REQUIREMENT: -
Get the Plant and storage location from the user and to get the available materials in the particular storage location and display in a report.
When the material number in the report is selected the material description and other complete details are displayed in a new screen using interactive report.
STEPS FOLLOWED TO ACHIEVE THE GOAL:
Go to SE38 ABAP Editor create a new program.
Code the logic in the ABAP Editor.
Check –Activate- and Execute the code.
Type in the Required Parameters or select a value from F4 Help Screen.
Execute the project
The Report is displayed in the output Screen.
Select a record using the mouse double click.
A new screen shows the output based on the selected record achieving the interactive reporting.
For the complete program,
*&----------------------------------------------------------------* *& Report ZVikram_interactive * *& * *&----------------------------------------------------------------* *& Published at SAPTechnical.COM * *& * *&----------------------------------------------------------------*
REPORT ZVikram_interactive NO STANDARD PAGE HEADING LINE-SIZE 255.
********** THE INITIALIZATION PART CREATING STRUCTURES*************
INITIALIZATION.
TYPES : BEGIN OF TY_MARD, MATNR TYPE MARD-MATNR, WERKS TYPE MARD-WERKS, LGORT TYPE MARD-LGORT, END OF TY_MARD,
BEGIN OF TY_MARA, MATNR TYPE MARA-MATNR, ERSDA TYPE MARA-ERSDA, ERNAM TYPE MARA-ERNAM, MTART TYPE MARA-MTART, MATKL TYPE MARA-MATKL, END OF TY_MARA,
BEGIN OF TY_MAKT, MATNR TYPE MAKT-MATNR, SPRAS TYPE MAKT-SPRAS, MAKTX TYPE MAKT-MAKTX, END OF TY_MAKT,
BEGIN OF TY_FINAL, MATNR TYPE MARA-MATNR, ERSDA TYPE MARA-ERSDA, ERNAM TYPE MARA-ERNAM, MTART TYPE MARA-MTART, MATKL TYPE MARA-MATKL, WERKS TYPE MARD-WERKS, LGORT TYPE MARD-LGORT, SPRAS TYPE MAKT-SPRAS, MAKTX TYPE MAKT-MAKTX, END OF TY_FINAL.
***** THE INITIALIZATION PART CREATING WORKAREA AND INTERNAL TABLE*****
DATA : W_MARD TYPE TY_MARD, I_MARD TYPE TABLE OF TY_MARD,
W_MARA TYPE TY_MARA, I_MARA TYPE TABLE OF TY_MARA,
W_MAKT TYPE TY_MAKT, I_MAKT TYPE TABLE OF TY_MAKT,
W_FINAL TYPE TY_FINAL, I_FINAL TYPE TABLE OF TY_FINAL. **************************START-OF-SELECTION.**************************
START-OF-SELECTION.
*************************GET INPUT FROM USER***************************
PARAMETER : PLANT TYPE MARD-WERKS,
STLOC TYPE MARD-LGORT.
****SELECT DATA FROM DATABASE INTO INTERNAL TABLES*********************
**SELECT FROM MARD THE REQUIRED FIELDS FOR THE GIVEN INPUT*************
SELECT MATNR WERKS LGORT FROM MARD INTO TABLE I_MARD WHERE WERKS = PLANT AND LGORT = STLOC.
*****CHECK IF RECORDS ARE FETCHED IF NO EXIT OUT OF THE PROGRAM********
IF SY-SUBRC <> 0. WRITE 'NO RECORDS'. EXIT. ELSE.
***IF RECORDS ARE FETCHED FROM FRIST TABLE***************************** ****FETCH RELATED RECORDS FROM NEXT TABLE******************************
SELECT MATNR ERSDA ERNAM MTART MATKL FROM MARA INTO TABLE I_MARA FOR ALL ENTRIES IN I_MARD WHERE MATNR = I_MARD-MATNR. IF SY-SUBRC <> 0. WRITE 'NO MASTER DATA'. STOP. ELSE. SELECT MATNR SPRAS MAKTX FROM MAKT INTO TABLE I_MAKT FOR ALL ENTRIES IN I_MARA WHERE MATNR = I_MARA-MATNR AND SPRAS = 'E'. ENDIF. ENDIF.
*****READ FROM INTERNAL TABLE FOR OUTPUT ******************************
LOOP AT I_MARA INTO W_MARA. AT FIRST.
WRITE : SY-ULINE(100), /1 SY-VLINE, 25 'EXAMPLE INTERACTIVE REPORT', 100 SY-VLINE, / SY-ULINE(100),
/1 SY-VLINE, 2 'MATERIAL NUMBER' , 20 SY-VLINE, 22 'CREATION DATE', 40 SY-VLINE, 42 'USER NAME', 60 SY-VLINE, 62 'MATERIAL TYPE', 80 SY-VLINE, 82 'MATERIAL GROUP', 100 SY-VLINE, / SY-ULINE(100). ENDAT.
ON CHANGE OF W_MARA-MATNR. READ TABLE I_MARD INTO W_MARD WITH KEY MATNR = W_MARA-MATNR. ENDON.
WRITE :/1 SY-VLINE, 2 W_MARA-MATNR , 20 SY-VLINE, 22 W_MARA-ERSDA, 40 SY-VLINE, 42 W_MARA-ERNAM, 60 SY-VLINE, 62 W_MARA-MTART, 80 SY-VLINE, 82 W_MARA-MATKL, 100 SY-VLINE.
HIDE W_MARA-MATNR. CLEAR W_MARA-MATNR.
WRITE: / SY-ULINE(100).
ENDLOOP.
*****************END-OF-SELECTION.*************************************
END-OF-SELECTION.
****MOVING VALUES IN TO FINAL INTERNAL TABLE **************************
LOOP AT I_MARA INTO W_MARA. ON CHANGE OF W_MARA-MATNR. READ TABLE I_MAKT INTO W_MAKT WITH KEY MATNR = W_MARA-MATNR. READ TABLE I_MARD INTO W_MARD WITH KEY MATNR = W_MARA-MATNR. ENDON.
W_FINAL-MATNR = W_MARA-MATNR. W_FINAL-ERSDA = W_MARA-ERSDA. W_FINAL-ERNAM = W_MARA-ERNAM. W_FINAL-MTART = W_MARA-MTART. W_FINAL-MATKL = W_MARA-MATKL. W_FINAL-WERKS = W_MARD-WERKS. W_FINAL-LGORT = W_MARD-LGORT. W_FINAL-SPRAS = W_MAKT-SPRAS. W_FINAL-MAKTX = W_MAKT-MAKTX.
APPEND W_FINAL TO I_FINAL.
ENDLOOP.
********AT LINE-SELECTION EVENT TRIGERING INTERACTIVE REPORTING.*******
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.
**DISPLAY OUTPUT IN NEW SCREEN AT LINE SELECTION BY USER MOUSE CLICK ** WRITE: / W_MARA-MATNR COLOR 2.
READ TABLE I_FINAL INTO W_FINAL WITH KEY MATNR = W_MARA-MATNR SPRAS = 'EN'.
ULINE 1(200). WRITE : /1 SY-VLINE, 75 'EXAMPLE INTERACTIVE REPORT', 200 SY-VLINE, SY-ULINE(200), /1 SY-VLINE, 2 'MATERIAL NUMBER' , 20 SY-VLINE, 22 'CREATION DATE', 40 SY-VLINE, 42 'USER NAME', 60 SY-VLINE, 62 'MATERIAL TYPE', 80 SY-VLINE, 82 'MATERIAL GROUP', 100 SY-VLINE, 102 'PLANT NUMBER', 120 SY-VLINE, 122 'STORAG LOCATION', 140 SY-VLINE, 142 'LANGUAGE', 160 SY-VLINE, 162 'DESCRIPTION', 200 SY-VLINE, / SY-ULINE(200).
WRITE :/1 SY-VLINE, 2 W_FINAL-MATNR , 20 SY-VLINE, 22 W_FINAL-ERSDA, 40 SY-VLINE, 42 W_FINAL-ERNAM, 60 SY-VLINE, 62 W_FINAL-MTART, 80 SY-VLINE, 82 W_FINAL-MATKL, 100 SY-VLINE, 102 W_FINAL-WERKS, 120 SY-VLINE, 122 W_FINAL-LGORT, 140 SY-VLINE, 142 W_FINAL-SPRAS, 160 SY-VLINE, 162 W_FINAL-MAKTX, 200 SY-VLINE, / SY-ULINE(200).
CLEAR W_MARA-MATNR.
ENDCASE.