0% found this document useful (0 votes)
222 views

Module Pool Programming

This document provides instructions for creating a module pool programming application in ABAP for managing customer details. It includes steps to create a dialog programming module using transactions SE38 and SE51, create a screen using SE51, assign a transaction code using SE93, and add event handling logic and database access using ABAP code. The application allows the user to display, clear and exit customer records by triggering different events based on the function keys pressed.

Uploaded by

Ashutosh Jha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
222 views

Module Pool Programming

This document provides instructions for creating a module pool programming application in ABAP for managing customer details. It includes steps to create a dialog programming module using transactions SE38 and SE51, create a screen using SE51, assign a transaction code using SE93, and add event handling logic and database access using ABAP code. The application allows the user to display, clear and exit customer records by triggering different events based on the function keys pressed.

Uploaded by

Ashutosh Jha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

MODULE POOL PROGRAMMING

ABAP Transactions:
 It is also known as Module Pool Programming
 It is also known as Dialog Programming

Transaction:
A transaction is a series of Dialog (Screen) Steps in which application will
accept data from user which is finally updated to Database

Name1

Ort01 Dialog Programming


Flow Logic
Land1

Display exit

Note:
Flow Logic (Events) acts as interface between Screen Painter & Dialog
Programming

Events in Dialog Programming:


1. PAI (Process After Input)
2. PBO (Process Before Output)
3. POH (Process on Help Request)
4. POV (Process on Value Request)

PAI:
 It triggers after processing input values in a screen
 This event triggers whenever user interacts with a screen

PBO:
It triggers before screen display

Note:
1. PAI will brings the data from Screen to Program Variables
2. PBO will brings the data from Program Variables to Screen
POH:
It triggers whenever user select F1 Function Key. It is for help

POV:
It triggers whenever user select F4 Function Key. It is for search help

Flow of Data in Module Pool Programming:

Transfer data from Screen to Program variables


Dialog
Screen Programming

Transfer data from Program Variables to Screen

Function Control Codes:


 It is also known as FCT codes
 Using FCT codes Function Codes can be controlled (or) identified in
Module Pool Programming
SY-UCOMM
Logic Logic

FCT FCT

Display Insert

Dialog Programming

SY-UCOMM:
It returns FCT value for a function key (button) in Dialog programming selected
by user

Steps:
1. Work with SE38 (create a Dialog Programming)
2. Work with SE51 (create a Screen)
3. Work with SE93 (create a T code)
4. Run the T code
Requirement:

2132
Kunnr

Land1

Name1

Ort01

Pstlz

stras

Display Clear Exit

Solution:
Step-1:
 Go to SE38
 Program: ZSD_CUSTOMER_DETAILS
 Create
 Title: Customer Details
 Type: Module Pool
 Enter
 Package: ZABAP
 Save
 Create Request
 Short Description: SD/ABAP: Customer Details (25.09.2019)
 Enter
 Enter

Step-2:
 Go to SE51
 Program: ZSD_CUSTOMER_DETAILS
 Screen Number: 100
 Create
 Short Description: Screen 100
 Layout button
 Place a box (last from 6th option) on the screen
Note:
Place the mouse pointer on the icon & click on it

 Bring mouse pointer on the screen & drag & drop it on the screen
according to requirement
 Double click on Frame of the box
 You will find an attributes pop-up
 Provide Text: Customer Details
 Close
 Select Dictionary Program Fields button (F6)
 You will find a pop-up
 Table Name: KNA1
 Enter
 You will find fields of the table
 Select Kunnr, Land1, Name1, Ort01, Pstlz, Stras
 Enter
 Place the fields with the help of mouse pointer on the box & right click
 Place 3 Push buttons (starting from 6th option) on Tool bar
 Double click on 1st Push button
 Text: Display
 FCT Code: Display
 Close
 Double click on 2nd Push button
 Text: Clear
 FCT Code: Clear
 Close
 Double click on 3rd Push button
 Text: Exit
 FCT Code: Exit
 Close
 Flow Logic button (F9)
 Remove comment for MODULE USER_COMMAND_100.
 Double click on USER_COMMAND_100
 You will find a pop-up Create Object: Yes
 By default New Include selected
 Select Main Program
 Enter
 Yes
TABLES: KNA1.

DATA: BEGIN OF wa_kna1,


Land1 TYPE land1,
Name1 TYPE name1,
Ort01 TYPE ort01,
Pstlz TYPE pstlz,
Stras TYPE stras,
END OF wa_kna1.

 Scroll down to bottom


 Place cursor between MODULE…………ENDMODULE of
USER_COMMAND_100.

CASE SY-UCOMM.
WHEN ‘Display’.
SELECT SINGLE land1 name1 ort01 pstlz stras INTO wa_kna1
FROM KNA1
WHERE kunnr EQ KNA1-kunnr.
WHEN ‘Clear’.
CLEAR: wa_kna1, KNA1-kunnr.
WHEN ‘Exit’.
LEAVE PROGRAM.
ENDCASE.

 Activate the program


 Back (F3)
 Remove comment for MODULE STATUS_100.
 Double click on STATUS_100
 Yes
 Main Program
 Enter
 Enter
 Place mouse pointer between MODULE…………ENDMODULE of
