Skip to Content
-1
Jul 11, 2019 at 06:19 AM

Interactive Report + Dynamic Screen Selection

165 Views Last edit Jul 11, 2019 at 06:55 AM 2 rev

LINE SELECTION IS NOT WORKING PROPERLY.

FIRST SCREEN: MARA-MATNR & MAKT-MAKTG

LINE SELECTION SCREEN: MATNR ERSDA ERNAM LAEDA MTART MATKL MEINS LGORT WERKS

SELECTION SCREEN ------ Works Fine.

FIRST SCREEN ---- Works Fine.

LINE SELECTION ---- Shows ALL DATA instead of showing a single line based of the MATNR selected.

TABLES: MARA, VBAK, MAKT, MARD, VBAP.
****** Selection Screen ******
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT01.
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: DATE FOR SY-DATUM DEFAULT ' ' TO SY-DATUM OBLIGATORY.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT02.
SELECTION-SCREEN SKIP 1.
PARAMETERS: MATRL_R RADIOBUTTON GROUP G1 USER-COMMAND D1 DEFAULT 'X',
 SALES_R RADIOBUTTON GROUP G1 .
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT03.
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: MATNR FOR MARA-MATNR MODIF ID D1 NO INTERVALS.
SELECT-OPTIONS: VBELN FOR VBAK-VBELN MODIF ID D2 NO INTERVALS.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION-SCREEN OUTPUT.
 LOOP AT SCREEN.
 IF SCREEN-GROUP1 = 'D1'.
 IF MATRL_R = 'X'.
 SCREEN-INVISIBLE = '0'.
 SCREEN-ACTIVE = '1'.
 ELSE.
 SCREEN-INVISIBLE = '1'.
 SCREEN-ACTIVE = '0'.
 ENDIF.
 MODIFY SCREEN.
 ENDIF.
 IF SCREEN-GROUP1 = 'D2'.
 IF SALES_R = 'X'.
 SCREEN-INVISIBLE = '0'.
 SCREEN-ACTIVE = '1'.
 ELSE.
 SCREEN-INVISIBLE = '1'.
 SCREEN-ACTIVE = '0'.
 ENDIF.
 MODIFY SCREEN.
 ENDIF.
 ENDLOOP.
INITIALIZATION.
TEXT01 = 'Selection Screen Tutorial'.
TEXT02 = 'Radio Buttons'.
TEXT03 = 'Dynamic Screen Selection'.
TYPES: BEGIN OF ITAB1,
 MATNR TYPE MARA-MATNR,
 ERSDA TYPE MARA-ERSDA,
 ERNAM TYPE MARA-ERNAM,
 LAEDA TYPE MARA-LAEDA,
 MTART TYPE MARA-MTART,
 MATKL TYPE MARA-MATKL,
 MEINS TYPE MARA-MEINS,
 END OF ITAB1.
DATA: IT_MARA TYPE STANDARD TABLE OF ITAB1,
 WA_MARA TYPE ITAB1.
TYPES: BEGIN OF ITAB2,
 MATNR TYPE MAKT-MATNR,
 MAKTG TYPE MAKT-MAKTG,
 END OF ITAB2.
DATA: IT_MAKT TYPE STANDARD TABLE OF ITAB2,
 WA_MAKT TYPE ITAB2.
TYPES: BEGIN OF ITAB3,
 MATNR TYPE MARD-MATNR,
 LGORT TYPE MARD-LGORT,
 WERKS TYPE MARD-WERKS,
 END OF ITAB3.
DATA: IT_MARD TYPE STANDARD TABLE OF ITAB3,
 WA_MARD TYPE ITAB3.
TYPES: BEGIN OF ITAB4,
 MATNR TYPE MARA-MATNR,
 ERSDA TYPE MARA-ERSDA,
 ERNAM TYPE MARA-ERNAM,
 LAEDA TYPE MARA-LAEDA,
 MTART TYPE MARA-MTART,
 MATKL TYPE MARA-MATKL,
 MEINS TYPE MARA-MEINS,
 MAKTG TYPE MAKT-MAKTG,
 LGORT TYPE MARD-LGORT,
 WERKS TYPE MARD-WERKS,
 END OF ITAB4.
DATA: IT_FINAL TYPE STANDARD TABLE OF ITAB4,
 WA_FINAL TYPE ITAB4.
TYPES: BEGIN OF ITAB6,
 VBELN TYPE VBAK-VBELN,
 ERDAT TYPE VBAK-ERDAT,
 END OF ITAB6.
DATA: IT_VBAK TYPE STANDARD TABLE OF ITAB6,
 WA_VBAK TYPE ITAB6.
TYPES: BEGIN OF ITAB5,
 VBELN TYPE VBAP-VBELN,
 POSNR TYPE VBAP-POSNR,
 MATNR TYPE VBAP-MATNR,
 MATWA TYPE VBAP-MATWA,
 END OF ITAB5.
DATA: IT_VBAP TYPE STANDARD TABLE OF ITAB5,
 WA_VBAP TYPE ITAB5.
TYPES: BEGIN OF ITAB9,
 VBELN TYPE VBAK-VBELN,
 ERDAT TYPE VBAK-ERDAT,
 POSNR TYPE VBAP-POSNR,
 MATNR TYPE VBAP-MATNR,
 MATWA TYPE VBAP-MATWA,
 END OF ITAB9.
DATA: IT_FINAL1 TYPE STANDARD TABLE OF ITAB9,
 WA_FINAL1 TYPE ITAB9.
************* MATERIAL REPORT ***************************************************************************************************************************
START-OF-SELECTION.
IF MATRL_R = 'X'.
SELECT MATNR ERSDA ERNAM LAEDA MTART MATKL MEINS FROM MARA INTO TABLE IT_MARA WHERE MATNR IN MATNR AND ERSDA IN DATE.
IF IT_MARA IS NOT INITIAL.
SELECT MATNR MAKTG FROM MAKT INTO TABLE IT_MAKT FOR ALL ENTRIES IN IT_MARA WHERE MATNR = IT_MARA-MATNR AND SPRAS = 'E'.
SELECT MATNR LGORT WERKS FROM MARD INTO TABLE IT_MARD FOR ALL ENTRIES IN IT_MARA WHERE MATNR = IT_MARA-MATNR.
LOOP AT IT_MARA INTO WA_MARA.
 WA_FINAL-MATNR = WA_MARA-MATNR.
 WA_FINAL-ERSDA = WA_MARA-ERSDA.
 WA_FINAL-ERNAM = WA_MARA-ERNAM.
 WA_FINAL-LAEDA = WA_MARA-LAEDA.
 WA_FINAL-MTART = WA_MARA-MTART.
 WA_FINAL-MATKL = WA_MARA-MATKL.
 WA_FINAL-MEINS = WA_MARA-MEINS.
 READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_MARA-MATNR.
 WA_FINAL-MAKTG = WA_MAKT-MAKTG.
 READ TABLE IT_MARD INTO WA_MARD WITH KEY MATNR = WA_MAKT-MATNR.
 WA_FINAL-LGORT = WA_MARD-LGORT.
 WA_FINAL-WERKS = WA_MARD-WERKS.
 APPEND WA_FINAL TO IT_FINAL.
 CLEAR WA_MARA-MATNR.
 ENDLOOP.
 WRITE: /0 'MATERIAL NO' COLOR 2,
 40 'MATERIAL DESCRIPTION' COLOR 5.
 LOOP AT IT_FINAL INTO WA_FINAL.
 WRITE: /0 WA_FINAL-MATNR,
 40 WA_FINAL-MAKTG.
 ENDLOOP.
ELSE.
 MESSAGE S000(Y_MSG) DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
*CLEAR WA_FINAL-MATNR.
*BREAK-POINT.
AT LINE-SELECTION.
*REFRESH IT_FINAL.
*CLEAR WA_FINAL.
IF MATRL_R = 'X'.
WRITE : /0 'MATERIAL NO' COLOR 1,
 20 'CREATED ON' COLOR 2,
 40 'CREATED BY' COLOR 3,
 60 'LAST CHANGE' COLOR 4,
 80 'MATERIAL TYPE' COLOR 5,
 100 'MATERIAL GROUP' COLOR 6,
 120 'UNIT OF MEASURE' COLOR 7,
 140 'STORE_LOCATION' COLOR 1,
 160 'PLANT' COLOR 2.
 LOOP AT IT_FINAL INTO WA_FINAL.
 WRITE: /0 WA_FINAL-MATNR,
 20 WA_FINAL-ERSDA,
 40 WA_FINAL-ERNAM,
 60 WA_FINAL-LAEDA,
 80 WA_FINAL-MTART,
 100 WA_FINAL-MATKL,
 120 WA_FINAL-MEINS,
 140 WA_FINAL-LGORT,
 160 WA_FINAL-WERKS.
 ENDLOOP.
ENDIF.
END-OF-SELECTION.
******************** END OF MATERIAL REPORT *************************************************************************************************************
******************** START OF SALES REPORT **************************************************************************************************************
*BREAK-POINT.
IF MATRL_R = ' '.
SELECT VBELN ERDAT FROM VBAK INTO TABLE IT_VBAK WHERE VBELN IN VBELN AND ERDAT IN DATE.
 IF IT_VBAK IS NOT INITIAL.
SELECT VBELN POSNR MATNR MATWA FROM VBAP INTO TABLE IT_VBAP FOR ALL ENTRIES IN IT_VBAK WHERE VBELN = IT_VBAK-VBELN.
WRITE: /0 'SALES DOCUMENT'COLOR 2,
 40 'CREATED ON' COLOR 5.
LOOP AT IT_VBAK INTO WA_VBAK.
 WRITE: /0 WA_VBAK-VBELN COLOR 5,
 40 WA_VBAK-ERDAT COLOR 2.
ENDLOOP.
ELSE.
 MESSAGE S000(Y_MSG) DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
CLEAR WA_VBAK-VBELN.
AT LINE-SELECTION.
IF MATRL_R = ' '.
WRITE : /0 'SALES DOCUMENT' COLOR 1,
 20 'SALES DOCUMENT ITEM' COLOR 2,
 60 'MATERIAL NUMBER' COLOR 3,
 80 'MATERIAL ENTERED' COLOR 4.
 LOOP AT IT_VBAP INTO WA_VBAP WHERE VBELN = WA_VBAK-VBELN.
 WA_FINAL1-VBELN = WA_VBAP-VBELN.
 WA_FINAL1-POSNR = WA_VBAP-POSNR.
 WA_FINAL1-MATNR = WA_VBAP-MATNR.
 WA_FINAL1-MATWA = WA_VBAP-MATWA.
 APPEND WA_FINAL1 TO IT_FINAL1.
 ENDLOOP.
 LOOP AT IT_FINAL1 INTO WA_FINAL1.
 WRITE: /0 WA_FINAL1-VBELN,
 20 WA_FINAL1-POSNR,
 60 WA_FINAL1-MATNR,
 80 WA_FINAL1-MATWA.
 ENDLOOP.
 ENDIF.

Attachments

first-screen.png (40.7 kB)
line-selection.png (71.3 kB)