Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dialog programming ..

Former Member
0 Likes
1,420

Dear All

Please give me some guidance for

learning Dialog Programming

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,236

Hi,

Structure of a Dialog Program

A dialog program consists of the following basic components:

Screens (dynpros)

Each dialog in an SAP system is controlled by dynpros. A dynpro (DYnamic PROgram) consists of a screen and its flow logic and controls exactly one dialog step. The flow logic determines which processing takes place before displaying the screen (PBO-Process Before Output) and after receiving the entries the user made on the screen (PAI-Process After Input).

The screen layout fixed in the Screen Painter determines the positions of input/output fields, text fields, and graphical elements such as radio buttons and checkboxes. In addition, the Menu Painter allows to store menus, icons, pushbuttons, and function keys in one or more GUI statuses. Dynpros and GUI statuses refer to the ABAP/4 program that control the sequence of the dynpros and GUI statuses at runtime.

ABAP/4 module pool

Each dynpro refers to exactly one ABAP/4 dialog program. Such a dialog program is also called a module pool, since it consists of interactive modules. The flow logic of a dynpro contains calls of modules from the corresponding module pool. Interactive modules called at the PBO event are used to prepare the screen template in accordance to the context, for example by setting field contents or by suppressing fields from the display that are not needed. Interactive modules called at the PAI event are used to check the user input and to trigger appropriate dialog steps, such as the update task.

All dynpros to be called from within one transaction refer to a common module pool. The dynpros of a module pool are numbered. By default, the system stores for each dynpro the dynpro to be displayed next. This dynpro sequence or chain can be linear as well as cyclic. From within a dynpro chain, you can even call another dynpro chain and, after processing it, return to the original chain.

Check this link for basics.

http://sap.mis.cmich.edu/sap-abap/abap09/index.htm

Check this link for Dialog Programming/Table Control

http://www.planetsap.com/Tips_and_Tricks.htm#dialog

Check this SAP Help for Dialog Program doc.

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/content.htm

Check this SAP Help link for Subscreens.

http://help.sap.com/saphelp_nw70/helpdata/en/9f/dbabfe35c111d1829f0000e829fbfe/content.htm

Check this link for subscreen demo program.

http://abapcode.blogspot.com/2007/05/demo-program-to-create-subscreen-in.html

Also check this link too.

http://abapcode.blogspot.com/2007/06/dialog-programming-faq.html

6 REPLIES 6
Read only

Former Member
0 Likes
1,236

hi,

Download the PDF its good for learning dialog programming.

http://www.esnips.com/doc/a609d3bc-725f-4cfd-a13c-cff9fd38adbe/5-Developing-User-Dialogs(P436)

Hope this helps, Do reward.

Read only

Former Member
0 Likes
1,237

Hi,

Structure of a Dialog Program

A dialog program consists of the following basic components:

Screens (dynpros)

Each dialog in an SAP system is controlled by dynpros. A dynpro (DYnamic PROgram) consists of a screen and its flow logic and controls exactly one dialog step. The flow logic determines which processing takes place before displaying the screen (PBO-Process Before Output) and after receiving the entries the user made on the screen (PAI-Process After Input).

The screen layout fixed in the Screen Painter determines the positions of input/output fields, text fields, and graphical elements such as radio buttons and checkboxes. In addition, the Menu Painter allows to store menus, icons, pushbuttons, and function keys in one or more GUI statuses. Dynpros and GUI statuses refer to the ABAP/4 program that control the sequence of the dynpros and GUI statuses at runtime.

ABAP/4 module pool

Each dynpro refers to exactly one ABAP/4 dialog program. Such a dialog program is also called a module pool, since it consists of interactive modules. The flow logic of a dynpro contains calls of modules from the corresponding module pool. Interactive modules called at the PBO event are used to prepare the screen template in accordance to the context, for example by setting field contents or by suppressing fields from the display that are not needed. Interactive modules called at the PAI event are used to check the user input and to trigger appropriate dialog steps, such as the update task.

All dynpros to be called from within one transaction refer to a common module pool. The dynpros of a module pool are numbered. By default, the system stores for each dynpro the dynpro to be displayed next. This dynpro sequence or chain can be linear as well as cyclic. From within a dynpro chain, you can even call another dynpro chain and, after processing it, return to the original chain.

Check this link for basics.

http://sap.mis.cmich.edu/sap-abap/abap09/index.htm

Check this link for Dialog Programming/Table Control

http://www.planetsap.com/Tips_and_Tricks.htm#dialog

Check this SAP Help for Dialog Program doc.

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/content.htm

Check this SAP Help link for Subscreens.

http://help.sap.com/saphelp_nw70/helpdata/en/9f/dbabfe35c111d1829f0000e829fbfe/content.htm

