12
SAP ABAP WEDNESDAY, 30 MAY 2012 MODULE POOL SIMPLE PROGRAM ON MODULE POOL Scenario : Here we would design a single screen(9000) with two i/p fields & one o/p field. Upon entering the values in the i/p field, if the user clicks on the add button then the sum will be displayed in the o/p field. Step-1. Go to SE80. Choose Program And Give a Name ( zmp_test1 ) and press Enter. Step-2. Choose Yes . Step -3. Uncheck the check box and Click Yes button. Step-4. Select Module Pool From the Type and Click on Save button. Step-5. Click on Local Object To save it local package ($TMP). Step-6. Double Click on Program Name & Click on Change Button. Siva Prasa View my compl ABOUT ME 2013 (43) 2012 (14) June (1) May (7) MODULE POOL EXCEPTION HANDLIN OOABAP PROGRAM FIELD SYMBOLS ALV REPORTS INTERACTIVE REPOR CLASSICAL REPORT PROGRAMS April (6) BLOG ARCHIVE MODULE POOL OO ALV WITH CONTAINERS INTERACTIVE REPORTS CLASSICAL REPORT PROGRAMS EXCEPTION HANDLING ABAP AND SAP MEMORY ALV REPORTS FIELD SYMBOLS ABAP System Variables Creation of Table Control in Module Pool Program POPULAR POSTS Más Siguiente blog» Crear

Sap Abap _ Module Pool

Embed Size (px)

Citation preview

Page 1: Sap Abap _ Module Pool

SAP ABAP

WEDNESDAY, 30 MAY 2012

MODULE POOL

SIMPLE PROGRAM ON MODULE POOL

Scenario : Here we would design a single screen(9000) with two i/p fields & one o/p field. Upon

entering the values in the i/p field, if the user clicks on the add button then the sum will be

displayed in the o/p field.

Step-1. Go to SE80. Choose Program And Give a Name ( zmp_test1 ) and press Enter.

Step-2. Choose Yes .

Step -3. Uncheck the

check box and Click

Yes button.

Step-4. Select Module

Pool From the Type

and Click on Save

button.

Step-5. Click on Local Object To save it local package ($TMP).

Step-6. Double Click on Program Name & Click on Change Button.

Siva Prasad Jena

View my complete profile

ABOUT ME

► 2013 (43)

▼ 2012 (14)

► June (1)

▼ May (7)

MODULE POOL

EXCEPTION HANDLING

OOABAP PROGRAMS

FIELD SYMBOLS

ALV REPORTS

INTERACTIVE REPORTS

CLASSICAL REPORTPROGRAMS

► April (6)

BLOG ARCHIVE

MODULE POOL

OO

ALV WITHCONTAINERS

INTERACTIVEREPORTS

CLASSICALREPORTPROGRAMS

EXCEPTIONHANDLING

ABAP AND SAPMEMORY

ALV REPORTS

FIELDSYMBOLS

ABAP SystemVariables

Creation ofTable Control inModule PoolProgram

POPULARPOSTS

Más Siguiente blog» Crear un blog

Page 2: Sap Abap _ Module Pool

Step-7. Create A

screen - right click

on Program Name -

>Create->Screen

Step-8. Give Screen

number - 9000 & click

on Yes Button.

Step-9. Give a short

Description & It's a

normal Screen.

Step-10. Click on

layout Button & the

Screen Painter Window

will appear .

Step-11. Create two

input fields , one

push button & an

output field & at

last click on flow

logic button on the

toolbar.

MODULE POOL

OO

ALV WITHCONTAINERS

INTERACTIVEREPORTS

CLASSICALREPORTPROGRAMS

EXCEPTIONHANDLING

ABAP AND SAPMEMORY

ALV REPORTS

FIELDSYMBOLS

ABAP SystemVariables

Creation ofTable Control inModule PoolProgram

POPULARPOSTS

Page 3: Sap Abap _ Module Pool

PROGRAM zmp_test1.

DATA : num1 TYPE i,

num2 TYPE i,

res TYPE i.

MODULE status_9000 OUTPUT.

SET PF-STATUS 'STATUS'.

* SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_9000 OUTPUT

