TABLES: MKPF, MSEG, EKKO, LFA1.
DATA: BEGIN OF ITAB OCCURS 10,
MBLNR LIKE MKPF-MBLNR, "MATL DOCN. NUMBER
XBLNR LIKE MKPF-XBLNR, "DELVERY NOTE NUMBER
BUDAT LIKE MKPF-BUDAT, "MAT.DOC.POSTING DATE
BLDAT LIKE MKPF-BLDAT, "GRN DATE
LIFNR LIKE MSEG-LIFNR, "SUPPLIER NUMBER
EBELN LIKE MSEG-EBELN, "PO NUMBER
MATNR LIKE MSEG-MATNR, "MATERIAL NUMBER
MEINS LIKE MSEG-MEINS, "UNIT OF MEASURE
LSMNG LIKE MSEG-LSMNG, "ADVISED QUANTITY
ERFMG LIKE MSEG-ERFMG, "RECEIVED QUANTITY
ZEILE LIKE MSEG-ZEILE, "LINE ITEM NUMBER
SGTXT LIKE MSEG-SGTXT, "TEXT(LOCATION)
BISMT LIKE MARA-BISMT, "OLD MATERIAL NUMBER
WEMPF LIKE MSEG-WEMPF, "GOODS RECEIPIENT(VERIFIED BY)
BEDAT LIKE EKKO-BEDAT, "PO DATE
NAME1 LIKE LFA1-NAME1, "SUPPLIER NAME
ORT01 LIKE LFA1-ORT01, "CITY
PSTLZ LIKE LFA1-PSTLZ, "POSTAL CODE
MAKTX LIKE MAKT-MAKTX, "MATL DESCRIPTION
J_1IEXRN LIKE J_1IMOVEND-J_1IEXRN, "EXCISE REGN NO
EXCESS LIKE MSEG-LSMNG, "EXCESS QTY
SHORT LIKE MSEG-LSMNG, "SHORT QTY
WERKS LIKE MSEG-WERKS, "PLANT
LGORT LIKE MSEG-LGORT, "STORAGE LOCATION
ABLAD LIKE MSEG-ABLAD, "UNLOADING POINT
LGPBE LIKE MARD-LGPBE, "STORAGE BIN
CHARG LIKE MSEG-CHARG,
END OF ITAB.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE T1.
PARAMETERS S1 LIKE MKPF-MBLNR MATCHCODE OBJECT ZGRNLIST OBLIGATORY.
SELECT-OPTIONS S3 FOR MSEG-ZEILE NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK B1.
INITIALIZATION.
T1 = 'Matnr & YEAR'.
START-OF-SELECTION.
SELECT MKPF~MBLNR MKPF~XBLNR MKPF~BUDAT MKPF~BLDAT MSEG~LIFNR
MSEG~EBELN MSEG~MATNR MSEG~MEINS MSEG~LSMNG MSEG~ERFMG MSEG~ZEILE MSEG~SGTXT
MSEG~WEMPF MSEG~WERKS MSEG~LGORT MSEG~ABLAD MSEG~CHARG
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM MKPF INNER JOIN MSEG
ON MKPF~MBLNR = MSEG~MBLNR
WHERE MKPF~MBLNR = S1
AND MSEG~BWART = '101'
AND MSEG~ZEILE IN S3.
LOOP AT ITAB.
SELECT SINGLE BEDAT FROM EKKO INTO CORRESPONDING FIELDS OF ITAB
WHERE EBELN = ITAB-EBELN.
SELECT SINGLE NAME1 ORT01 PSTLZ FROM LFA1 INTO CORRESPONDING
FIELDS OF ITAB WHERE LIFNR = ITAB-LIFNR.
SELECT SINGLE MAKTX FROM MAKT INTO CORRESPONDING FIELDS OF ITAB
WHERE MATNR = ITAB-MATNR.
SELECT SINGLE BISMT FROM MARA INTO CORRESPONDING FIELDS OF ITAB
WHERE MATNR = ITAB-MATNR.
SELECT SINGLE J_1IEXRN FROM J_1IMOVEND INTO CORRESPONDING FIELDS
OF ITAB WHERE LIFNR = ITAB-LIFNR.
SELECT SINGLE LGPBE FROM MARD INTO CORRESPONDING FIELDS OF ITAB
WHERE MATNR = ITAB-MATNR AND WERKS = ITAB-WERKS AND
LGORT = ITAB-LGORT.
IF ITAB-LSMNG <= ITAB-ERFMG.
ITAB-EXCESS = ITAB-ERFMG - ITAB-LSMNG.
MODIFY ITAB.
ENDIF.
IF ITAB-LSMNG >= ITAB-ERFMG.
ITAB-SHORT = ITAB-LSMNG - ITAB-ERFMG.
MODIFY ITAB.
ENDIF.
ENDLOOP.