Check this link for subscreen demo program.

http://abapcode.blogspot.com/2007/05/demo-program-to-create-subscreen-in.html

Also check this link too.

http://abapcode.blogspot.com/2007/06/dialog-programming-faq.html

Read only

Former Member
0 Likes
1,236
Read only

Former Member
0 Likes
1,236
Read only

Former Member
0 Likes
1,236

Hi,

MODULE POOL PROGRAMMING (MPP):

-


  • These are type M programs in SAP.

  • These programs cannot be executed directly.

  • Transaction Codes (Tcodes) are used to execute MPP programs.

  • Graphical Screen PAinter is the tool used to create GUI in MPP (SE51).

  • MPP programs are created using the transaction code SE80.

  • MPP programs should start with the naming convention SAPMZ or SAPMY.

EVENTS ASSOCIATED WITH SELECTION-SCREEN:

-


INITIALIZATION

AT SELECTION-SCREEN

START-OF-SELECTION

TOP-OF-PAGE

END-OF-PAGE

END-OF-SELECTION.

EVENTS ASSOCIATED WITH MPP:

-


1. PROCESS BEFORE OUTPUT (PBO) - Used to specify initial attributes for the screen.

2. PROCESS AFTER INPUT (PAI) - Used to specify

event functionalities for the components of the screen.

COMPONENTS OF MPP PROGRAM:

-


1. ATTRIBUTES - It holds description about the screen.

2. FLOW LOGIC - This is an editor for MPP programs to specify event functionality for the screen components.

3. ELEMENT LIST - This provides description about the components created in the screen.

TYPES OF SCREEN IN MPP:

-


1. NORMAL SCREEN - A screen which has maximizing, minimizing and closing options

is referred to as normal screen.

2. SUBSCREEN - A screen within a normal screen with either of above three options

is referred to as subscreen.

3. MODAL DIALOG BOX - A screen with only closing option which is used to provide

information to the end user is referred to as modal dialog box.

NAVIGATIONS TO CREATE A SIMPLE MPP PROGRAM:

-


SE80 -> Select Program from the dropdown list -> SPecify program name starting with SAPMZ or SAPMY (eg. SAPMYFIRSTMPP) -> Press Enter -> Click on Yes to Create object -> Opens another dialog box -> Click on Continue to create Top Include File for the program -> Opens another dialog box specifying TOP INCLUDE FILE name (MYFIRSTMPPTOP) -> Click on Continue -> Opens Program Attributes screen -> Enter short description -> The default program type is M -> Save under a package -> Assign Request number -> A folder with specified program name(SAPMYFIRSTMPP) is created with Top Include File.

To create a screen, right click on program name -> Create -> SCreen -> Opens dialog box

-> Specify Screen number (100) -> Continue -> Opens an interface -> Enter short description

-> Select Screen type as Normal -> Click on LAYOUT pushbutton from appn. toolbar

-> Opens Graphical Screen painter -> Drag and drop two input fields, two pushbuttons and

two text fields -> Double click on each component to specify attributes as follows:

INPUT FIELDS: IO1, IO2

FIRST PUSHBUTTON : PB1, PRINT, PRINT

SECOND PUSHBUTTON : PB2, EXIT, EXIT

TEXT FIELDS : LB1 (ENTER NAME), LB2 (ENTER CITY)

-> Save -> Click on Flowlogic Pushbutton from appn. toolbar -> Opens Flow Logic editor

with two events (PA1 and PBO).

To specify event functionalities for screen components,

decomment PAI Module name (USER_COMMAND_0100)

-> Double click on module name -> Click on Yes to create object -> Opens an interface

-> Select Program name from the list -> Continue -> Click on Yes to save the editor

-> Opens PAI module and specify following code:

CASE SY-UCOMM.

WHEN 'PRINT'.

LEAVE TO LIST-PROCESSING.

WRITE 😕 IO1, IO2.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

In TOP INCLUDE FILE, declare input fields as follows:

DATA : IO1(20), IO2(20).

Save -> Activate -> Right click on Program name -> Activate (to activate all inactive objects).

To execute MPP program, right click on program name -> Create -> Transaction

-> Opens an interface -> Specify Tcode starting with Z or Y (zfirstmpp) -> Enter short description -> Continue -> Specify Main program name (SAPMYFIRSTMPP) and initial Screen number (100) -> Save under a package -> Assign a request number -> Execute.

TOP INCLUDE FILE is an area to declare variables for the program, and the variables declared here becomes globally accessed.

SCREEN VALIDATION USING MPP:

-


SCREEN is a predefined structure used to make MPP screen validations dynamically. SCREEN has following components:

GROUP1

INVISIBLE

REQUIRED

INPUT

OUTPUT

INTENSIFIED