MODULE user_command_9000 INPUT.

CASE sy-ucomm.

WHEN 'SHOW'.

res = num1 + num2.

WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

Step-12. Now uncomment the two modules in PBO & PAI . Double click on the module name and create it in

main program.

Step-13. Write the

code in the program.

Step-14. Uncomment the SET PF-STATUS 'XXXX' line and give any name(STATUS) & double click on it to

create it. From the popup click on yes .

Step-15. Give A

short text and Click

on yes button.

Step-16. Click on the (+) Button on the right of Function keys to expand it. Give SAVE, BACK, EXIT &

CANCEL in the standard toolbar & activate it and press back button to come back to the program.

Page 4: Sap Abap _ Module Pool

data : N1 type i.

data : N2 type i.

data : ok_code type sy-ucomm.

module STATUS_9000 output.

* SET PF-STATUS 'xxxxxxxx'.

* SET TITLEBAR 'xxx'.

Step-17. Now create a transaction code for the program. Right click on program name->create-

>transaction.

Step-18. Give a T-

code, short

description and click

yes button.

Step-19. Give program name , screen number and click on the three check boxes and then click on save

button on the standard toolbar. Click on back button to come the program.

Step-20. Now open a new session and put the T-code of the program in the Command field and press

Enter.

Step-21. Fill the two input field with some values and then press ADD button. Find the Result.

PROGRAM DEMONSTRATING (ON INPUT)

Page 5: Sap Abap _ Module Pool

endmodule. " STATUS_9000 OUTPUT

module USER_COMMAND_9000 input.

CASE OK_CODE.

WHEN 'SHOW'.

CALL SCREEN 9001.

ENDCASE.

endmodule. " USER_COMMAND_9000 INPUT

module STATUS_9001 output.

* SET PF-STATUS 'xxxxxxxx'.

* SET TITLEBAR 'xxx'.

N2 = N1.

endmodule. " STATUS_9001 OUTPUT

module USER_COMMAND_9001 input.

CASE OK_CODE.

WHEN 'BACK'.

CALL SCREEN 9000.

ENDCASE.

endmodule. " USER_COMMAND_9001 INPUT

module CHECK_N1 input.

N1 = N1 + 10.

endmodule. " CHECK_M1 INPUT

FLOW LOGIC OF SCREEN 9000

PROCESS BEFORE OUTPUT.

MODULE STATUS_9000.

PROCESS AFTER INPUT.

FIELD N1 MODULE CHECK_N1 ON INPUT.

MODULE USER_COMMAND_9000.

FLOW LOGIC OF SCREEN 9001

PROCESS BEFORE OUTPUT.

MODULE STATUS_9001.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_9001.

Page 6: Sap Abap _ Module Pool

data : N1 type i.

data : N2 type i.

data : ok_code type sy-ucomm.

module STATUS_9000 output.

* SET PF-STATUS 'xxxxxxxx'.

* SET TITLEBAR 'xxx'.

endmodule. " STATUS_9000 OUTPUT

module USER_COMMAND_9000 input.

CASE OK_CODE.

WHEN 'SHOW'.

CALL SCREEN 9001.

ENDCASE.

endmodule. " USER_COMMAND_9000 INPUT

module STATUS_9001 output.

* SET PF-STATUS 'xxxxxxxx'.

* SET TITLEBAR 'xxx'.

N2 = N1.

endmodule. " STATUS_9001 OUTPUT

module USER_COMMAND_9001 input.

CASE OK_CODE.

WHEN 'BACK'.

CALL SCREEN 9000.

ENDCASE.

endmodule. " USER_COMMAND_9001 INPUT

module CHECK_N1 input.

N1 = N1 + 20.

endmodule. " CKECK_N1 INPUT

FLOW LOGIC OF SCREEN 9000

PROCESS BEFORE OUTPUT.

MODULE STATUS_9000.

*

PROCESS AFTER INPUT.

field N1 MODULE CHECK_N1 on REQUEST.

MODULE USER_COMMAND_9000.

FLOW LOGIC OF SCREEN 9001

PROCESS BEFORE OUTPUT.

MODULE STATUS_9001.

*

PROCESS AFTER INPUT.

