How to create Interactive Report in SAP ABAP

Interactive Reports
As the name suggests, the user can Interact with the report. We can have a drill down into the report data. For example, Column one of the report displays the material numbers, and the user feels that he needs some more specific data about the vendor for that material, he can HIDE that data under those material numbers.
And when the user clicks the material number, another report (actually sub report/secondary list) which displays the vendor details will be displayed.
We can have a basic list (number starts from 0) and 20 secondary lists (1 to 21).
Events associated with Interactive Reports are:
AT LINE-SELECTION
AT USER-COMMAND
AT PF<key>
TOP-OF-PAGE DURING LINE-SELECTION.
HIDE statement holds the data to be displayed in the secondary list.
sy-lisel : contains data of the selected line.
sy-lsind : contains the level of report (from 0 to 21)
Interactive Report Events:
AT LINE-SELECTION : This Event triggers when we double click a line on the list, when the event is triggered a new sublist is going to be generated. Under this event what ever the statements that are been return will be displayed on newly generated sublist.
AT PFn: For predefined function keys...
AT USER-COMMAND : It provides user functions keys.
TOP-OF-PAGE DURING LINE-SELECTION :top of page event for secondary list.

Interactive Reports Events
At Line-Selection

This event will trigger whenever the user double click on any list line.

Syntax: AT LINE-SELECTION . "Triggers line selection
At User Command

This event will trigger whenever user clicks on any custom buttons of the GUI.

Syntax: AT USER-COMMAND . "Triggers user command
At PF Status

This event will trigger whenever user clicks on any function buttons.

Syntax: AT PF <function key> . "Triggers user command
Top Of Page During line selection

This is used to print heading for secondary lists in interactive reports.

Syntax: TOP-OF-PAGE DURING LINE-SELECTION . "Prints secondary list header
Techniques used in interactive reporting
Hide area

It is a key word which is used to store the data into a temporary memory call as HIDE area.

Functionality of HIDE is

Whenever the user uses the HIDE statement, the data will be stored in 'HIDE' area along with line numbers.
Whenever user double clicks on any list line the system takes the line number and checks the HIDE area for the corresponding data in that particular line, then the data will be returned to the HIDE variables.
Syntax: HIDE <WA>. "store total work area in hide area
         OR
        HIDE <WA-FIELD>. "store work area field in hide area
GET CURSOR

