Module Pool
Create a module pool prg, create all include programs and activate.
IT is called dialog programming. It is a pool of modules (Screens, includes, Transactions)
Create screens:
Create PBO objects:
Create interfaces : SET PF_ STATUS Application tool bar & Function keys
[Link] function Attributes
Create a tcode for the module pool:
Create the Tables as per requirement: STUDENT details & Mark list
DESIGN the LAYOUT:
(Screen painter : se51)
Create a local structure and work area in the TOP include:
Data: gv_okcode type sy-ucomm,
Gv_save type sy-ucomm.
Write the logic in User_command 9000:
MODULE user_command_9000 INPUT.
*CALL SCREEN 9001.
gv_okcode = sy-ucomm.
CASE gv_okcode.
WHEN 'DISP'.
SELECT * FROM zls_student
INTO TABLE gt_student WHERE stud_id = zls_student-stud_id.
LOOP AT gt_student into gs_student.
ZLS_STUDENT-NAME = gs_student-name.
ZLS_STUDENT-class = gs_student-class.
ZLS_STUDENT-division = gs_student-division.
ENDLOOP.
when 'LIST'.
CALL SCREEN 9001.
when OTHERS.
LEAVE SCREEN.
ENDCASE.
ENDMODULE.
Create TABLE CONTROL for ITEM TABLE:
table control as ‘TBL_CTRL’ as declared in the main program. Check the Vertical and Horizontal
resizing button. Select the Horizontal and vertical separators. Select the w/SelColumn check box
and Provide the name as LS-SEL. [LS- is declared as a work area in the main program]. This LS_SEL
works as a select button for each row in the table control.
Step 5. Click on the top button marked as red and in the pop up window provide the work area
name as ‘LS’ and click on the Get from Program button. Select some fields that you want to show
in the table control columns. At last click on the Continue button.
Step 6. All the selected columns appear in the table control .
Step 7. Now lets provide the column text to every column on the table control. Select the text box
element from the element list, drag and drop it on the header of the table control. Double click on
the text element and Provided the required column text as shown below.
Step 8. Double click on the first column [LS-BUKRS]. As it is the primary key field of the table, lets
make it as read only field. Set the property as ‘Output only’.
Step 9. Provide the flow logic of the screen ‘0001’ containing the table control. Add the Loop and
Endloop statement in the PBO and PAI of the screen which contains the table control. The Loop
and Endloop statement in the PBO is used to read the value from the internal table and fill the
table control through the work area. The Loop and Endloop statement in the PAI is used to process
the record that are in the table control if the user performs some action like updating or modifying
the existing records.
Step 10. Define the modules in the flow logic of the screen and provide some code in it as shown
below.
Step 11. Lets create a T-Code for the Module pool program.
Step 12. Run the program and the table control is displayed on the screen.
Step 13. The table control and tab strip controls structures are defined in the type group ‘CXTAB’.
Go to – SE11 and provide the type group name and click on display button.
Step 14. The table control follows the type ‘SCXTAB_CONTROL’ and the tab strip control follows
type ‘SCXTAB_TABSTRIP’.
Create a sub screen and tabstrip:
Create 2 screens main : 9002(design sub screen area), sub : 9003
Subscreen coding in mainscreen:
PROCESS BEFORE OUTPUT.
call SUBSCREEN sub INCLUDING sy-repid '9003'.
Design tabstrip Wizard:
Modal dialog box:
Create model dialog screen 9004 display details.
Call the dialog from 9001. CREATE BUTTON
Write the below code in 9001(main call screen) – PAI -function code/button(ok).
call SCREEN 9004 starting at 10 20 "top lef corner co-ordinates
ending at 50 60. "bottom right corner co-ordinates
In Modal Dialog box screen 9004,
gv_okcode = sy-ucomm.
CASE gv_okcode.
when 'OK'.
leave TO SCREEN 0.
ENDCASE.
AT EXIT COMMAND:
SET FIELD INTO: REQUIRD (VALIDATION)
IN PAI USER COMMAND:
MODULE EXIT AT EXIT-COMMAND.
DOUBLE CLICK AND WRITE THE CODE LEAVE TO SCREEN 0.
CHAIN & ENDCHAIN:
It will enable the input screen.
MESSAGE E003(ZLS_MSG_CLASS). Instead we can use chain endchain.
Loop at screen.
If screen-name = ‘OK_code’ or screen-name = ‘SAVE’
Screen-input = 0.
Modify screen.
Endif.
Endloop.
11. Drop down list:
Create 2 tables with domain level value table. Go tosm30 and set values
In module pool program design screen with dropdown listbox.
Call function VRM_SET_VALUES : in field we can group the values to list display.
ROW SELECTION in TABLE CONTROL:
Create header ,item structure and a final structure.
Step 1: Data Declaration (Top Include)
First, you need to declare your types, the internal table, the work area, and the table control
itself. This usually goes in your TOP include.
ABAP
*----------------------------------------------------------------------*
* INCLUDE ZX_TOP *
*----------------------------------------------------------------------*
PROGRAM z_table_control_demo.
" 1. Your provided structure
TYPES: BEGIN OF ty_item,
saleid TYPE zls_sale_item-saleid,
name TYPE zls_sale_item-name,
type TYPE zls_sale_item-type,
price TYPE zls_sale_item-price,
currency TYPE zls_sale_item-currency,
unit TYPE zls_sale_item-unit,
END OF ty_item.
" 2. Internal table and work area
DATA: it_item TYPE STANDARD TABLE OF ty_item,
wa_item TYPE ty_item.
" 3. Table control declaration
" Replace 'TC_ITEMS' with the actual name you gave the table control in
Screen Painter
CONTROLS: tc_items TYPE TABLEVIEW USING SCREEN 100.
" 4. OK Code variable for user interactions
DATA: ok_code TYPE sy-ucomm.
Important UI Note: In your Screen Painter (Screen 100), make sure the input/output fields
inside the table control columns are named exactly after your work area. For example:
WA_ITEM-SALEID, WA_ITEM-NAME, WA_ITEM-TYPE, etc.
Step 2: Screen Flow Logic (Screen 100)
In the flow logic of your screen, you need to use the LOOP statement to process data between
the internal table and the screen table control.
ABAP
PROCESS BEFORE OUTPUT.
* Module to set status and title
MODULE status_0100.
* Loop through the internal table to display data on the screen
LOOP AT it_item INTO wa_item WITH CONTROL tc_items CURSOR tc_items-
current_line.
MODULE tc_items_get_lines.
ENDLOOP.
PROCESS AFTER INPUT.
* Module for standard user commands (Back, Exit, etc.)
MODULE user_command_0100.
* Loop to capture any data entered/modified by the user on the screen
LOOP AT it_item.
MODULE tc_items_modify.
ENDLOOP.
Step 3: PBO Modules (Process Before Output)
Create the PBO modules to handle the initial display and update the table control properties.
ABAP
*----------------------------------------------------------------------*
* MODULE status_0100 OUTPUT
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN_STATUS'. " Create this GUI status
SET TITLEBAR 'MAIN_TITLE'. " Create this Title
" Populate the internal table with initial data if it's empty
IF it_item IS INITIAL.
" Example: SELECT * FROM zls_sale_item INTO TABLE it_item UP TO 20
ROWS.
ENDIF.
" Tell the table control how many total lines exist in the internal table
" This ensures the vertical scrollbar works correctly
DESCRIBE TABLE it_item LINES tc_items-lines.
ENDMODULE.
*----------------------------------------------------------------------*
* MODULE tc_items_get_lines OUTPUT
*----------------------------------------------------------------------*
MODULE tc_items_get_lines OUTPUT.
" Data is automatically moved from WA_ITEM to the screen fields here
" You can add row-specific logic here if needed (e.g., disabling specific
cells)
ENDMODULE.
Step 4: PAI Modules (Process After Input)
Create the PAI modules to handle user actions and save screen inputs back into your internal
table.
ABAP
*----------------------------------------------------------------------*
* MODULE user_command_0100 INPUT
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
" Handle other buttons (Save, Refresh, etc.) here
ENDCASE.
CLEAR ok_code.
ENDMODULE.
*----------------------------------------------------------------------*
* MODULE tc_items_modify INPUT
*----------------------------------------------------------------------*
MODULE tc_items_modify INPUT.
" This updates the internal table with whatever the user typed into the
Table Control
MODIFY it_item FROM wa_item INDEX tc_items-current_line.
ENDMODULE.