MODULE USER_COMMAND_9001.

DATA : N1 TYPE i.

DATA : N2 TYPE i.

DATA : N3 TYPE i.

DATA : res TYPE i.

DATA : ok_code TYPE sy-ucomm.

MODULE status_9000 OUTPUT.

* SET PF-STATUS 'xxxxxxxx'.

* SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_9000 OUTPUT

MODULE user_command_9000 INPUT.

CASE ok_code.

WHEN 'ADD'.

CALL SCREEN 9001.

Run the program and if you give any value to the input field (n1) then only CHECK_N1 module will

execute . press SHOW & BACK button many times to see the change. If it finds any value in the input

field (n1) then every time CHECK_N1 module will execute and it will add up 10 to its value.

PROGRAM DEMONSTRATING (ON REQUEST)

Run the program and if you give any value to the input field (n1) then only CHECK_N1 module will

execute . press SHOW & BACK button many times to see the change.

PROGRAM DEMONSTRATING (ON CHAIN-INPUT)

Page 7: Sap Abap _ Module Pool

ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

MODULE status_9001 OUTPUT.

* SET PF-STATUS 'xxxxxxxx'.

* SET TITLEBAR 'xxx'.

res = N1 + N2 + N3.

ENDMODULE. " STATUS_9001 OUTPUT

MODULE user_command_9001 INPUT.

CASE ok_code.

WHEN 'BACK'.

CALL SCREEN 9000.

ENDCASE.

ENDMODULE. " USER_COMMAND_9001 INPUT

module CHECK_TWO_NUMBER input.

N1 = N1 + 10.

N2 = N2 + 10.

endmodule. " CKECK_THREE_NUMBER INPUT

FLOW LOGIC OF SCREEN 9000

PROCESS BEFORE OUTPUT.

MODULE status_9000.

PROCESS AFTER INPUT.

CHAIN.

FIELD : N1,N2.

MODULE CHECK_TWO_NUMBER ON CHAIN-INPUT.

ENDCHAIN.

MODULE user_command_9000.

FLOW LOGIC OF SCREEN 9001

PROCESS BEFORE OUTPUT.

MODULE STATUS_9001.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_9001.

Page 8: Sap Abap _ Module Pool

DATA : N1 TYPE i.

DATA : N2 TYPE i.

DATA : N3 TYPE i.

DATA : res TYPE i.

DATA : ok_code TYPE sy-ucomm.

MODULE status_9000 OUTPUT.

* SET PF-STATUS 'xxxxxxxx'.

* SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_9000 OUTPUT

MODULE user_command_9000 INPUT.

CASE ok_code.

WHEN 'ADD'.

CALL SCREEN 9001.

ENDCASE.

ENDMODULE. " USER_COMMAND_9000 INPUT

MODULE status_9001 OUTPUT.

* SET PF-STATUS 'xxxxxxxx'.

* SET TITLEBAR 'xxx'.

res = N1 + N2 + N3.

ENDMODULE. " STATUS_9001 OUTPUT

MODULE user_command_9001 INPUT.

CASE ok_code.

WHEN 'BACK'.

CALL SCREEN 9000.

ENDCASE.

ENDMODULE. " USER_COMMAND_9001 INPUT

module CHECK_TWO_NUMBER input.

N1 = N1 + 10.

N2 = N2 + 10.

endmodule. " CKECK_TWO_NUMBER INPUT

FLOW LOGIC OF SCREEN 9000

PROCESS BEFORE OUTPUT.

MODULE status_9000.

PROCESS AFTER INPUT.

CHAIN.

FIELD : N1,N2.

MODULE CHECK_TWO_NUMBER ON CHAIN-REQUEST.

ENDCHAIN.

MODULE user_command_9000.

FLOW LOGIC OF SCREEN 9001

PROCESS BEFORE OUTPUT.

MODULE STATUS_9001.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_9001.

Scenario : Generally if a screen contains any obligatory(Required) input field & we execute the MP

Run the program and if you provide any value to either n1 or n2 or both then only CHECK_TWO_NUMBER

module will execute . press ADD & BACK button many times to see the change.

PROGRAM DEMONSTRATING (ON CHAIN-REQUEST)

