Interactive Reports

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 13

Interactive Reports

Displaying the basic information in the basic list (First list) and detailed information on
the secondary list are called interactive Reports.

** There 21 list are available


- The first list is called BASIC LIST (list no = 0)
- The remaining lists are called secondary list (list no = 1, 2, 3, 4, 5, 6… 20).

SY-LSIND
- List index
- It is a system variable which stores the list no.

Interactive Report Events

1. AT LINE-SELECTION.
This Event is triggered when ever the user double clicks on any list line.
2. AT USER-COMMAND.
This event is triggered when ever user clicks on custom GUI Buttons.
3. AT PF. (obsolete)
This event is triggered when ever the user hits the function key.
4. TOP-OF-PAGE.    
To generate the page heading only for the basic list (First List)
5. TOP-OF-PAGE DURING LINE-SELECTION.  
To generate the constant page heading for all the secondary list
Example how to use these

REPORT  ZIINTERACTIVE_REPORT NO STANDARD PAGE HEADING.

WRITE : /  'Please click here for next screen', sy-lsind COLOR 4 INVERS
E.

AT LINE-SELECTION.
  WRITE :/ 'you are clicked', sy-lsind COLOR 5 INVERSE.

TOP-OF-PAGE.  
  WRITE : /35 'Interactive Reports' COLOR 4 INVERSE.
  SKIP.
  SKIP.

TOP-OF-PAGE DURING LINE-SELECTION. 
  WRITE : /10 'Interactive report secorndary list heading'.

Finding Selected line contents


There are 3 techniques to find the line contents on which field the user has raised the
double click events.

1. SY-LISEL (Line Selection)


2. Hide
3. Get cursor
Off set functionality
This functionality is used to read a single character or group of characters from a source
variable in to target variable

Target variable = Source variable + starting position (Width)

Example Program on SY-LISEL

REPORT  ZIINTERACTIVE_REPORT NO STANDARD PAGE HEADING.

DATA : i_mara TYPE TABLE OF mara.
DATA : wa_mara TYPE mara.
DATA : i_mAKT TYPE TABLE OF maKT.
DATA : wa_maKT TYPE maKT.

DATA : V_MATNR TYPE MARA-MATNR.

SELECT * FROM mara
   into TABLE i_mara
   UP TO 10 ROWS.

LOOP AT  i_mara INTO wa_mara.

  WRITE :  / wa_mara-matnr,
             wa_mara-mtart,
             wa_mara-meins.

ENDLOOP.
at LINE-SELECTION.
    SY-LSIND = 1.
  V_MATNR = SY-LISEL+0(18).

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      INPUT = V_MATNR
    IMPORTING
      OUTPUT = V_MATNR.

  SELECT * FROM MAKT
        INTO TABLE I_MAKT
        WHERE MATNR = V_MATNR.

  LOOP AT I_MAKT INTO WA_MAKT.
    WRITE : / WA_MAKT-MATNR,
              WA_MAKT-SPRAS,
              WA_MAKT-MAKTX.

  ENDLOOP.

TOP-OF-PAGE.
  WRITE  : /35 'Material Details DELL', SY-LSIND.
  SKIP.
  SKIP.

TOP-OF-PAGE DURING LINE-SELECTION.
  WRITE  : /35 'DELL MATERIALS', SY-LSIND.
  SKIP.
  SKIP.
  SKIP.
Business Requirement

1. Develop a SALE order Report which displays header details in the basic list and
item details in the secondary List

Header Table Details: VBELN, VKORG, VTWEG, SPART


Item Details are : VBELN, POSNR, MATNR, and NETWR
Interactive Reports Using HIDE Statement

HIDE
It is a key word which is used to store a variable or work area in to a temporary
memory is called as HIDE AREA.

HIDE AREA
It is a temporary memory

Functionalities of HIDE
When ever we are displaying the data in the output, we need to store a copy of the
output into HIDE AREA memory using the below syntax

Syntax
Loop at I_kna1 into wa_kna1.
Write: wa_kna1-kunnr, wa_kna1-name1….
HIDE wa_kna1-kunnr.  A copy of output is stored in HIDE AREA
Endloop.

** When ever the user double clicks on any LISTLINE the system will take the
selected line and it check whether the selected line is available in HIDE AREA.

- If the line is available, the data is retrieved from hide area and it is stored
back in to the HIDE variable.
- Using this hide variable we can generate the interactive reports
Example program

DATA  : i_mara TYPE TABLE OF mara.
DATA  : wa_mara TYPE mara.
data  : i_makt TYPE TABLE OF makt.
DATA  : wa_makt TYPE makt.
data  : i_marc TYPE TABLE OF marc.
DATA  : wa_marc TYPE marc.

SELECT * FROM mara
          INTO TABLE i_mara
        UP TO 100 ROWS.

WRITE : /50 'The scree No is:' , SY-lsind.
LOOP AT  i_mara INTO wa_mara.

  WRITE : / wa_mara-matnr,
            wa_mara-mtart,
            wa_mara-meins.

  HIDE : wa_mara-matnr.

ENDLOOP.

at LINE-SELECTION.
  if sy-lsind  = 1.

    SELECT * FROM makt
          INTO TABLE i_makt
          WHERE matnr = wa_mara-matnr.

    WRITE : /50 'The scree No is:' , SY-lsind.
    LOOP AT i_makt INTO wa_makt.

      WRITE : / wa_makt-matnr,
                wa_makt-spras,
                wa_makt-maktx.
    ENDLOOP.

  ELSEIF sy-lsind = 2.
    SELECT * FROM marc
           INTO TABLE i_marc
           WHERE matnr = wa_mara-matnr.

    WRITE : /50 'The scree No is:' , SY-lsind.
    LOOP AT i_marc INTO wa_marc.

      WRITE  : / wa_marc-matnr,
                 wa_marc-werks,
                 wa_marc-mmsta.

    ENDLOOP.

    ELSEIF sy-lsind = 3.
        sy-lsind  = 2.
  endif.

