Chapter 6 - Module Pool Programming
Chapter 6 - Module Pool Programming
1. Introduction
Module Pool Programming is also called as dialog programming.
3. Requirement
Let’s take a requirement to create two screens ( 100 and 200 ) out of which we will display
Employee details on screen 100 and Project details on screen 200.
Tabs of a Screen :-
1. Attributes :-
It gives us the generic information of that screen.
All the elements that we will design on this screen will be a part of element list.
3. Flow Logic :-
Its purpose is to write the logic.
4. Creating Screens
Step 1 :- Right click on the program name → create → screen to create a screen.
Whenever the program is executed, the module inside the PBO event is triggered first.
F4 Help :-
It tells us what are the various possible values for any input field.
For creating buttons we will use PBO event and for writing logic we will use PAI event.
Now, In this part we will design the layout to display data of Employee on screen 100
and Project details on screen 200.
Designing the layout and Displaying data in Module Pool Programming (Using Screen Painter ) 1
Mob No :- +916261538504
We will create a label Employee Id and then we will create a input field for it where we
will take input from the user.
Then we will create a button SUBMIT and when we will click on that SUBMIT button,
we will display the Employee Details based on the input on Screen 100.
Step 2 :- Click on the text field to create a field label for Employee Id.
Step 3 :- Then we are require to create a input field to take input from user and for that
we will click on input/output field.
Note :-
Every buttons requires a function code.
Designing the layout and Displaying data in Module Pool Programming (Using Screen Painter ) 2
Mob No :- +916261538504
Step 5 :- Now to display the data from various field of Employee Table
Then we will go to screen 100 and write the logic in PAI of screen 100.
Designing the layout and Displaying data in Module Pool Programming (Using Screen Painter ) 3
Mob No :- +916261538504
Requirement for screen 200
Since, we are getting data from our Employee table on screen 100 and now we want to
display data of the project details tables on screen 200 based on the input of Employee Id
on screen 100.
For showing multiple data we will require the understanding of Table Control with
wizard and we will discuss this in the next part.
Designing the layout and Displaying data in Module Pool Programming (Using Screen Painter ) 4
Mob No :- +916261538504
3️⃣
Table Control With Wizard
In the previous part we designed the layout of screen 100 and we displayed the data from
Employee table on it based on the given input of Employee Id.
In this part we will display the data of Project Details on screen 200.
Now, see we have multiple records in Project Details tables for each employee Id, so for
displaying multiple records in module pool programming we use the concept of Table
Control With Wizard.
Definition
Table Control is used to display data in the form of a table( column and rows ).
A section of the screen that is defined within in the module pool program is referred to as a
submodule or Sub Screen.
Sub screens are extra screens which can be integrated into the primary screen.
Requirement :-
Calling a Sub screen into the normal screen/ primary screen.
We will display Employee Details on the Sub Screen from our Employee Table.
Call the Sub Screen in to the sub screen area of the normal screen.
Syntax :-
CALL SUBSCREEN SUB INCLUDING SY-REPID ‘0200’.
WHERE
SUB :- Sub Screen area name
Implementation
Step 1 :- Create a module pool program from SE38 transaction code.
Step 4 :- We will go to screen ‘100’ and we will create a label for Employee Id, input/output
field for Employee id and a Submit button.
Step 5 :- Create a sub screen area on screen 100 with name SUB.
Step 7 :- From the 100 screen we will call the screen 200 from PBO event.
Code :-
*&-----------------------------------------------------------
*& Module Pool ZAR_SUB
*&
*&-----------------------------------------------------------
*&
*&
*&-----------------------------------------------------------
PROGRAM ZAR_SUB.
TABLES : ZAR_EMP_TAB.
TYPES : begin of ty_employee,
EMP_ID type ZAR_EMP_ID,
EMP_NAME type ZAR_EMP_NAMe,
department type ZAR_DEPARTMENT,
manager type ZAR_MANAGER,
end of ty_employee.
DATA : lt_employee type table of TY_EMPLOYEE,
ls_employee type TY_EMPLOYEE.
*&-----------------------------------------------------------
*& Module USER_COMMAND_0100 INPUT
*&-----------------------------------------------------------
* text
*------------------------------------------------------------
MODULE USER_COMMAND_0100 INPUT.
if sy-ucomm eq 'SUBMIT'.
Select emp_id emp_name department manager
from ZAR_EMP_TAB
into table LT_EMPLOYEE
where EMP_ID = ZAR_EMP_TAB-EMP_ID.
Output
1. Introduction
This screen appears in the form of dialog box.
2. Requirement
On Screen 100, when we click on Submit button, the data from our Employee table will
appear in form of Modal Dialog box from screen 200 and when the user will click on OK
button, the control will get back to the 100 screen.
Syntax :-
CALL SCREEN 0200 STARTING AT 10 20 "Top Left Corner Coordinates
ENDING AT 70 80. "Bottom Righ
PROGRAM ZAR_MODAL.
TABLES : ZAR_EMP_TAB.
*&--------------------------------------------------------------
*& Module USER_COMMAND_0100 INPUT
*&--------------------------------------------------------------
* text
*---------------------------------------------------------------
MODULE USER_COMMAND_0100 INPUT.
if sy-ucomm eq 'SUBMIT'.
Select EMP_Id EMP_NAME DEPARTMENT MANAGER
from ZAR_EMP_TAB
into table LT_EMPLOYEE
endif.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&--------------------------------------------------------------
*& Module USER_COMMAND_0200 INPUT
*&--------------------------------------------------------------
* text
*---------------------------------------------------------------
MODULE USER_COMMAND_0200 INPUT.
leave to screen 0. "to get back to previous screen on pressing e
ENDMODULE. " USER_COMMAND_0200 INPUT
Output
1. Introduction
A tab strip with a wizard interface combines the functionality of tabs for navigation with the
step-by-step guidance of a wizard.
Using Tab Strip With Wizard we can create multiple tabs in Module Pool and we can display
various kinds of data according to our requirement.
2. Requirement
Our Requirement is to create two tabs on a screen and to display Employee Details from
Employee Table on one tab and Project Details from Project Details table on another tab.
Step 2 :- We will create a screen 100 and we will define a label, input/output field, a
Submit button.
Step 8 :- uncomment the PAI of screen 100 and implement the logic.
Till now we have seen various kinds of screens in Module and we used them to achieve our
various kinds of requirements.
In this part we will see how we can integrate all Module Pool applications that we created
into a single one.
Requirement :-
We have created four module pool programs for our previous requirement which includes,
Sub Screen
In this part, we will call all these programs from one single Module Pool program.
Implementation :-
Step 1 :- Create a Module Pool Program from ABAP Editor.
Step 2 :- Create a normal screen and then design a label, 4 radio buttons, a SUBMIT
pushbuttons on it.
Now we are require to define our radio buttons to one group, otherwise you will see all
of them as ticked.
Step 3 :- Now, we are required to define the variable for all the four radio buttons.
AT EXIT COMMAND is used to leave the current screen without automatic input checks
taking place.
When we discussed the concept of Tab Strip With Wizard, we designed the below screen.
Requirement 2 :-
In the above scenario if there is no input of Employee Id and we are clicking on Submit
button, then It will give error,
Even if you will click on any button, it will give the same error that no input in Employee Id.
Now, this time we want that if we click on Submit button, then and then only this error
should be shown and rest buttons should be working properly.
Implementation :-
Step 1 :- Mark the function type of the button as E.
1. Introduction
The purpose of Chain and End Chain is to validate the input Field.
We will validate the input given by user by using chain and end chain.
Note :-
To validate the user input you will provide a error message on your screen and as soon
as you will provide an error message on your screen your input screen will be disabled.
To overcome this issue, SAP has given us Chain and End Chain statement to perform
the validation step.
We can validate any number of field through chain and end chain.
2. Implementation
Step 1 :- We will write a message that when we click on Submit button and Select query do
not return any result, then we will get a message that Employee details do not exist.
Now, when you will pass a wrong data on screen your screen will change to read mode
and you will not be able to pass the correct details.
So, to achieve this requirement so that our field will remain in change mode even we
pass the wrong details, we will implement the chain and end chain concept.
Step 2 :- We will go to Flow logic for screen 100 and we will implement the Chain and End
chain.
We can use multiple fields and we can write logic for each of them.
In this part we are going to see, how we can change the properties of screen fields based on
various kind of requirements.
Let’s take the example of our Table Control with wizard program which we have developed
in our previous parts.
Requirement
Our requirement is that when I given 101 as employee id, my screen fields of Employee
Details should be disabled and when I give employee id as 102, then screen field should be
enabled.
Implementation :-
Output
In this part we will see how want have drop down list in Module Pool Programming.
Requirement :-
We are going to create 2 drop down list, the second one should be dependent on the first one.
First drop down list should be regarding states which will consist of names of state and on
the basis of it, the second drop down list will have the values of cities present in that state.
Implementation :-
Step 1 :- To achieve this requirement, we will start with creation of a table having two
columns State and City in it.
Step 3 :- Then we will create a module pool program through ABAP Editor ( SE38 )
transaction code.
Step 4 :- We will create a screen 100 there and we will design our requirement there.
Step 6 :- Now we will write the logic, so that name of cities should only be shown for a
particular state in drop down format.
Note :-
Whenever we will give any value for the State then PAI should be triggered, so that we
write logic for city field.
So, to achieve that requirement, we will simply, give a function code for State
field.
Step 8 :- Then we will write the logic for fetching and storing data in PAI of screen 100.
Note :-
We have a dedicated function module VRM_SET_VALUES, which we can use for this
mapping.
*&--------------------------------------------------------------
*& Module STATUS_0100 OUTPUT
*&--------------------------------------------------------------
*&
*&--------------------------------------------------------------
MODULE status_0100 OUTPUT.
SET PF-STATUS 'DROP_DOWN'.
SET TITLEBAR 'DRP'.
ENDIF.
ENDMODULE.
*&--------------------------------------------------------------
*& Module USER_COMMAND_0100 INPUT
*&--------------------------------------------------------------
* text
*---------------------------------------------------------------
MODULE user_command_0100 INPUT.
IF sy-ucomm EQ 'BACK'.
LEAVE TO SCREEN 0.
ENDIF.
IF sy-ucomm EQ 'STATE'.
SELECT state city
FROM zar_state_city
INTO CORRESPONDING FIELDS OF TABLE lt_state_city
WHERE state = zar_state_city-state.
ENDIF.
ENDMODULE.
Till now, In our Module Pool programming, we saw how we can create input/output field
and field labels etc.
Now, In this part we will see how we can create Select Options in case of Module Pool
Programming.
Implementation :-
Step 1 :- Go to SE38 transaction code and create a module pool program.
Step 4 :- We will go to screen 100, there we will create a sub screen area.
Code :-
*&--------------------------------------------------------------
*& Modulpool ZAR_SELECT_OPTION_MODULE_POOL
*&--------------------------------------------------------------
*&
*&--------------------------------------------------------------
PROGRAM ZAR_SELECT_OPTION_MODULE_POOL.
When you will F4 on a field, then at that Process on Value Request event will call.
Requirement :-
In the previous part, we developed the below programs
Our Requirement is that we want to create a search help for our Employee Id.
Hints :-
Implementation :-
Step 1 :- We will go to screen 100 we will assign the event Process on value request.
Then we will use field statement to give the name of the field for which we want to
apply process on value request.
After that we can see we will have a F4 button enabled for our employee id.
Step 3 :- Now we are require to write the logic to fill this employee id value.
tables
value_tab = lt_emp
EXCEPTIONS
Testing :-
Execute the code and press F4 button on output screen for employee Id.
Whenever you click on a Field it shows us the technical information of that particular field.
In this part we will see how we can create a technical information for a particular field.
Requirement :-
In the previous part, we saw how we can create a F4 help for a particular field.
Our Requirement is to create a F1 help for the same field Employee Id.
Hints :-
In SAP We create a documentation through SE61 transaction code.
Implementation :-
Step 1 :- Go to SE61 transaction code.
Step 2 :- For general documentation select General text for document class.
Step 7 :- Go to the flow logic of screen 100 and write the event Process on help request and
give the field and a corresponding module.
Step 8 :- Double click on the given module and write the logic inside the module.