This key word is used to read the field name and field value where the mouse cursor is placed or double click action is raised. It dosen`t use hide area.

Syntax : GET CURSOR FIELD <V_FIELDNAME>,
                    FIELDVALUE <V_FIELDVALUE>.

Creating Interactive Report in SAP ABAP

*&---------------------------------------------------------------------*
*& Report  ZDEMO_PROGRAM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZDEMO_PROGRAM.
*report program started



*TABLES DECLARATION

TABLES kna1vbakvbap.

*SELECT OPTIONS

SELECT-OPTIONScust_no FOR kna1-kunnr.


*INITIALIZATION

INITIALIZATION.

  cust_no-low '01'.
  cust_no-high '4000'.
  cust_no-sign 'I'.
  cust_no-option 'BT'.
  APPEND cust_no.


*SELECTION SCREEN VALIDATION

AT SELECTION-SCREEN ON cust_no.

  LOOP AT SCREEN.
    IF cust_no-low < OR cust_no-high > 5000.
      MESSAGE e001(ztj1).
    ENDIF.
  ENDLOOP.


*BASIC LIST SELECTION

START-OF-SELECTION.

  SELECT kunnr name1 ort01 land1 INTO
         (kna1-kunnrkna1-name1,kna1-ort01,kna1-land1)
         FROM kna1
         WHERE kunnr IN cust_no.

    WRITE:/1 sy-vline,
          kna1-kunnr UNDER 'CUSTOMER NO.' HOTSPOT ON,
          16 sy-vline,
          kna1-name1 UNDER 'NAME',
          61 sy-vline,
          kna1-ort01 UNDER 'CITY',
          86 sy-vline,
          kna1-land1 UNDER 'COUNTRY',
          103 sy-vline.

    HIDEkna1-kunnr.

  ENDSELECT.

  ULINE.

*SECONDARY LIST ACCESS

AT LINE-SELECTION.

  IF sy-lsind 1.
    PERFORM sales_ord.
  ENDIF.
  IF sy-lsind 2.
    PERFORM item_det.
  ENDIF.


*TOP OF PAGE

TOP-OF-PAGE.

  FORMAT COLOR 1.

  WRITE 'CUSTOMER DETAILS'.

  FORMAT COLOR OFF.


  ULINE.

  FORMAT COLOR 3.

  WRITE sy-vline,
          'CUSTOMER NO.',
          16 sy-vline,
          18 'NAME',
          61 sy-vline,
          63 'CITY',
          86 sy-vline,
          88 'COUNTRY',
          103 sy-vline.

  ULINE.

  FORMAT COLOR OFF.


*TOP OF PAGE FOR SECONDARY LISTS

TOP-OF-PAGE DURING LINE-SELECTION.

*TOP OF PAGE FOR 1ST SECONDARY LIST

  IF sy-lsind 1.

    ULINE.

    FORMAT COLOR 1.

    WRITE 'SALES ORDER DETAILS'.
    ULINE.
    FORMAT COLOR OFF.


    FORMAT COLOR 3.

    WRITE sy-vline,
            'CUSTOMER NO.',
            16 sy-vline,
            18 'SALES ORDER NO.',
            40 sy-vline,
            42 'DATE',
            60 sy-vline,
            62 'CREATOR',
            85 sy-vline,
            87 'DOC DATE',
            103 sy-vline.
    ULINE.

  ENDIF.

  FORMAT COLOR OFF.

*TOP OF PAGE FOR 2ND SECONDARY LIST

  IF sy-lsind 2.

    ULINE.

    FORMAT COLOR 1.

    WRITE 'ITEM DETAILS'.

    ULINE.

    FORMAT COLOR OFF.

    FORMAT COLOR 3.

    WRITE sy-vline,
            3  'SALES ORDER NO.',
            40 sy-vline,
            42 'SALES ITEM NO.',
            60 sy-vline,
            62 'ORDER QUANTITY',
            103 sy-vline.
    ULINE.

  ENDIF.

  FORMAT COLOR OFF.

*END OF PAGE

END-OF-PAGE.

  ULINE.
  WRITE :'USER :',sy-uname,/,'DATE :'sy-datum85 'END OF PAGE:',
  sy-pagno.
  SKIP.


*&---------------------------------------------------------------------*
*&      Form  SALES_ORD
*&
*&      FIRST SECONDARY LIST FORM
*&---------------------------------------------------------------------*

FORM sales_ord .

  SELECT kunnr vbeln erdat ernam audat INTO
         (vbak-kunnrvbak-vbelnvbak-erdatvbak-ernamvbak-audat)
         FROM vbak
         WHERE kunnr kna1-kunnr.

    WRITE:/1 sy-vline,
            vbak-kunnr UNDER 'CUSTOMER NO.' HOTSPOT ON,
            16 sy-vline,
            vbak-vbeln UNDER 'SALES ORDER NO.' HOTSPOT ON,
            40 sy-vline,
            vbak-erdat UNDER 'DATE',
            60 sy-vline,
            vbak-ernam UNDER 'CREATOR',
            85 sy-vline,
            vbak-audat UNDER 'DOC DATE',
            103 sy-vline.
    HIDE vbak-vbeln.
  ENDSELECT.

  ULINE.


ENDFORM.                    " SALES_ORD
*&---------------------------------------------------------------------*
*&      Form  ITEM_DET
*&
*&      SECOND SECONDARY LIST FORM
*&---------------------------------------------------------------------*
FORM item_det .

  SELECT vbeln posnr kwmeng INTO
         (vbap-vbelnvbap-posnrvbap-kwmeng)
         FROM vbap
         WHERE vbeln vbak-vbeln.

    WRITE /1 sy-vline,
              vbap-vbeln UNDER 'SALES ORDER NO.',
              40 sy-vline,
              vbap-posnr UNDER 'SALES ITEM NO.',
              60 sy-vline,
              vbap-kwmeng UNDER 'ORDER QUANTITY',
              103 sy-vline.

  ENDSELECT.

  ULINE.
ENDFORM.                    " ITEM_DET

Input Selection screen
How to create Interactive Report in SAP ABAP
Primary Output:
How to create Interactive Report in SAP ABAP
Secondary list output:
How to create Interactive Report in SAP ABAP




Popular posts from this blog

How to create ALV Interactive Report in SAP ABAP

BDC Call Transaction Method Program