IF SCREEN-INVISIBLE = 0 - Sets the input field values as visible.

SCREEN-INVISIBLE = 1 - Sets the input field as password field.

SCREEN-REQUIRED = 0 - Not a mandatory field.

SCREEN-REQUIRED = 1 - Sets input field as mandatory one.

Eg. code to perform validation dynamically for a login screen:

-


1. Create an MPP program.

2. Create a Normal Screen like initial login screen.

3. Assign IO1, IO2 to group GR1, IO3 to GR2.

4. In Top Include file, declare variables.

5. In PBO, specify following code:

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'GR1'.

SCREEN-REQUIRED = '1'.

ENDIF.

IF SCREEN-GROUP1 = 'GR2'.

SCREEN-INVISIBLE = '1'.

ENDIF.

MODIFY SCREEN. * to update the changes made to the predefined structure.

ENDLOOP.

6. In PAI, specify following code:

CASE SY-UCOMM.

WHEN 'LOGIN'.

CALL TRANSACTION 'SE38'.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

7. Create a Tcode -> Activate all -> Execute.

INSERTING RECORDS FROM MPP SCREEN INTO DATABASE TABLE:

-


1. Create an MPP program.

2. In Top Include File, declare an internal table as follows:

DATA IT_KNA1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.

-> Save -> Activate.

3. Create a screen -> In Screen Painter, click DICTIONARY/PROGRAM FIELDS (F6)

pushbutton from appn. toolbar -> Opens an interface

-> Specify internal table name -> Click on GET FROM PROGRAM pushbutton

-> Select required fields -> Continue -> Paste on Screen Painter

-> Create two pushbuttons (INSERT, EXIT) -> Save -> Flow logic.

4. In PAI, specify following code:

CASE SY-UCOMM.

WHEN 'INSERT'.

INSERT INTO KNA1 VALUES IT_KNA1.

IF SY-SUBRC = 0.

MESSAGE S000(ZMSG).

ELSE.

MESSAGE W001(ZMSG).

ENDIF.

WHEN 'EXIT'.

*LEAVE PROGRAM.

SET SCREEN 0.

ENDCASE.

5. Create a Tcode -> Activate all -> Execute.

LIST OF VALUES:

-


Adding dropdown facility to the input fields is called as LIST OF VALUES.

VRM is a predefined type group which has the following structure and internal table:

VRM_VALUE is a structure with the components KEY and TEXT.

VRM_VALUES is an internal table declared for the above structure without header line.

The above type group is used to fetch values from the internal table declared with user-defined records and insert into the input field in the screen.

'VRM_SET_VALUES' is a function module used to carry the records from the internal table and populate in the input field.

NAVIGATIONS TO CREATE DROPDOWN FACILITY FOR INPUT BOX:

-


1. Create MPP program.

2. Create a screen.

3. Add a input box -> Double click -> Specify name (IO1) -> Select LISTBOX from the dropdown list -> A dropdown facility is added for the input field in the screen.

4. Create two pushbuttons (PRINT, EXIT).

5. In Top Include File, specify following code:

TYPE-POOLS VRM.

DATA IO1(20).

DATA A TYPE I.

DATA ITAB TYPE VRM_VALUES. * To create an internal table of an existing type

DATA WA LIKE LINE OF ITAB. * To create a temporary structure of sameline type of internal table.

6. In PBO, specify following code:

IF A = 0.

WA-KEY = 'ABAP'.

WA-TEXT = 'ADVANCED PROGRAMMING'.

APPEND WA TO ITAB.

WA-KEY = 'BW'.

WA-TEXT = 'BUSINESS WAREHOUSING'.

APPEND WA TO ITAB.

WA-KEY = 'EP'.

WA-TEXT = 'ENTERPRISE PORTAL'.

APPEND WA TO ITAB.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'IO1'

VALUES = ITAB.

A = 1.

ENDIF.

7. In PAI, specify following:

CASE SY-UCOMM.

WHEN 'PRINT'.

LEAVE TO LIST-PROCESSING.

WRITE 😕 IO1.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

8. Create a Tcode -> Activate all -> Execute.

CREATING TABSTRIPS IN MPP:

-


In a normal screen, we can add only maximum of 40 components.

To make a screen hold more than 40 components, we can use tabstrip controls.

NAVIGATIONS TO CREATE TABSTRIP CONTROL:

-


1. Create an MPP program.

2. Create a normal screen (100)

-> Add Tabstrip Control component from toolbar

-> By default, a tabstrip control is created with 2 tab buttons

-> Double click on tabstrip control

-> Specify name (TBSTR) in Attributes box

-> Click on First tab button

-> Add Subscreen Area from toolbar to first tab button

-> Double click on subscreen area

-> Specify name (SUB1)

-> Click on Second tab button

