Site icon DataFlair

SAP ABAP Dialog Programming | SAP ABAP Report Programming

SAP ABAP Report and Dialog Programming

FREE Online Courses: Knowledge Awaits – Click for Free Access!

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?

Use of SAP ABAP Report Programs

What are Events in SAP ABAP?

EVENT DEFINITION
INITIALIZATION This event is triggered at the starting point before the program displays the selection screen
AT SELECTION-SCREEN This event is triggered on user input – it processed user input to perform actions
START-OF-SELECTION This event is triggered when the user selects ‘execution’ option i.e. when we want to exit the selection screen
END-OF-SELECTION This event is triggered when we execute the last line of the START-OF-SELECTION statement
TOP-OF-PAGE This event is triggered on the first WRITE statement at the top of the page
END-OF-PAGE This 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

What is Dialog Programming in SAP ABAP?

Components of SAP ABAP Dialog Programming

1. T-code

2. Screens

3. GUI Status

4. ABAP Program

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

7. Module Pool

8. Toolset

TOOL COMPONENT TRANSACTION
Object Browser All SE80
Screen Painter Screen SE51
ABAP/4 Editor ABAP/4 Module Pool SE38
Menu Painter Menu SE41
Maintain Transaction Transaction (txn) SE93
ABAP/4 Dictionary Dictionary object SE11

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’

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

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 PROGRAM DIALOG PROGRAM
The relationship between report and database is only one-way The relationship between dialog and database is two ways
The report reads and analyses the data Dialog works interactively with screen
Report does not change the content of the database Dialog 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.

Exit mobile version