SAP ABAP Dialog Programming | SAP ABAP Report Programming

FREE Online Courses: Transform Your Career – Enroll for Free!

In this tutorial, we’ll be learning about two elements of SAP ABAP report programming and dialog programming. They are fundamental features in ABAP selection screens, and we will learn how they are used and why.

What is a Report and Report Programming in SAP?

  • SAP ABAP supports the creation of ‘reports’
  • A report is a structure that presents data in an orderly manner
  • Creating reports means we can write a report in SAP ABAP
  • A report usually uses the WRITE statement within an iteration i.e. a loop
  • We also have pre-defined reports that we can use, that are triggered based on user input

Use of SAP ABAP Report Programs

  • Reports are used when we have to select sections of data from one or more tables
  • Report programs are used when we need reports of a special format
  • They are also used when we need to send the report to someone via email
  • Report programs can be used when we need to download the report from SAP and send it across for distribution

What are Events in SAP ABAP?

EVENTDEFINITION
INITIALIZATIONThis event is triggered at the starting point before the program displays the selection screen
AT SELECTION-SCREENThis event is triggered on user input – it processed user input to perform actions
START-OF-SELECTIONThis event is triggered when the user selects ‘execution’ option i.e. when we want to exit the selection screen
END-OF-SELECTIONThis event is triggered when we execute the last line of the START-OF-SELECTION statement
TOP-OF-PAGEThis event is triggered on the first WRITE statement at the top of the page
END-OF-PAGEThis is the last event, it is triggered when we reach the end of the page

Example of Events in SAP ABAP

REPORT ZR_SS_DATAFLAIR_SAMPLE_001 NO STANDARD PAGE HEADING MESSAGE-ID ZNNR LINE-SIZE 50 LINE-COUNT 75(4).

DATA : BEGIN OF IT_PLANT OCCURS 0,
        MATNR LIKE MARA-MATNR,
        WERKS LIKE MARC-WERKS,
        PSTAT LIKE MARC-PSTAT,
        EKGRP LIKE MARC-EKGRP,
       END OF IT_PLANT.

DATA : BEGIN OF IT_PONO OCCURS 0,
        EBELN LIKE EKKO-EBELN,
        EBELP LIKE EKPO-EBELP,
        MATNR LIKE EKPO-MATNR,
        WERKS LIKE EKPO-WERKS,
        LGORT LIKE EKPO-LGORT,
       END OF IT_PONO.

TABLES EKKO.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS : P_WERKS LIKE MARC-WERKS MODIF ID S1.
SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN NO INTERVALS MODIF ID S2.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.

SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 5(20) TEXT-002 FOR FIELD R1.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : R2 RADIOBUTTON GROUP G1.
SELECTION-SCREEN COMMENT 5(20) TEXT-003 FOR FIELD R2.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK B2.

INITIALIZATION.

P_WERKS = '999'.

S_EBELN-LOW = '6729482600'.
S_EBELN-OPTION = 'EQ'.
S_EBELN-SIGN = 'I'.
APPEND S_EBELN.
CLEAR S_EBELN.

AT SELECTION-SCREEN OUTPUT.

  LOOP AT SCREEN.

    IF R1 EQ 'X' AND SCREEN-GROUP1 EQ 'S2'.
      SCREEN-INPUT = 0.
      MODIFY SCREEN.
    ENDIF.

    IF R2 EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.
      SCREEN-INPUT = 0.
      MODIFY SCREEN.
    ENDIF.

  ENDLOOP.

at selection-screen.
  SELECT SINGLE *
           FROM EKKO
           INTO EKKO
           WHERE EBELN IN S_EBELN.

  IF SY-SUBRC <> 0.
    SET CURSOR FIELD 'S_EBELN-LOW'.
    MESSAGE E999 WITH TEXT-005.
  ENDIF.

START-OF-SELECTION.

  IF R1 EQ 'X'.

    SELECT MATNR
           WERKS
           PSTAT
           EKGRP
       FROM MARC
       INTO TABLE IT_PLANT
       WHERE WERKS = P_WERKS.

    LOOP AT IT_PLANT.


      WRITE : SY-VLINE , 2 IT_PLANT-MATNR COLOR COL_KEY,
             21 SY-VLINE , 22  IT_PLANT-WERKS COLOR COL_KEY,
             27 SY-VLINE ,28 IT_PLANT-PSTAT COLOR COL_NORMAL,
             43 SY-VLINE ,44 IT_PLANT-EKGRP COLOR COL_NORMAL.


    ENDLOOP.

  ENDIF.

  IF R2 EQ 'X'.

    SELECT EBELN EBELP MATNR WERKS LGORT
           FROM EKPO
           INTO TABLE IT_PONO
           WHERE EBELN IN S_EBELN.

    LOOP AT IT_PONO.

      WRITE : SY-VLINE , 2 IT_PONO-EBELN COLOR COL_KEY,
             12 SY-VLINE , 13 IT_PONO-EBELP COLOR COL_KEY,
             18 SY-VLINE , 19 IT_PONO-MATNR COLOR COL_NORMAL,
             37 SY-VLINE , 38 IT_PONO-WERKS COLOR COL_NORMAL,
             44 SY-VLINE , 45 IT_PONO-LGORT COLOR COL_NORMAL, 49 SY-VLINE..
    ENDLOOP.
  ENDIF.

