Mastering Sub Screens in SAP ABAP Module Pool Programming: A Comprehensive Guide

 A section of the screen that is defined within a module pool program is referred to as a submodule or "sub screen" in SAP ABAP module pool programming. With SAP module pool programming, you can design interactive user interfaces with independent management of various screen segments for improved modularity and organization.

This is a basic explanation of module pool programming's use of submodules:

  1. Main Screen: Usually, a module pool program opens with a main screen. The main screen that users interact with is this one. It may have buttons, input and output areas, and other UI components.
  2. Subscreens: Extra screens known as subscreens are ones that can be integrated into the primary screen. If necessary, they can be created independently and subsequently added to the main screen. Subscreens are reusable parts that contribute to the better maintainability and organization of the user interface.
  3. Submodule Pool: Submodule pools are separate ABAP programs that define subscreens and their logic. These submodule pools are then integrated into the main module pool program using the CALL SUBSCREEN statement.
  4. Communication: The most common method of communication between the main screen and subscreens is through parameters. Subscreens can return data to the main screen upon user interaction, and the main screen can pass data to the subscreens.
  5. Navigation: Users can navigate between different subscreens within the main screen using navigation buttons or other UI controls.

Syntax :- CALL SUBSCREEN SUB INCLUDING SY-REPID ‘0100’.

  • Where SUB = Sub screen area name.
  • SY-REPID :- System Variable for Report Id.
  • 0101 :- Sub Screen number.

Let’s take a real life requirement :-

Requirement :-

  • Suppose, we have two screens 100 and 200
  • We will create a sub screen on screen 100 and then we will call the screen 200 into sub screen area of screen 100.
  • And we will display Order details on that.

Solution :-

  • Step 1 :- Create a module pool program in ABAP Editor.



  • Step 2 :- Navigate to Object List.

  • Step 3 :- Create two screens and select Normal Screen radio button for screen 100 and Sub screen radio button for screen 0200.



  • Step 4 :- Open the layout for Normal screen.

  • Step 5 :- Design the below things on the layout of screen 100.



    • We have designed one label, one input/output field to take order number as input.
    • Then we have a Push button Submit whose FCT code is SUBMIT.
    • And then we have a sub screen area whose name is SUB.
  • Step 6 :- Open the layout on the screen 200.

  • Step 7 :- Click on Dictionary/Program fields.

  • Step 8 :- Provide the table name and select the fields which you want to be displayed.



  • Step 9 :- Press enter and drop on the screen.



  • Step 10 :- Save the layout.

  • Step 11 :- Open the Flow logic of Screen 100 and write the below logic.



  • Step 12 :- Create a type structure for the table and also create the corresponding internal table and work area.



  • Step 13 :- Open the PBO of Screen 100 and write the logic.



  • Step 14 :- Create a transaction code for our module pool program.




Code :-

*&---------------------------------------------------------------------*
*& Modulpool ZAR_SUB_SCREEN
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
PROGRAM ZAR_SUB_SCREEN.

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 ORDER_NUMBER order_date
  payment_mode total_amount currency
  from ZAR_HEADER into table lt_header
  where order_number = ZAR_HEADER-ORDER_NUMBER.

  Read table lt_header into ls_header index 1.
  if sy-subrc eq 0.
    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.
  endif.
endif.

if sy-ucomm eq 'BACK'.
  leave to screen 0.
endif.
ENDMODULE.

Execute the Program :-



  • Click on submit button.



Comments

Popular posts from this blog

Understanding Different Types of SAP Function Modules: Normal, RFC, and Update

Unlocking SAP ABAP Secrets: Interactive Classical Reports with GET CURSOR, At User Command, and a Comparison of HIDE Statements

Mastering ABAP: A Step-by-Step Guide to Function Modules and Groups for Modularized Programming