STATUS_100

KNA1-land1 = wa_kna1-land1.
KNA1-name1 = wa_kna1-name1.
KNA1-ort01 = wa_kna1-ort01.
KNA1-pstlz = wa_kna1-pstlz.
KNA1-stras = wa_kna1-stras.

 Activate the program


 Back (F3)
 Activate the screen
Step-3:
 Go to SE93
 Transaction Code: ZCUSTOMER
 Create
 Title: T code for Customer Details
 Enter
 Program: ZSD_CUSTOMER_DETAILS
 Screen Number: 100
 Save
 Enter
 Run the T code (ZCUSTOMER)

Brief Flow:
1. PBO (Screen is called)
2. PAI (This event will triggers whenever you select a Button)
3. PBO (This will carry the data from Program Variables i.e. wa_kna1-
kunnr = KNA1-kunnr to screen field)

Debugging a Module Pool Program:


 Go to SE38
 Program: ZSD_CUSTOMER_DETAILS
 Change
 Place cursor at WHEN ‘DISPLAY’.
 Select Stop
 Place cursor between MODULE………..ENDMODULE of
STATUS_100.
 Select Stop
 Run T code (ZCUSTOMER)
 Enter
Table Control:
Use table control for processing multiple records

Syntax for declaring Table Control:


CONTROLS <table control name> TYPE TABLEVIEW USING
SCREEN <screen no>

Object:
Truck Entry Screen

Vendor

DC DC Truck Gross Net Tare PO Vendor


Number Dat Number weigh Weight Weight Numbe number
e t r

Display Insert Update Reset Exit

Screen 100

Solution:
Step-1:
 Go to SE11
 Database Table: ZMM_DEMO
 Create
 Short Description: Truck Entry Table
 Delivery Class: A
 Table View Maintenance: Table View Maintained with Restrictions
 Fields
Field key Data Element
MANDT _/ MANDT
DCNO _/ ZDCNO
DCDATE _/ ZDC_DATE
TNO ZTNO
BRGEW BRGEW
TWT TWT
NTGEW NTGEW
EBELN EBELN
LIFNR LIFNR

 Currency Quantity Fields


Field Reference Table Reference Field
BRGEW EKPO MEINS
TWT EKPO MEINS
NTGEW EKPO MEINS

 Technical Settings
 Data Class: APPL1
 Size Category: 0
 Save
 Back (F3)
 Activate Table
 Yes

Step-2:
 Go to SE80
 Function Group: ZTCGR
 Enter
 Yes
 Short Text: Function Group for Truck Details
 Enter
 Local Object
 Under ZTCGR you will find INCLUDES, Expand it
 You will find 2 INCLUDES
 Double click on an include with TOP as suffix
 Select Display/Change option

TABLES: ZMM_DEMO1, LFA1.

CONTROLS: vcontrol   TYPE   TABLEVIEW   USING   SCREEN   '100'.
DATA: n   TYPE   I,
             wa_demo   TYPE   zmm_demo1,
             wa_demo2   TYPE   zmm_demo1,
             it_demo     TYPE   TABLE   OF   zmm_demo1.

 Activate
 Back (F3)
 Right click on ZTCGR function group
 Create
 Screen
 You will find a pop-up
 Program: SAPLZTCGR
 Screen Number: 100
 Enter
 Short Description: Screen 100
 Layout
 F6
 Table Name: LFA1
 Enter
 Select Lifnr
 Enter
 Place the field on top of the screen
 Place a Box on the screen
 Double click on box frame
 Text: Truck Entry
 Close
 Place Table Control (last from 4th option) on the box
 Double click on Table Control
 At bottom under Separators check Vertical & check Horizontal
 Close
 F6
 Table Name: wa_demo2
 Select all fields except MANDT
 Enter
 Place the fields on table contro
 Provide header text for each column of table control
 Place 5 push buttons under table control
 Provide Text & FCT code as per requirement
 Flow Logic

Step-3:
 Place cursor under PROCESS AFTER INPUT.
LOOP  AT it_demo.

  chain.
FIELD: wa_demo2-dcno,
     ZMM_demo-dcdate,
     ZMM_demo-tno,
     ZMM_demo-brgew,
     ZMM_demo-twt,
     ZMM_demo-ntgew,
     ZMM_demo-ebeln,
     ZMM_demo-lifnr.

endchain.

MODULE tab_modify."" on CHAIN-REQUEST.
ENDLOOP.
MODULE   USER_DML.
 MODULE USER_COMMAND_0100.

 Double click on tab_modify.


IF it_demo IS NOT INITIAL.
MODIFY it_demo FROM wa_demo2 INDEX vcontrol-current_line.

ELSE.
  append wa_demo2 to it_demo.
ENDIF.

 Place cursor under PROCESS BEFORE OUTPUT.


LOOP   AT   it_demo   INTO   wa_demo   WITH   CONTROL   vcontrol.
 MODULE STATUS_0100.