-> Repeat same process for adding subscreen area (SUB2)

-> Double click on First tab button

-> Specify attributes (TAB1,FIRST,TAB1)

-> Double click on Second tab button

-> Specify attributes (TAB2, SECOND, TAB2)

-> SAve

-> Flowlogic.

3. Create two subscreens (10, 20) -> Add required components in each subscreen.

4. In Top Include File, specify following code:

DATA : IO1(10), IO2(10), IO3(10), IO4(10).

CONTROLS TBSTR TYPE TABSTRIP.

DATA A LIKE SY-DYNNR.

'CONTROLS' statement is used to allocate a memory area for the tabstrip created in the normal screen. 'TABSTRIP' itself is a data type for the tabstrip control. Whenever a tabstrip is created, SAP creates an object called 'ACTIVETAB' which is used to call the corresponding subscreens for each tab button in PAI.

5. In Flowlogic editor, write following code to initiate the subscreens to the corresponding subscreen areas of each tab button when the main screen is called:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

CALL SUBSCREEN SUB1 INCLUDING 'SAPMZTABSTRIP' '10'.

CALL SUBSCREEN SUB2 INCLUDING 'SAPMZTABSTRIP' '20'.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.

CALL SUBSCREEN SUB1.

CALL SUBSCREEN SUB2.

6. In PAI, specify following code for click events on each tab button:

CASE SY-UCOMM.

WHEN 'TAB1'.

A = '10'. * calls specified subscreen during PAI

TBSTR-ACTIVETAB = 'TAB1'. * makes entire tab button in active status

WHEN 'TAB2'.

A = '20'.

TBSTR-ACTIVETAB = 'TAB2'.

WHEN 'DISPLAY'.

LEAVE TO LIST-PROCESSING.

WRITE 😕 IO1, IO2, IO3, IO4.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

7. Create a Tcode -> Activate all -> Execute.

TABLE CONTROLS:

-


Table Control component is used to view the internal table contents in the screen.

Navigations to create Table control component:

-


1. Create an MPP program.

2. In Top include File, declare variables as follows:

DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.

DATA ITAB1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.

CONTROLS TBCL TYPE TABLEVIEW USING SCREEN 100.

DATA CUR TYPE I VALUE 5.

-> Save -> Activate.

3. Create a Screen (100) -> Select Table control component from toolbar -> Double Click and specify name (TBCL) -> Press F6 and specify internal table name (ITAB) -> Select required fields -> Paste on the Table control -> To separate the fields, use Separators option in Table control Attributes -> Specify labels if necessary -> Create pushbuttons (FETCH, MODIFY, PRINT, EXIT) -> Save -> Flowlogic.

4. In PAI module, specify following code:

CASE SY-UCOMM.

WHEN 'FETCH'.

SELECT * FROM KNA1 INTO TABLE ITAB.

TBCL-LINES = SY-DBCNT. * To create Vertical Scrollbar

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'PRINT'.

GET CURSOR LINE CUR.

READ TABLE ITAB INDEX CUR.

LEAVE TO LIST-PROCESSING.

WRITE 😕 ITAB-KUNNR, ITAB-NAME1, ITAB-ORT01, ITAB-LAND1.

WHEN 'MODIFY'.

LOOP AT ITAB1.

MODIFY KNA1 FROM ITAB1.

IF SY-SUBRC = 0.

MESSAGE S002(ZMSG).

ELSE.

MESSAGE E003(ZMSG).

ENDIF.

ENDLOOP.

SELECT * FROM KNA1 INTO TABLE ITAB.

TBCL-LINES = SY-DBCNT.

ENDCASE.

5. In FlowLogic editor, specify following step loops:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

LOOP AT ITAB CURSOR CUR WITH CONTROL TBCL.

ENDLOOP.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.

LOOP AT ITAB.

MODULE NEW. * New module to move records from ITAB to ITAB1. Double click on Module Name (New) to create a new one.

ENDLOOP.

6. Specify following code in the NEW module:

MODULE NEW INPUT.

APPEND ITAB TO ITAB1.

ENDMODULE.

7. Create a Tcode -> Activate all -> Execute.

USING TABLE CONTROL WIZARD:

-


This is a predefined SAP-specific component to create table control using predefined navigations.

1. Create an executable program (Z_TABLEWIZARD) in SE38 editor. Write the following code:

CALL SCREEN 200.

-> Save -> Activate.

2. Goto SE51 -> Specify program name created earlier (Z_TABLEWIZARD) -> Specify Screen number (200) -> Layout -> Select Table Control (Wizard) component from toolbar -> Opens Table control Wizard -> Follow the navigations -> Save and Activate the table control.

3. Execute the program (Z_TABLEWIZARD).

Regards,

Priya.