TOP-OF-PAGE.

  IF R1 EQ 'X'.

    WRITE : SY-VLINE ,2 'MATERIAL NUMBER',
            21 SY-VLINE , 22 'PLANT',
            27 SY-VLINE , 28 'STATUS',
            43 SY-VLINE , 44 'GRUP', 48 SY-VLINE.

    ULINE AT /1(48).

  ENDIF.

  IF R2 EQ 'X'.

    WRITE : SY-VLINE , 2 'PO NUMBER',
           12 SY-VLINE, 13 'ITEM',
           18 SY-VLINE,19 'MATERIAL NUMBER',
           37 SY-VLINE, 38 'PLANT',
           44 SY-VLINE, 45 'GRUP',
           49 SY-VLINE.
    ULINE AT /1(50).
  ENDIF.

END-OF-PAGE.

Output

SAP ABAP Report Programming

What is Dialog Programming in SAP ABAP?

  • Dialog programming contains objects that are linked to the main program
  • ABAP links these objects to each other in a hierarchical manner and executes them sequentially
  • The ABAP workbench contains tools to develop dialogs in programming
  • The main constituents of dialog programs are as follows – 
    1. Screens: These are the various windows we see in a program
    2. Menus: These are elements that provide options for navigation or selection
    3. Module pools: They are modularization techniques having a collection of screens, flow logic, menu bars
    4. Subroutines: These are modularisation techniques that comprise chunks of code that we can reuse
    5. Transactions: These are actions performed to and from a source

Components of SAP ABAP Dialog Programming

1. T-code

  • T-codes are transaction codes
  • The repository browser creates t-code and stores them in ABAP workbench
  • We can also use t-code SE93 to create them
  • The transaction codes help with the initialisation of screens or programs in ABAP

2. Screens

  • All programs in ABAP are made up of screens that are related or connected to each other in some way
  • We can create a screen using t-code SE51
  • We can also use Screen Painter from ABAP Workbench to create screens
  • The layout or design of screen determines where the input/output and other elements are placed on the screen and how it will appear to the user
  • The screen also decides the logic and steps to follow for processing

3. GUI Status

  • GUI stands for Graphical User Interface, the display that we see on screen
  • The GUI status controls the various toolbars available – menu, standard, application, etc.
  • We can create GUI status using the Menu Painter from ABAP Workbench

4. ABAP Program

  • The ABAP program contains dialog modules
  • It basically links the screen, GUI status, screen flow logic, etc. into one integrated unit
  • The dialog modules process user input and thus help the GUI status with its function as well

5. Screen Flow Logic

The screen flow logic consists of several events, which are as follows:

a. Process Before Output (PBO): Here the event we have is processed before the program displays the screen

b. Process After Input (PAI): where the event we have is processed after the user performs some action on the screen

c. Process On Help request (POH): where the event we have is processed after user presses key ‘F1’

d. Process On Value request (POV): where the event we have is processed after user presses key ‘F4’

6. Dynpro

  • A Web Dynpro is a dynamic program
  • It combines the flow logic with the screen
  • It is part of dialog program execution

7. Module Pool

  • A module pool is a pool or group of all above components
  • It also includes the dialog programs
  • Module pool is what ties up the loose ends and brings the dialog programming together

8. Toolset

  • We must link all objects in dialog programming to the main program
  • This will make navigation easier, and moving from one object to another seamless
  • Here are the components with the tools and transactions they need –
TOOLCOMPONENTTRANSACTION
Object BrowserAllSE80
Screen PainterScreenSE51
ABAP/4 EditorABAP/4 Module PoolSE38
Menu PainterMenuSE41
Maintain TransactionTransaction (txn)SE93
ABAP/4 DictionaryDictionary objectSE11

Creating & Executing Dialog Programs in ABAP

Technology is evolving rapidly!
Stay updated with DataFlair on WhatsApp!!

1. Go to SAP system

2. Choose transaction code SE80

3. Click on ‘Program’ from the dropdown menu

4. Input name for the program – e.g. ‘ZDATAFLAIR_SCREEN’

5. Select from popup, option ‘With TOP INCL’

Dialog Programming in ABAP

6. Select the ‘Yes’ button

7. Input a name for the top and check the radio button

8. Enter a title and click on ‘Save’

9. Add a screen by going to Create → Screen

SAP ABAP Dialog Programming

10. Enter name for the screen and a title for the attribute → Hit ‘Save’ again

11. Input a screen number e.g. ‘0211’ and move ahead

12. In the Text screen, add text e.g. ‘Hello World’

13. Hit ‘Save’ and activate screen (Ctrl+F2, Ctrl+F3)

Difference between Report and Dialog Programming in SAP ABAP

REPORT PROGRAMDIALOG PROGRAM
The relationship between report and database is only one-wayThe relationship between dialog and database is two ways
The report reads and analyses the dataDialog works interactively with screen
Report does not change the content of the databaseDialog programs can change the contents of the database

Summary

Thus, in this tutorial, we learnt about SAP ABAP report and dialog programming. They are additional features that form ABAP language’s base, and can be used within selection screens and other elements for user input and reading from the database.

We work very hard to provide you quality material
Could you take 15 seconds and share your happy experience on Google

follow dataflair on YouTube

1 Response

  1. tharan says:

    well .., ‘thank you’

Leave a Reply

Your email address will not be published. Required fields are marked *