REPORT Z_MM_RP_MATERIAL_TAG NO STANDARD PAGE HEADING
MESSAGE-ID Z_MSGCLASS
LINE-COUNT 100
LINE-SIZE 132.
************************************************************************
* Report Name : Z_MM_RP_MATERIAL_TAG *
* Description : Material Management: Material Tag *
* This report displays the following: *
* 1) GRN Number *
* 2) GRN Date *
* 3) Material Group *
* 4) Description of storage location *
* 5) Purchase Order Number *
* 6) Material Number *
* 7) Base Unit of measure *
* 8) Quantity *
* 9) Manufacturer Part Number *
* 10) Material Description (Short Text) *
* based on Plant,Material Document No, *
* Functional : *
* Developer : *
* Development class : Z_MSGCLASS *
************************************************************************
*----------------------------------------------------------------------*
* DATABASE TABLES
*----------------------------------------------------------------------*
TABLES : MKPF, " Header: Material Document
MSEG. " Document Segment: Material
*----------------------------------------------------------------------*
* INTERNAL TABLE DECLARATIONS
*----------------------------------------------------------------------*
*--- Work area to hold Header: Material Document.
DATA: WA_MKPF LIKE MKPF.
*---- Internal table to hold Document Segment: Material
DATA: BEGIN OF IT_MSEG OCCURS 10,
MBLNR LIKE MSEG-MBLNR, " Material Document No (GRN No)
MJAHR LIKE MSEG-MJAHR, " Material doc. year
ZEILE LIKE MSEG-ZEILE, " Item in Material Document
MATNR LIKE MSEG-MATNR, " Material no
WERKS LIKE MSEG-WERKS, " Plant
LGORT LIKE MSEG-LGORT, " Storage Location
MENGE LIKE MSEG-MENGE, " Quantity
MEINS LIKE MSEG-MEINS, " Base Unit of Measure
EBELN LIKE MSEG-EBELN, " Purchasing Document Number
END OF IT_MSEG.
*---- Internal table to hold Material Master
DATA: BEGIN OF IT_MARA OCCURS 10,
MATNR LIKE MARA-MATNR, " Material Number
MATKL LIKE MARA-MATKL, " Material Group
MFRPN LIKE MARA-MFRPN, " Manufacturer Part Number
END OF IT_MARA.
*---- Internal table to hold Material Descriptions
DATA: BEGIN OF IT_MAKT OCCURS 10,
MATNR LIKE MAKT-MATNR, " Material Number
SPRAS LIKE MAKT-SPRAS, " Language Key
MAKTX LIKE MAKT-MAKTX, " Material Description (Short Text)
END OF IT_MAKT.
*---- Internal table to hold Storage Locations
DATA: BEGIN OF IT_T001L OCCURS 10,
WERKS LIKE T001L-WERKS, " Plant
LGORT LIKE T001L-LGORT, " Storage Location
LGOBE LIKE T001L-LGOBE, " Description of Storage Location
END OF IT_T001L.
DATA: BEGIN OF IT_MARD OCCURS 10,
MATNR LIKE MARD-MATNR, " Material Number
WERKS LIKE MARD-WERKS, " Plant
LGORT LIKE MARD-LGORT, " Storage Location
LGPBE LIKE MARD-LGPBE, " Storage Bin
END OF IT_MARD.
DATA: BEGIN OF IT_T001W OCCURS 10,
WERKS LIKE T001W-WERKS,
NAME1 LIKE T001W-NAME1,
END OF IT_T001W.
*---- Internal table to hold Output
DATA: BEGIN OF IT_OUTPUT OCCURS 10,
MBLNR LIKE MKPF-MBLNR, " Material Document No (GRN No)
BUDAT LIKE MKPF-BUDAT, " Posting date in the document
MATKL LIKE MARA-MATKL, " Material Group
LGPBE LIKE MARD-LGPBE, " Storage Bin
EBELN LIKE MSEG-EBELN, " Purchasing Document Number
MATNR LIKE MSEG-MATNR, " Material no
MEINS LIKE MSEG-MEINS, " Base Unit of Measure
MENGE LIKE MSEG-MENGE, " Quantity
MFRPN LIKE MARA-MFRPN, " Manufacturer Part Number
MAKTX LIKE MAKT-MAKTX, " Material Description (Short Text)
LGOBE LIKE T001L-LGOBE, " Description of Storage Location
END OF IT_OUTPUT.
*----------------------------------------------------------------------*
* DATA DECLARATIONS
*----------------------------------------------------------------------*
DATA : V_MESG(200). " Message variable
*----------------------------------------------------------------------*
* SELECTION SCREEN
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
PARAMETERS: P_WERKS LIKE MSEG-WERKS OBLIGATORY, " Plant
P_MBLNR LIKE MKPF-MBLNR OBLIGATORY. " No of material document
SELECT-OPTIONS : S_MATNR FOR MSEG-MATNR. " Material Number
SELECTION-SCREEN END OF BLOCK SCR1.
*----------------------------------------------------------------------*
* AT SELECTION SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON P_WERKS.
*--- Perform to validate the Plant
PERFORM VALIDATE_WERKS.
AT SELECTION-SCREEN ON P_MBLNR.
*--- Perform to validate the No of material document
PERFORM VALIDATE_MBLNR.
AT SELECTION-SCREEN ON S_MATNR.
*--- Perform to validate the Material No
PERFORM VALIDATE_MATNR.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
*--- Perform to get Header: Material Document
PERFORM GET_MKPF_DATA.
*--- Perform to get Document Segment: Material
PERFORM GET_MSEG_DATA.
*--- Perform to get General Material Data
PERFORM GET_MARA_DATA.
*--- Perform to get Material Descriptions
PERFORM GET_MAKT_DATA.
*--- Perform to get Storage Locations
PERFORM GET_T001L_DATA.
*--- Perform to get
PERFORM GET_MARD_DATA.
PERFORM GET_T001W_DATA.
*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
END-OF-SELECTION.
*--- Perform to display the Material Tag.
PERFORM DISPLAY.
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* Perform to display the Material Tag
*----------------------------------------------------------------------*
FORM DISPLAY .
LOOP AT IT_MSEG.
ON CHANGE OF IT_MSEG-ZEILE.
WRITE: /01(100) SY-ULINE,
/01(01) SY-VLINE.
READ TABLE IT_T001W WITH KEY WERKS = IT_MSEG-WERKS.
IF SY-SUBRC = 0.
WRITE: 02(100) IT_T001W-NAME1 CENTERED.
ENDIF.
WRITE: 100(01) SY-VLINE,
/01(100) SY-ULINE,
100(01) SY-VLINE.
WRITE: /01(100) SY-ULINE.
WRITE: /01(01) SY-VLINE,
02(13) 'GRN. NO:'(002),
15(01) SY-VLINE,
16(10) IT_MSEG-MBLNR CENTERED,
45(01) SY-VLINE,
46(09) 'MTRL GRP'(003) CENTERED,
55(01) SY-VLINE,
56(24) 'LOCATION'(004) CENTERED,
80(01) SY-VLINE,
81(19)'STORAGE BIN' CENTERED,
100(01) SY-VLINE,
/01(100) SY-ULINE,
/01(01) SY-VLINE,
02(13) 'GRN. DATE:'(005),
15(01) SY-VLINE,
16(10) WA_MKPF-BUDAT,
45(01) SY-VLINE.
READ TABLE IT_MARA WITH KEY MATNR = IT_MSEG-MATNR.
IF SY-SUBRC = 0.
WRITE : 46(09) IT_MARA-MATKL CENTERED.
ENDIF.
WRITE: 55(01) SY-VLINE.
READ TABLE IT_T001L WITH KEY WERKS = IT_MSEG-WERKS LGORT = IT_MSEG-LGORT.
IF SY-SUBRC = 0.
WRITE: 56(16) IT_T001L-LGOBE CENTERED.
ENDIF.
WRITE: 80(01) SY-VLINE.
READ TABLE IT_MARD WITH KEY MATNR = IT_MSEG-MATNR.
IF SY-SUBRC = 0.
WRITE: 82(10) IT_MARD-LGPBE CENTERED.
ENDIF.
WRITE: 100(01) SY-VLINE,
/01(100) SY-ULINE,
/01(01) SY-VLINE,
02(13) 'PO. NO.:'(006),
15(01) SY-VLINE,
16(10) IT_MSEG-EBELN CENTERED,
55(01) SY-VLINE,
56(11) 'UOM'(007) CENTERED,
66(01) SY-VLINE,
67(12) 'QTY'(008) CENTERED,
80(01) SY-VLINE,
100(01) SY-VLINE,
/01(100) SY-ULINE,
/01(01) SY-VLINE,
02(13) 'ITEM CODE:'(009),
15(01) SY-VLINE,
16(18) IT_MSEG-MATNR CENTERED,
55(01) SY-VLINE,
59(03) IT_MSEG-MEINS CENTERED,
66(01) SY-VLINE,
67(13) IT_MSEG-MENGE CENTERED, "#EC UOM_IN_MES
80(01) SY-VLINE,
100(01) SY-VLINE,
/01(100) SY-ULINE,
/01(01) SY-VLINE,
02(13) 'VENDOR PART. NO:'(010),
15(01) SY-VLINE.
READ TABLE IT_MARA WITH KEY MATNR = IT_MSEG-MATNR.
IF SY-SUBRC = 0.
WRITE: 16(40) IT_MARA-MFRPN.
ENDIF.
WRITE: 80(01) SY-VLINE,
100(01) SY-VLINE,
/01(100) SY-ULINE,
/01(01) SY-VLINE,
02(13) 'ITEM DESCR.:'(011),
15(01) SY-VLINE.
READ TABLE IT_MAKT WITH KEY MATNR = IT_MARA-MATNR
SPRAS = SY-LANGU.
IF SY-SUBRC = 0.
WRITE: 16(40) IT_MAKT-MAKTX.
ENDIF.
WRITE :80(01) SY-VLINE,
100(01) SY-VLINE,
/01(100) SY-ULINE.
NEW-PAGE.
ENDON.
ENDLOOP.
ENDFORM. " DISPLAY
*&---------------------------------------------------------------------*
*& Form VALIDATE_WERKS
*&---------------------------------------------------------------------*
* Perform to validate the Plant
*----------------------------------------------------------------------*
FORM VALIDATE_WERKS .
DATA: LV_WERKS LIKE T001W-WERKS. " Plant
*--- Check for a valid Plant
SELECT SINGLE WERKS
INTO LV_WERKS
FROM T001W
WHERE WERKS = P_WERKS.
IF SY-SUBRC <> 0.
*--- Message to enter Valid Plant
V_MESG = 'Enter a Valid Plant'(012).
MESSAGE E002(Z_MSGCLASS) WITH V_MESG.
ENDIF.
ENDFORM. " VALIDATE_WERKS
*&---------------------------------------------------------------------*
*& Form VALIDATE_MBLNR
*&---------------------------------------------------------------------*
* Perform to validate the No of material document
*----------------------------------------------------------------------*
FORM VALIDATE_MBLNR .
DATA: LV_MBLNR LIKE MKPF-MBLNR. " Number of material document
*--- Check for a valid Material Document
*--- Select construct against the chk table for a No of material doc
SELECT SINGLE MBLNR
INTO LV_MBLNR
FROM MKPF
WHERE MBLNR = P_MBLNR.
IF SY-SUBRC <> 0.
*--- Message to enter a valid Number of Material Document
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Number of Material Document'(013).
ENDIF.
ENDFORM. " VALIDATE_MBLNR
*&---------------------------------------------------------------------*
*& Form VALIDATE_MATNR
*&---------------------------------------------------------------------*
* Perform to validate the Material No
*----------------------------------------------------------------------*
FORM VALIDATE_MATNR .
DATA: LV_MATNR LIKE MARA-MATNR. " Material Number
*--- Check for a valid Vendor
IF NOT S_MATNR[] IS INITIAL.
*--- Select construct against the chk table for a Vendor Number
SELECT SINGLE MATNR
INTO LV_MATNR
FROM MARA
WHERE MATNR IN S_MATNR.
IF SY-SUBRC <> 0.
*--- Message to enter a Valid Material Number
V_MESG = 'Enter a Valid Material Number'(014).
MESSAGE E002(Z_MSGCLASS) WITH V_MESG.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_MATNR
*&---------------------------------------------------------------------*
*& Form GET_MKPF_DATA
*&---------------------------------------------------------------------*
* Perform to get Header: Material Document
*----------------------------------------------------------------------*
FORM GET_MKPF_DATA .
*---- Select construct to get the Material Document
SELECT SINGLE * FROM MKPF
INTO WA_MKPF
WHERE MBLNR = P_MBLNR.
IF SY-SUBRC <> 0.
*--- Message if no data exists with the selection criteria.
V_MESG = 'No data exists with the selection criteria'(015).
MESSAGE E002(Z_MSGCLASS) WITH V_MESG.
ENDIF.
ENDFORM. " GET_MKPF_DATA
*&---------------------------------------------------------------------*
*& Form GET_MSEG_DATA
*&---------------------------------------------------------------------*
* Perform to get Document Segment: Material
*----------------------------------------------------------------------*
FORM GET_MSEG_DATA .
*--- Check for a valid Material Document
IF NOT WA_MKPF IS INITIAL.
SELECT MBLNR MJAHR ZEILE MATNR WERKS LGORT MENGE MEINS EBELN
FROM MSEG
INTO TABLE IT_MSEG
WHERE MBLNR = WA_MKPF-MBLNR
AND MJAHR = WA_MKPF-MJAHR
AND WERKS = P_WERKS.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDFORM. " GET_MSEG_DATA
*&---------------------------------------------------------------------*
*& Form GET_MARA_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_MARA_DATA .
*--- Check for a valid General Material Data
IF NOT IT_MSEG[] IS INITIAL.
SELECT MATNR MATKL MFRPN
FROM MARA
INTO TABLE IT_MARA
FOR ALL ENTRIES IN IT_MSEG
WHERE MATNR = IT_MSEG-MATNR.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDFORM. " GET_MARA_DATA
*&---------------------------------------------------------------------*
*& Form GET_MAKT_DATA
*&---------------------------------------------------------------------*
* Perform to get Material Descriptions
*----------------------------------------------------------------------*
FORM GET_MAKT_DATA .
*--- Check for a valid Material Descriptions
IF NOT IT_MSEG[] IS INITIAL.
SELECT MATNR SPRAS MAKTX
FROM MAKT
INTO TABLE IT_MAKT
FOR ALL ENTRIES IN IT_MSEG
WHERE MATNR = IT_MSEG-MATNR.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDFORM. " GET_MAKT_DATA
*&---------------------------------------------------------------------*
*& Form GET_T001L_DATA
*&---------------------------------------------------------------------*
* Perform to get Storage Locations
*----------------------------------------------------------------------*
FORM GET_T001L_DATA .
*--- Check for a valid Material Descriptions
IF NOT IT_MSEG[] IS INITIAL.
SELECT WERKS LGORT LGOBE
FROM T001L
INTO TABLE IT_T001L
FOR ALL ENTRIES IN IT_MSEG
WHERE WERKS = IT_MSEG-WERKS
AND LGORT = IT_MSEG-LGORT.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDFORM. " GET_T001L_DATA
*&---------------------------------------------------------------------*
*& Form GET_MARD_DATA
*&---------------------------------------------------------------------*
* Perform to get
*----------------------------------------------------------------------*
FORM GET_MARD_DATA .
*--- Check for a valid Material Descriptions
IF NOT IT_MSEG[] IS INITIAL.
SELECT MATNR WERKS LGORT LGPBE
FROM MARD
INTO TABLE IT_MARD
FOR ALL ENTRIES IN IT_MSEG
WHERE MATNR = IT_MSEG-MATNR.
IF SY-SUBRC = 0.
SORT IT_MARD BY MATNR.
ENDIF.
ENDIF.
ENDFORM. " GET_MARD_DATA
*&---------------------------------------------------------------------*
*& Form GET_T001W_DATA
*&---------------------------------------------------------------------*
* Perform to get
*----------------------------------------------------------------------*
FORM GET_T001W_DATA .
*--- Check for a valid Material Descriptions
IF NOT IT_MSEG[] IS INITIAL.
SELECT WERKS NAME1
FROM T001W
INTO TABLE IT_T001W
FOR ALL ENTRIES IN IT_MSEG
WHERE WERKS = IT_MSEG-WERKS.
IF SY-SUBRC = 0.
ENDIF.
ENDIF.
ENDFORM. " GET_MARD_DATA
Monday, November 5, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment