Get cursor/Line selection
REPORT ZSAPN_INTERACTIVE_GETCURSOR LINE-COUNT 30(3) NO STANDARD PAGE HEADING.
DATA : IT_MARA TYPE TABLE OF MARA,
WA_MARA TYPE MARA,
IT_MAKT TYPE TABLE OF MAKT,
WA_MAKT TYPE MAKT.
DATA : FNAM(30), FVAL(50).
SELECT-OPTIONS : S_MATNR FOR WA_MARA-MATNR.
INITIALIZATION.
AT SELECTION-SCREEN.
PERFORM VALIDATE_INPUT.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM DISPLAY_DATA.
TOP-OF-PAGE.
PERFORM DISPLAY_TOPOFPAGE.
AT LINE-SELECTION.
PERFORM DISPLAY_SECONDARYLIST.
TOP-OF-PAGE DURING LINE-SELECTION.
PERFORM LINE_TOPOFPAGE.
FORM VALIDATE_INPUT .
IF S_MATNR IS INITIAL.
MESSAGE 'Enter material input' TYPE 'E'.
ENDIF.
ENDFORM. " VALIDATE_INPUT
FORM GET_DATA .
SELECT * FROM MARA INTO TABLE IT_MARA WHERE MATNR IN S_MATNR.
ENDFORM. " GET_DATA
FORM DISPLAY_DATA .
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS.
ENDLOOP.
ENDFORM. " DISPLAY_DATA
FORM DISPLAY_SECONDARYLIST .
GET CURSOR FIELD FNAM VALUE FVAL.
CONDENSE FNAM.
CONDENSE FVAL.
IF FNAM = 'WA_MARA-MATNR'.
SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR = FVAL .
WRITE:/ WA_MARA-MATNR, WA_MARA-MBRSH, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-ERSDA, WA_MARA-ERNAM.
ELSEIF FNAM = 'WA_MARA-MTART'.
SELECT * FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS WHERE MTART = FVAL.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL.
ENDLOOP.
ENDIF.
ENDFORM. " DISPLAY_SECONDARYLIST
FORM DISPLAY_TOPOFPAGE .
WRITE:/ 'Material Details' COLOR 3.
ENDFORM. " DISPLAY_TOPOFPAGE
FORM LINE_TOPOFPAGE .
IF FNAM = 'WA_MARA-MATNR'.
WRITE:/ 'Material details ', WA_MARA-MATNR COLOR 5.
ELSEIF FNAM = 'WA_MARA-MTART'.
WRITE:/ 'Material with material type ', WA_MARA-MTART COLOR 5.
ENDIF.
ENDFORM. " LINE_TOPOFPAGE