ENDLOOP.

 Double click on USER_DML


 Yes
 Enter
 Enter
 Yes

 Place cursor between MODULE………..ENDMODULE of USER_DML


MODULE user_dml INPUT.

CASE   SY-UCOMM.
WHEN   'INSERT'.
MODIFY   zmm_demo1   FROM   wa_demo2.
IF   SY-SUBRC   EQ   0.
MESSAGE   'Record Inserted'   TYPE   'S'.
ENDIF.

WHEN   'UPDATE'.
UPDATE   zmm_demo1   SET    brgew  =  wa_demo2-brgew
          twt     =  wa_demo2-twt
          ntgew  =  wa_demo2-ntgew
WHERE   dcno  =  wa_demo2-dcno.
IF   SY-SUBRC   EQ   0.
MESSAGE   'Record Updated'   TYPE   'S'.
ENDIF.

WHEN   'ENTER'.
wa_demo2-ntgew  =  wa_demo2-brgew  -  wa_demo2-twt.
ENDCASE.

ENDMODULE.  
 Activate
 Back (F3)

 Remove comment for MODULE USER_COMMAND_100.


 Double click on USER_COMMAND_100
 Yes
 Enter
 Enter
 Yes
 Place cursor between MODULE…………..ENDMODULE of
USER_COMMAND_100
MODULE user_command_0100 INPUT.
CASE   SY-UCOMM.
WHEN   'DISPLAY'.
  DATA:lv_lifnr TYPE lfa1-lifnr.

  lv_lifnr = lfa1-lifnr.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input         = lv_lifnr
   IMPORTING
     OUTPUT        = lv_lifnr
            .

  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.

SELECT   *   FROM   zmm_demo1   INTO   TABLE   it_demo   WHERE   lifnr  =  
lv_lifnr.

WHEN   'RESET'.
*REFRESH   it_demo.
clear:zmm_demo1.
WHEN   'EXIT'.
LEAVE   TO   SCREEN   0.
ENDCASE.

IF zmm_demo1 IS NOT INITIAL.
MODIFY   it_demo   FROM   zmm_demo1   INDEX   vcontrol-current_line.
IF   SY-SUBRC   NE   0.
APPEND   zmm_demo1   TO   it_demo.
ENDIF.
ENDIF.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

 Activate
 Back (F3)
 Remove comment for MODULE STATUS_100.
 Double click on STATUS_0100
 Yes
 Enter
 Enter
 Yes
  SET PF-STATUS 'ZQUICK'.
*  SET TITLEBAR 'xxx'.

MOVE   wa_demo-dcno      TO   wa_demo2-dcno.
MOVE   wa_demo-dcdate   TO   wa_demo2-dcdate.
MOVE   wa_demo-tno        TO   wa_demo2-tno.
MOVE   wa_demo-brgew   TO   wa_demo2-brgew.
MOVE   wa_demo-twt        TO   wa_demo2-twt.
MOVE   wa_demo-ntgew   TO   wa_demo2-ntgew.
MOVE   wa_demo-ebeln    TO   wa_demo2-ebeln.
MOVE   wa_demo-lifnr      TO   wa_demo2-lifnr.

DESCRIBE   TABLE   it_demo   LINES   n.
vcontrol-lines  =  n.  "" //---it activates vertical scroll bar

 Back (F3)
 Activate screen

 Right click on ZTCGR function group


 Activate
 Enter
 Right click on ZTCGR
 Create
 Transaction
 Transaction Code: ZTRUCK
 Short Text: Truck Entry
 ***Program: SAPLTCGR
 ***Screen Number: 100
 Save

 Run T code (ZTRUCK)

All Code:
PROCESS BEFORE OUTPUT.

LOOP   AT   it_demo   INTO   wa_demo   WITH   CONTROL   vcontrol.
 MODULE STATUS_0100.
ENDLOOP.

*
PROCESS AFTER INPUT.

LOOP  AT it_demo.

  chain.
FIELD: wa_demo2-dcno,
     wa_demo2-dcdate,
     wa_demo2-tno,
     wa_demo2-brgew,
     wa_demo2-twt,
     wa_demo2-ntgew,
     wa_demo2-ebeln,
     wa_demo2-lifnr.

endchain.

MODULE tab_modiy."" on CHAIN-REQUEST.
ENDLOOP.

MODULE   USER_DML.
 MODULE USER_COMMAND_0100.

Ques-1: Suppose in table control when I entered few records then I selected
‘Enter’ option, I found that the records are completely vanished from table
control. Why it happens & What logic you will write to avoid problem?
Ans:
 When you select ‘Enter’ control will moves from screen to program
 In program there is no logic provided for storing the table control data in
internal table
 So nothing is transferred back to table control screen
 So it looks like empty
Logic:
IF it_demo IS NOT INITIAL.
MODIFY it_demo FROM wa_demo2 INDEX vcontrol-current_line.

ELSE.
  append wa_demo2 to it_demo.
ENDIF.

CHAIN Keyword:
 By default standard application allows screen level validations
 If you want to perform field level validations you should write logic
explicitly using CHAIN……..ENDCHAIN

You might also like