Run the program and if you provide any value to either n1 or n2 or both then only CHECK_TWO_NUMBER

module will execute . press ADD & BACK button many times to see the change.

PROGRAM DEMONSTRATING (AT EXIT-COMMAND)

Page 9: Sap Abap _ Module Pool

program , the screen appears & if we want to come out of the program it will not allow us . We have to

fill the mandatory field on the screen and then we can come out of the program by clicking on the

application tool bar buttons. To overcome this problem , generally we use AT EXIT-COMMAND at PAI of the

screen to force exit from the screen that contains a required field without filling any value to it.

Here we have two screens 9000 and 9001. In the 9000 screen we have an required i/p field & a single

record is displayed on 9001 screen based on the i/p.

******** program on at exit-command *************

data : p_carr type spfli-carrid,

wa_spfli type spfli,

ok_code type sy-ucomm.

module STATUS_9000 output.

SET PF-STATUS 'STATUS'. " DOUBLE CLICK ON 'STATUS' TO CREATE IT

* SET TITLEBAR 'xxx'.

endmodule. " STATUS_9000 OUTPUT

module FORCE_EXIT input.

CASE OK_CODE.

WHEN 'EXIT' OR 'CANCEL'.

LEAVE PROGRAM.

ENDCASE.

endmodule. " FORCE_EXIT INPUT

module USER_COMMAND_9000 input.

case ok_code.

WHEN 'DISP'.

CALL SCREEN 9001.

WHEN 'BACK'.

LEAVE PROGRAM.

endcase.

endmodule. " USER_COMMAND_9000 INPUT

module STATUS_9001 output.

* SET PF-STATUS 'xxxxxxxx'.

* SET TITLEBAR 'xxx'.

SELECT SINGLE * FROM SPFLI INTO WA_SPFLI WHERE CARRID = P_CARR.

endmodule. " STATUS_9001 OUTPUT

module USER_COMMAND_9001 input.

case ok_code.

when 'BACK'.

LEAVE TO SCREEN 0.

endcase.

endmodule. " USER_COMMAND_9001 INPUT

TO CREATE PF STATUS

STEP-1 : Double click on 'STATUS' to create pf status and click on yes button.

STEP-2: Give a short description.

Page 10: Sap Abap _ Module Pool

STEP-3: Click on the '+' button of the Function key & fill values 'BACK', 'EXIT' & 'CANCEL'.

STEP-4: Double click on 'EXIT' & the following screen will appear. Click of the value help of theFunction Type field and choose

the first entry. 'E' type.

STEP-5 : Click yes to set 'E' for the EXIT and also set 'E' type also for 'CANCEL'

FLOW LOGIC OF SCREEN 9000

PROCESS BEFORE OUTPUT.

MODULE status_9000.

PROCESS AFTER INPUT.

MODULE force_exit AT EXIT-COMMAND.

MODULE user_command_9000.

Page 11: Sap Abap _ Module Pool

Posted by Siva Prasad Jena at 10:49

FLOW LOGIC OF SCREEN 9001

PROCESS BEFORE OUTPUT.

MODULE STATUS_9001.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_9001.

OUTPUT:

+1 Recommend this on Google

Replies

Reply

4 comments:

alex linh 23 December 2012 02:25

How to create a status bar in module pool /user dialog abapprogramming, you could check this link

http://saptechnicals.blogspot.com/2012/12/module-pool-programming-create-gui.html

Reply

Hugo Omar Rodriguez 9 October 2013 08:45

GREAT JOB. !!!

Reply

vidya sagar 30 October 2013 00:47

how to create radio buttons in module pool program

Reply

Siva Prasad Jena 30 October 2013 05:27

Create a variable like data: rb1 type c. and take it to the module pool screen. Then

right click on the element on the screen to convertt it to a radio button or check box

and follow the path: Transform-Radiobutton-Left button/Right button.

Page 12: Sap Abap _ Module Pool

Newer Post Older PostHome

Subscribe to: Post Comments (Atom)

Enter your comment...

Comment as: Google Account

Publish

Preview

1. Simple ABAP Programs

DOCUMENT CATAGORIES :

Picture Window template. Template images by Zemdega. Powered by Blogger.