Business Requirement

Develop a sale order report which displays sale order header details in the basic list and
item details in the secondary list.

- Display the material details also once the user double clicks on material
numbers on the secondary list1.

TABLES: vbak, vbap, mara.


Get cursor

This statement is used to read the details of field name and field value on which the
double click event is raised.

Get cursor is mainly used to generate various secondary list’s depends on selected
fields.

Syntax
Get cursor field <FIELD NAME>
Value <FIELD VALUE>.

REPORT  ZGETCURSOR NO STANDARD PAGE HEADING.

DATA  : i_mara TYPE TABLE OF mara.
DATA  : i_makt TYPE TABLE OF makt.
DATA  : I_MARA1 TYPE TABLE OF MARA.
DATA  : WA_MARA1 TYPE MARA.
DATA  : wa_mara TYPE mara.
DATA  : wa_makt TYPE makt.
DATA  : I_T134 TYPE TABLE OF T134.
DATA  : WA_T134 TYPE T134.
DATA  : v_fname(15) TYPE c.
DATA  : v_fval  TYPE mara-matnr.

SELECT * FROM mara
        into TABLE i_mara.
**        UP TO 50 ROWS.

WRITE :/60 'The Screen No is: ', sy-lsind.

LOOP AT i_mara INTO wa_mara.

  WRITE : / wa_mara-matnr,
            wa_mara-mtart,
            wa_mara-meins.

ENDLOOP.

at LINE-SELECTION.
  sy-lsind = 1.
  GET CURSOR FIELD v_fname
             VALUE v_fval.

  IF v_fname  = 'WA_MARA-MATNR'.

    SELECT * FROM makt
            INTO TABLE i_makt
            WHERE matnr = v_fval.

    LOOP AT i_makt INTO wa_makt.
      WRITE : / wa_makt-matnr,
                wa_makt-spras,
                wa_makt-maktx.

    ENDLOOP.

    ELSEIF   V_FNAME  = 'WA_MARA-MTART'.

      SELECT * FROM MARA
            INTO TABLE I_MARA1
            WHERE MTART = V_FVAL.

        LOOP AT I_MARA1 INTO WA_MARA1.

          WRITE : / WA_MARA1-MTART.

        ENDLOOP.

      SELECT * FROM T134
            INTO TABLE I_T134
          WHERE MTART = V_FVAL.
        LOOP AT I_T134 INTO WA_T134.

          WRITE : / WA_T134-MTART, WA_T134-MTREF, WA_T134-MBREF.

        ENDLOOP.

  ENDIF.

Menu painter SE41

Creating Custom GUI (Menu Bar)


Example Program

set PF-STATUS 'MENU'.

WRITE : / ' A SAMPLE PROGRAM ON CUSTOM GUI'.

AT USER-COMMAND.

  IF SY-UCOMM = 'SE11'.
    CALL TRANSACTION 'SE11'.

  ELSEIF SY-UCOMM = 'SE38'.
    CALL TRANSACTION 'SE39'.

  ELSEIF SY-UCOMM  = 'XK01'.
    CALL TRANSACTION 'XK01'.

  ELSEIF SY-UCOMM = 'XK03'.
    CALL TRANSACTION  'XK03'.

  ENDIF.
Using Standard Tool Bar (Function key’s)

REPORT  ZMENU_PAINTER NO STANDARD PAGE HEADING.

DATA  : i_mara TYPE TABLE OF mara.
DATA  : i_mara1 TYPE TABLE OF mara.
DATA  : wa_mara  TYPE mara.
DATA  : V_CHKBOX(1) TYPE  C.
DATA  : V_LINES TYPE I.

set PF-STATUS 'MENU'.

SELECT * FROM MARA
        INTO TABLE I_MARA
          UP TO 50 ROWS.

WRITE : /30 ' A SAMPLE PROGRAM ON CUSTOM GUI'.
SKIP.

DESCRIBE TABLE  I_MARA LINES V_LINES.
  PERFORM get_data.

AT USER-COMMAND.

  SY-LSIND  = 0.
  IF SY-UCOMM = 'SALL'.
    V_CHKBOX  = 'X'.
    PERFORM get_data.

  ELSEIF SY-UCOMM = 'DALL'.
    V_CHKBOX  = ' '.
    PERFORM get_data.

  ELSEIF SY-UCOMM = 'DOWN'.

    DO V_LINES TIMES.
      READ LINE SY-INDEX FIELD VALUE V_CHKBOX WA_MARA-MATNR WA_MARA-
MTART WA_MARA-MEINS.

      IF V_CHKBOX = 'X'.

        APPEND WA_MARA TO I_MARA1.

      ENDIF.
    ENDDO.

    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME              = 'C:\Sap abap materials\DLOAD.TXT'
        FILETYPE              = 'ASC'
        WRITE_FIELD_SEPARATOR = 'X'
      TABLES
        DATA_TAB              = I_MARA1.
  ENDIF.

FORM get_data .

 LOOP AT I_MARA INTO WA_MARA.
      WRITE : /15 V_CHKBOX AS CHECKBOX,   WA_MARA-MATNR,
                                          WA_MARA-MTART,
                                          WA_MARA-MEINS.
    ENDLOOP.

ENDFORM.                    " get_data

You might also like