Understanding Modal Dialog Boxes in SAP ABAP Module Pool Programming: A Practical Approach
In SAP ABAP, a modal dialog box screen in a module pool is a user interface element that is used to display information or gather input from the user within a specific context of a module pool program. Here's a breakdown of its components:
- Definition: The modal dialog box screen is defined within the module pool program using the ABAP Dialog Programming techniques.
- Purpose: It serves various purposes such as displaying messages, warnings, errors, or requesting user input for certain actions.
- Modal: It's termed as "modal" because it halts the execution of the program until the user interacts with it, ensuring that the user addresses the information or input request before proceeding further.
- Components: Like any other screen in SAP ABAP, the modal dialog box screen consists of elements such as input fields, buttons, icons, text elements, etc., depending on the specific requirements of the dialog.
- Control Flow: Once the modal dialog box screen is displayed, the program waits for user input. Based on the user's actions (e.g., clicking a button or entering data), the program responds accordingly. After the user has interacted with the dialog box, the program resumes execution.
- Data Exchange: Data entered by the user in the modal dialog box can be transferred back to the calling program for further processing, typically through parameters or shared memory techniques.
- Integration with Module Pool: The modal dialog box screen is integrated into the module pool program's flow, allowing it to interact with other screens and program logic within the same module pool.
Overall, the modal dialog box screen in SAP ABAP provides a means for interactive communication between the user and the module pool program, facilitating a structured and controlled user experience within the SAP environment.
let’s take a real life Requirement to understand it more clearly.
Requirement :-
-
Suppose, below is our header table
-
Now, Customer wants us to create two screens 100 and 200.
-
Screen 100 will be normal screen and Screen 200 will be Modal dialog box screen.
-
On screen 100 the user wants us to create a field label Order Number, then a input field for order Number and then a submit button for order number.
-
Now the customer wants that, as soon as He / She press Submit button, Header details should be open in form of Modal Dialog Box screen.
Solution :-
-
Step 1 :- Create a Module Pool Program in ABAP Editor.
-
Step 2 :- Navigate to SE80 by click into Object list display.
-
Step 3 :- Create two screens 100 and 200 and make sure to check Modal dialog box for screen 200.
-
Step 4:- Open the screen painter for screen 100 and design the below screen and click on save.
-
Step 5 :- Open screen 200 and select Dictionary/Program fields.
-
Step 6 :- select the fields and press enter.
-
Step 7 :- drag and drop on screen 200 and click on save.
-
Step 8 :- Create a OK button on screen 200, so that when the Customer press on OK button , the it should get back to 200 screen.
-
Step 9 :- Write the logic to call the modal dialog box screen in PAI of screen 100.
-
Step 10 :- declare type structure, internal table and work are for our header table.
-
Step 11 :- Write the logic in PAI for screen 100.
-
Step 12 :- Create a transaction code for the program.
Code :-
*&---------------------------------------------------------------------*
*& Modulpool ZAR_MODULE_POOL_PROGRAM
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
PROGRAM zar_module_pool_program.
TABLES: ZAR_HEADER.
TYPES : BEGIN OF ty_header,
order_number TYPE zar_order_number,
order_date TYPE zar_order_date,
payment_mode TYPE zar_payment_mode,
total_amount TYPE zar_total_amount,
currency TYPE zar_curency,
END OF ty_header.
DATA : lt_header TYPE TABLE of ty_header,
ls_header TYPE ty_header.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'HEADER'.
SET TITLEBAR 'HDR'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
IF sy-ucomm EQ 'SUBMIT'.
select single Order_number order_date
payment_mode total_amount currency
from ZAR_HEADER into ls_header
where order_number = ZAR_HEADER-ORDER_NUMBER.
ZAR_HEADER-ORDER_NUMBER = ls_header-order_number.
ZAR_HEADER-ORDER_DATE = ls_header-order_date.
ZAR_HEADER-PAYMENT_MODE = ls_header-payment_mode.
ZAR_HEADER-total_amount = ls_header-total_amount.
ZAR_HEADER-currency = ls_header-currency.
CALL SCREEN '0200' STARTING AT 10 20 "Top Left Corner Coordinates
ENDING AT 80 60. "Bottom Right Corner Coordinates
ENDIF.
IF sy-ucomm EQ 'BACK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_0200 OUTPUT.
SET PF-STATUS 'HEADER'.
SET TITLEBAR 'DET'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0200 INPUT.
IF sy-ucomm EQ 'OK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.
Execute the Code :-
-
click on submit button.
-
Click on OK button.
Comments
Post a Comment