Modulepool - Dialog Programing
Modulepool - Dialog Programing
SCREEN
It is a visible layout which is displayed in the output. The components of the Screen are
Components of Screen:
MODULE:
Requirement: design the below screen and write the logic for buttons.
Leave program is sap keyword which can move control out of application.
SAVE and ACTIVATE go BACK and ACTIVATE
Select the program name, right click create -> Transaction
Use Tcode
Use Tcode:
Check the actions in KNA1 Table.
Note: Flow logic Sequence: - PBO triggered, screen displayed. After screen displayed, customer
number entered and perform Display. With this PAI triggered. So that data kept in body. Then PBO
triggered and screen refreshed. Then from body data transfers to screen via work area.
Flow Logic sequence is PBO + PAI + PBO
In the below example we will create a simple Module Pool Program to display hello world.
Go to SE80, select program from drop down, provide name as ZSAP_HELLO_WORLD and press
enter.
Save, click back (F3) and create another module and do same as above.
Click on Layout ( toolbar button), it will open Module Pool layout designer (If you are using it first
time it might take some time...If you failed to open layout it might be due to some missing
configuration, at that time contact basis/admin).
The layout will be like below, drag and drop Text Field element on to screen area.
Provide name and text.
Save, close windows, go to flow logic, double click on each module and add below code.
Double click on MENU100 to create menu. Activate
Double click on TITLE01 to create title GUI status for the program.
Example module pool program to display material details, module pool program
using form and button
Requirement: Display material details for a material input by designing a module pool screen.
Go to SE80, select program from drop down, provide name and press enter.
Expand program, double click on top include and add below code.
Right click on program name, create -> screen.
Move mouse cursor on layout and place the form in suitable position.
Now click on text icon, put it before any input field and enter text.
IF SY-UCOMM = 'GETM' .
SELECT SINGLE * FROM MARA INTO CORRESPONDING FIELDS OF WA_MARA
WHERE MATNR = WA_MARA-MATNR.
ENDIF.
Such sub screens are for Reusability. User can reuse sub screens with in application and even
across applications. Here 120 screen is sub screen because it calls 100 and 110 screens.
Sub Screen area is a part of Normal screen. sub screen can be displayed in sub screen area.
Sub screen Logic: CALL SUBSCREEN <sub screen area name> INCLUDING <module pool
program name> <sub screen number>
With this syntax sub screen can be displayed in normal screen.
Every screen have separate PBO and PAI that is Flow Logic.
Requirement is as below:
Flow logic sequence: - Normal screen triggered, with that call sub screen logic executed. So
that normal screen can display along with sub screen. After display customer entered then
Display perform with this normal screen PAI triggered, then data kept in body. Finally sub
screen PBO triggers, then sub screen can be refreshed. Later data transfers from body to sub
screen fields via work area.
Select SE80, provide module pool program name: ZDLG_SUBSCREEN
Provide screen No: 100
Select ‘create’ to switch over to screen painter
Maintain description: Normal screen to sub screen application
SAVE
Select LAYOUT from screen painter. Go to -> secondary window -> dictionary program fields
Select only customer field and provide customer field in layout (kna1 -> kunnr)
From tool box select ‘sub screen area’ to maintain properties
Properties means name only i.e. SUB (we can take any name)
Maintain DISPLAY and EXIT operations by using Push Button.
SAVE and ACTIVE normal screen design
Select SE80, provide module pool program name: ZDLG_SUBSCREEN
Provide screen No: 120
Select ‘create’ to switch over to screen painter
Maintain description: Sub screen to normal screen
Select screen type : SUBSCREEN radio button
Select LAYOUT, Go to -> secondary window -> dictionary program fields
Select fields Customer Name(NAME1) and City(ORT01). Drop it in layout at the corner because
we don’t know the exact place of the sub screen area which is in Normal screen
SAVE and ACTIVATE sub screen design
Screen 100 flow logic: -
Select se80, provide module pool program name : ZDLG_SUBSCREEN
select screen number : 100
Select CHANGE (ctrl+F1)
In PBO, Process before output
Call subscreen SUB including ‘ZDLG_SUBSCREEN’ ‘120’.
* MODULE STATUS_0100.
Select PAI module and un comment it and double click on its module
Select main program
Tables: kna1.
Types: Begin of ty_kna1,
Kunnr type kunnr,
Name1 type name1_gp,
Ort01 type ort01_gp,
End of ty_kna1.
Data: wa_kna1 type ty_kna1,
I_kna1 type standard table of ty_kna1.
Select module .. end module of PAI
Case sy-ucomm.
When ‘DISPLAY’.
Select kunnr name1 ort01 from kna1 into table i_kna1 where kunnr = kna1-kunnr.
When ‘EXIT’.
Leave program.
Endcase.
Endcase.
ENDMODULE.
SAVE and ACTIVATE , F3 ,ACTIVATE
Select SE80 choose program right click -> create -> Transaction
Provide t code :zwt_tr
This is to demonstrate the step by step tutorial of how to make use of table control with wizard, where the
developer’s effort to write code with table control without wizard is avoided.
Table control with wizard is the control provided by SAP, in which the users are not needed to code
separately for table control operations. It generates automatically system generated code for the following
table control operations.
1. Insertion
2. Deletion
3. Scrolling
4. First
5. Last
6. Next
7. Previous
8. Select
9. Select all
10. Deselect
11. Deselect all
Double click the program, Create an internal table and work area, which we are going to deploy
in table control.
tables :mara.
types: BEGIN OF ty_mara,
mark type c,
matnr type matnr,
ersda type ersda,
ernam type ernam,
END OF ty_mara.
data: it_mara type table of ty_mara,
wa_mara type ty_mara.
Once you drag and drop the control a popup will appear.
Press Continue. In the next screen enter the table control name as ‘TBC_0100’ or your own name.
In the next screen you input the internal table and work area which has been created earlier.
Note: Before it is done, you must activate the page, in which you have declared the internal table and
work area. Then only this table control screen will take its properties.
The next screen will automatically retrieve the fields available in the internal table and show. We have to
select those fields, which and all should be displayed in table control.
If you have declared any character field for table control line selection, that should not be selected in this
screen
Select the input/output attributes as ‘Input control’ and give the field for selection of table control rows.
Select the multiple line selection.
Click on Continue.
Click on Continue.
Click on Continue. The table control with auto generated code will automatically be created.
Click Complete
This will automatically create PBO & PAI modules for table control operations.
select matnr ersda ernam from mara into CORRESPONDING FIELDS OF TABLE it_mara
up to 10 rows.
All sap applications by default follows screen level validations. To apply field level validations
Logic should kept explicitly using CHAIN … ENDCHAIN syntax.
Application based on field level validations:
Select se80 and create Module pool program for field level validations: ZDLG_VALIDATIONS
Right click program -> Create -> Screen
Provide screen number: 100; Maintain description: Field level validations application
SAVE
Select Layout, provide Customer, Name, City fields in layout screen
Go to secondary window dictionary program field KNA1 select field KUNNR
SAVE screen design
Select flow logic from screen painter, select PAI module and delete comment
Double click on that module, select Main program
TABLES: KNA1, VBAK.
TYPES: BEGIN OF TY_KNA1,
KUNNR TYPE KUNNR,
NAME1 TYPE NAME1,
ORT01 TYPE ORT01,
END OF TY_KNA1.
DATA: WA_KNA1 TYPE TY_KNA1,
IT_KNA1 TYPE TABLE OF TY_KNA1.
Using data base LUW, data transfer from screen to data base buffer.
Whenever application terminate in between then whatever data having in data base
buffer that data can be deleted automatically.
Using sap LUW data transfers from buffer to tables
In ABAP transactions FCT codes are mandatory whenever user interaction required.
In this we maintain FCT codes for Customer and Sorder which are in Tab Strip Control.
Select se80 and create Module pool program for Tab strip control application:
ZDLG_TABSTRIP
Right click program -> create -> Screen. Provide screen no: 100
From tool box select Tab Strip Control & drop it in layout.
Double click on Tab Strip Control to maintain properties i.e. name only
Name is: STRIP and close it
Click on first control (Tab1) to maintain properties
Name: CUSTOMER, Text: CUSTOMER, FCT code: TAB1
From tool box select Sub Screen Area drop it under CUSTOMER control
Click on sub screen area to maintain properties i.e. Name: SUB
Click on second control (Tab2) to maintain properties
Name: SORDER, Text: SORDER, FCT code: TAB2, Reference field: SUB
Select PBO Module and double click on that, select MAIN PROGRAM
Select module .. end module of PBO.
This is to demonstrate the step by step tutorial of how to make use of table strip with wizard, where the
developer’s effort to write code with tab strip without wizard is avoided.
Tab strip with wizard is the control provided by SAP, in which the users are not needed to code separately
for tab strip operations. It generates automatically system generated code for the following tab strip
operations.
Tab Title definition: In this have to mention minimum 2 tabs titles. If we try to create only one tab the
following message is displayed.
Tab Title definition Tab text Sales Header Details (One Tab), Sales Item Details (Another Tab).
Click on Continue.
Sub screens (601, 602) for 2 tabs and Function codes are generated in this step. Click on continue.
PBO and PAI Includes are generated automatically by this wizard in this step. Click on Continue
Tab strip Control is generated. Click On Continue
Screen 600 is as shown below with 2 tabs and 2 different Sub screen areas.
Empty Sub screen 601 has been created for tab (Sales Header details)
Empty Sub screen 602 has been created for tab (Sales Item details)
Click on Dictionary/Program fields to select the required fields from VBAK table.
Table/Field Name: VBAK and Click on Get from Dictionary Fields will be displayed.
Similarly repeat the same steps for the Sub screen 602 to display the Sales Item Details (from VBAP
table). Select the required fields.
SELECT SINGLE vbeln erdat erzet ernam
FROM vbak
INTO (vbak-vbeln, vbak-erdat, vbak-erzet, vbak-ernam).
SELECT SINGLE vbeln posnr matnr matwa
FROM vbap
INTO (vbap-vbeln, vbap-posnr, vbap-matnr, vbap-matwa).
Through the code wizard empty PBO and PAI has been generated. Need to implement the logic to call
screens( Normal screen 600, Subscreen 601 and Subscreen 602). And in PBO MODULE STATUS
TABLES : VBAK, VBAP.
Activate the program Right click on program create Transaction.
The Output is displayed. Tab strip with 2 tabs 1) Sales Header Details and 2) Sales Item Details