Module pool program has different modules which contains different logic for different screen. Module pool program can be called dialog programming. Any number of screens can be developed by module pool programming. Every screen has a logic which runs at the back end. Module pool program can be executed by Transaction Code only.
Here we have created a program which contains two screens. Initial screen contains an input
field and some check boxes. In the input field we are getting the Customer number manually.
We have three check boxes. The box which is clicked will be shown on the second screen.
That means if we check Name and Country boxes then on the second screen we shall see
only the customer name and country code with the customer number. Two push buttons are
there and these two buttons have separate functionality for the data processing. Push button
DISPLAY only displays the entered customer details and CANCEL will clear the initial screen.
Below is the logic which is written according to the Includes.
*&---------------------------------------------------------------------*
*& Module Pool ZSR_MOD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
INCLUDE ZSR_TOP . " global Data
INCLUDE ZSR_O01 . " PBO-Modules
INCLUDE ZSR_I01 . " PAI-Modules
INCLUDE ZSR_F01 . " FORM-Routines
*&---------------------------------------------------------------------*
*& Include ZSR_TOP
*& Module Pool ZSR_MOD
*&
*&---------------------------------------------------------------------*
PROGRAM zsr_mod.
TABLES: kna1.
TYPES: BEGIN OF ty_kna1,
kunnr TYPE kna1-kunnr,
land1 TYPE kna1-land1,
name1 TYPE kna1-name1,
ort01 TYPE kna1-ort01,
END OF ty_kna1.
DATA: wa_kna1 TYPE ty_kna1,
it_kna1 TYPE STANDARD TABLE OF ty_kna1,
ok_code TYPE sy-ucomm,
ok_code2 TYPE sy-ucomm,
name TYPE c,
country TYPE c,
city TYPE c.
*&---------------------------------------------------------------------*
*& Include ZSR_O01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9001 OUTPUT.
SET PF-STATUS 'GUI_9001'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_9002 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9002 OUTPUT.
SET PF-STATUS 'GUI_9002'.
* SET TITLEBAR 'xxx'.
PERFORM process_list.
ENDMODULE. " STATUS_9002 OUTPUT
*&---------------------------------------------------------------------*
*& Include ZSR_I01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9001 INPUT.
CASE ok_code.
WHEN 'BACK'.
PERFORM leave.
WHEN 'EXIT'.
PERFORM leave.
WHEN 'CANCEL'.
PERFORM leave.
WHEN 'DISP'.
PERFORM display.
WHEN 'CANC'.
PERFORM cancel.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9002 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9002 INPUT.
CASE ok_code2.
WHEN 'BACK2'.
PERFORM leave2.
WHEN 'EXIT2'.
PERFORM leave2.
WHEN 'CANCEL2'.
PERFORM leave2.
ENDCASE.
ENDMODULE. " USER_COMMAND_9002 INPUT
*&---------------------------------------------------------------------*
*& Include ZSR_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form LEAVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM leave .
LEAVE TO SCREEN 0.
LEAVE LIST-PROCESSING.
ENDFORM. " LEAVE
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display .
IF kna1-kunnr IS NOT INITIAL.
SELECT SINGLE kunnr land1 name1 ort01
FROM kna1 INTO wa_kna1
WHERE kunnr = kna1-kunnr.
IF sy-subrc = 0.
CALL SCREEN 9002.
ELSE.
MESSAGE 'Customer Number doesn''t Exist' TYPE 'I'.
ENDIF.
ELSE.
MESSAGE 'Invalid Customer Number' TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " DISPLAY
*&---------------------------------------------------------------------*
*& Form CANCEL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM cancel .
CLEAR: kna1-kunnr, country, name, city.
LEAVE TO SCREEN 9001.
LEAVE LIST-PROCESSING.
ENDFORM. " CANCEL
*&---------------------------------------------------------------------*
*& Form LEAVE2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM leave2 .
CLEAR: kna1-land1, kna1-name1, kna1-ort01.
LEAVE TO SCREEN 0.
LEAVE LIST-PROCESSING.
ENDFORM. " LEAVE2
*&---------------------------------------------------------------------*
*& Form PROCESS_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM process_list .
IF name = 'X'.
kna1-name1 = wa_kna1-name1.
ENDIF.
IF country = 'X'.
kna1-land1 = wa_kna1-land1.
ENDIF.
IF city = 'X'.
kna1-ort01 = wa_kna1-ort01.
ENDIF.
ENDFORM. " PROCESS_LIST
We have created two screens here as follows:
PROCESS BEFORE OUTPUT.
MODULE STATUS_9001.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_9001.
and
PROCESS BEFORE OUTPUT.
MODULE STATUS_9002.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_9002.
We have created a Transaction Code here and below is the output of first screen:
Then we have the first screen as follows:
Now we are entering the input value and check the boxes as per requirement:
Finally we click on the display button and then following output has come:
Now by clicking BACK button on the standard toolbar we come back to the first screen and
then again by clicking BACK button we shall go to the home screen:
No comments:
Post a Comment