Interactive report using HIDE technique in SAP ABAP

Interactive report using hide technique in SAP ABAP programming, using hide technique in ABAP reporting

+ -
Requirement:Develop a material master report which displays the basic details on the basic list and description details in the secondary list for a material type input (selection screen parameter).

Requirement Analysis: In the above requirement we have to get material details for a material type input(Parameter input for MTART field), when ever user double clicks on any record of basic list, it will go to second screen and display descriptions for that material, display page header and footer for the report.

SAP Tables to be used are: MARA(Material Master), MAKT(Material descriptions).

Step1: Define report heading.

Go to SE38, create a program ZSAPN_INTERACTIVE_REPORT1.In order to display footer information we have to provide some space for footer, it can be defined at report definition(First line of the report), to provide space for footer we use below syntax.
REPORT ZSAPN_INTERACTIVE_REPORT LINE-COUNT 34(2) NO STANDARD PAGE HEADING. "leave some pages for footer and hide standard heading
In the above deceleration we have provided 34 lines for report and 2 lines for footer i:e 34(2), we don`t need standard page heading so we used NO STANDARD PAGE HEADING.

Step2:Data decelerations and Selection screen.

Declare the required internal tables, work areas, variables etc and add selection screen element parameter for material type input.
DATA : IT_MARA TYPE TABLE OF MARA, "mara internal table
       WA_MARA TYPE MARA, "mara work area
       IT_MAKT TYPE TABLE OF MAKT, "MAKT internal table
       WA_MAKT TYPE MAKT. "MAKT work area

PARAMETERS P_MTART TYPE MARA-MTART. "selection screen element input field

Step3: Add code to get material basic details.

Add logic to get material details for the material type input under START-OF-SELECTION event.
START-OF-SELECTION.
  SELECT * FROM MARA
    INTO TABLE IT_MARA
    WHERE MTART = P_MTART.

Display materials and use HIDE technique

Display materials and use HIDE technique( HIDE area) to store line data.
  LOOP AT IT_MARA INTO WA_MARA.
    WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MBRSH.
    HIDE WA_MARA. "store line details in HIDE area
  ENDLOOP.

Step4: Get material descriptions using hide area

Get material descriptions from MAKT table based on HIDE area storage under AT LINE-SELECTION event.
AT LINE-SELECTION.
  SELECT * FROM MAKT
    INTO TABLE IT_MAKT
    WHERE MATNR = WA_MARA-MATNR.

Step5: Display material descriptions data

Display material descriptions data in secondary list.
  LOOP AT IT_MAKT INTO WA_MAKT.
    WRITE :/ WA_MAKT-MATNR, WA_MAKT-MAKTX.
  ENDLOOP.

Step6:Display top of page for basic list and secondary list

Display page heading for basic list under TOP-OF-PAGE event and display secondary list heading under TOP-OF-PAGE DURING LINE-SELECTION event.
TOP-OF-PAGE.
  WRITE : 'Material Basic Details' COLOR 5.
TOP-OF-PAGE DURING LINE-SELECTION.
  WRITE: 'Descriptions of material:', WA_MARA-MATNR COLOR 6.

Step7: Display footer for basic list

Display footer information for basic material list.
  WRITE: 'Report Generated at:', SY-DATUM COLOR 1.

Final report after modularization is below

REPORT ZSAPN_INTERACTIVE_REPORT LINE-COUNT 33(3) NO STANDARD PAGE HEADING. "leave some pages for footer and hide standard heading
DATA : IT_MARA TYPE TABLE OF MARA, "mara internal table
       WA_MARA TYPE MARA, "mara work area
       IT_MAKT TYPE TABLE OF MAKT, "MAKT internal table
       WA_MAKT TYPE MAKT. "MAKT work area

PARAMETERS P_MTART TYPE MARA-MTART. "selection screen element input field

INITIALIZATION. "initialization event

AT SELECTION-SCREEN. "at selection screen event to validate inputs
  PERFORM VALIDATE_INPUT. "Subroutine to validate input

START-OF-SELECTION.
  PERFORM GET_MATERIAL_DATA.
  PERFORM DISPLAY_MATERIALS.

TOP-OF-PAGE.
  PERFORM DISPLAY_HEADER.

END-OF-PAGE.
  PERFORM DISPLAY_FOOTER.

AT LINE-SELECTION.
  PERFORM GET_DESC_DATA.
  PERFORM DISPLAY_DESC_DATA.

TOP-OF-PAGE DURING LINE-SELECTION.
  PERFORM DISPLAY_LIST_HEADER.
FORM VALIDATE_INPUT .
  IF P_MTART IS INITIAL.
    MESSAGE 'Please enter input' TYPE 'E'.
  ENDIF.
ENDFORM.                    " VALIDATE_INPUT

FORM GET_MATERIAL_DATA .
  SELECT * FROM MARA
    INTO TABLE IT_MARA
    UP TO 50 ROWS
    WHERE MTART = P_MTART .
ENDFORM.                    " GET_MATERIAL_DATA
FORM DISPLAY_MATERIALS .
  LOOP AT IT_MARA INTO WA_MARA.
    WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MBRSH.
    HIDE WA_MARA. "store line details in HIDE area
  ENDLOOP.
ENDFORM.                    " DISPLAY_MATERIALS
FORM DISPLAY_HEADER .
  WRITE : 'Material Basic Details' COLOR 5.
ENDFORM.                    " DISPLAY_HEADER

FORM DISPLAY_FOOTER .
  WRITE: 'Report Generated at:', SY-DATUM COLOR 1.
ENDFORM.                    " DISPLAY_FOOTER
FORM GET_DESC_DATA .
  SELECT * FROM MAKT
    INTO TABLE IT_MAKT
    WHERE MATNR = WA_MARA-MATNR.
ENDFORM.                    " GET_DESC_DATA
FORM DISPLAY_DESC_DATA .
  LOOP AT IT_MAKT INTO WA_MAKT.
    WRITE :/ WA_MAKT-MATNR, WA_MAKT-MAKTX.
  ENDLOOP.
ENDFORM.                    " DISPLAY_DESC_DATA

FORM DISPLAY_LIST_HEADER .
  WRITE: 'Descriptions for material:', WA_MARA-MATNR COLOR 6.
ENDFORM.                    " DISPLAY_LIST_HEADER

Unit Testing

To test the above report go to MARA table(SE11-MARA-DISPLAY-CONTENETS), get a material type ex: FERT, HALB etc, execute the report, provide material type and execute. The list of materials will be displayed, double click on any record, the corresponding material descriptions will be displayed in secondary list.

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 32 People out of 33 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Chapter →