Module Pool Programming From Scratch - SAP Blogs
Module Pool Programming From Scratch - SAP Blogs
Community
Technical Articles
Sinela Anwar
June 17, 2022 | 3 minute read
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 1/11
12/20/22, 1:40 PM Module Pool Programming from scratch | SAP Blogs
First create a new report in SE80 with top include and give the type Module pool as
given below.
Create Transaction
Right click on report then create transaction then enter program name and screen
name and then assign to package.
Create Screen
Now Screen Painter will open. Here you can design your screen.
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 2/11
12/20/22, 1:40 PM Module Pool Programming from scratch | SAP Blogs
Step 3: Enter the name of table in and click on “Get from Dictionary” and select the
fields you want to display.
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 3/11
12/20/22, 1:40 PM Module Pool Programming from scratch | SAP Blogs
Step 5: Now create a button by clicking on the “Push Button” on the left toolbox and
placing it on the screen wherever you want. Now double click on the button, a pop-up
will come out, enter the name of the button there and mention the function code “Fct
Code” this code will be used in user command. Now save and activate the screen.
Step 6: Now go to the “Flow Logic” tab and uncomment the PBO and PAI modules
respectively.
Then double click on both the Modules and create them in the Main Program.
Step 7: Now write code in user command for both the push buttons using function
code as given below
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 4/11
12/20/22, 1:40 PM Module Pool Programming from scratch | SAP Blogs
CASE SY-UCOMM.
WHEN 'FC_1'.
SELECT
SINGLE
MATNR
ERSDA
CREATED_AT_TIME
ERNAM
MTART
MATKL
FROM MARA INTO CORRESPONDING FIELDS OF MARA WHERE MATNR = MARA-M
WHEN 'FC2'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
*&-------------------------------------------------------------------
*& Module Pool Z1015035_MPP_MARA_
*&-------------------------------------------------------------------
*&
*&-------------------------------------------------------------------
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 5/11
12/20/22, 1:40 PM Module Pool Programming from scratch | SAP Blogs
*--------------------------------------------------------------------
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'FC_1'.
PERFORM GET_DATA.
WHEN 'FC2'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
---INCLUDE----
*&-------------------------------------------------------------------
*& Include ZMARATOP - Module Pool
*&-------------------------------------------------------------------
PROGRAM Z1015035_MPP_MARA_.
TABLES: MARA.
*&-------------------------------------------------------------------
*& Form GET_DATA
*&-------------------------------------------------------------------
*& text
*&-------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
*&-------------------------------------------------------------------
FORM GET_DATA .
SELECT
SINGLE
MATNR
ERSDA
CREATED_AT_TIME
ERNAM
MTART
MATKL
FROM MARA INTO CORRESPONDING FIELDS OF MARA WHERE MATNR = MARA-MAT
ENDFORM.
Output
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 6/11
12/20/22, 1:40 PM Module Pool Programming from scratch | SAP Blogs
By following the steps you will be able to create basic Module Pool Program. I hope
this blog post helped you as beginner.
As we continue to learn more in this series about MPP, I will use this blog post to link
all the parts of this series.
Follow my account Sinela Anwar to be notified of the next blog post. Please feel free
to ask any questions you have in the comments section below.
Join the conversation about the ABAP programming by following the tag ABAP
Development
Post questions and answer related to tag by following the tag Questions & Answers
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 7/11
12/20/22, 1:40 PM Module Pool Programming from scratch | SAP Blogs
Alert Moderator
Assigned Tags
ABAP Development
Related Questions
module pool
By Former Member Jul 19, 2007
5 Comments
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 8/11
12/20/22, 1:40 PM Module Pool Programming from scratch | SAP Blogs
Lars Hvam
June 17, 2022 at 8:26 pm
Thanks for sharing, even though dynpros are old technology, it is is still relevant for many customers
Like 4 | Share
Juan Suros
June 17, 2022 at 9:34 pm
I hope SAP remembers that they did not grow to their current size by offering cloud and phone apps, before
they become the General Motors of the ERP world.
Like 2 | Share
Sandra Rossi
June 18, 2022 at 7:13 am
Dynpros can be used not only with Module Pools, but also with Executable programs ("reports") and Function
Pools/Groups, so "Module Pool Programming" is a too restrictive term. A module pool is to be used when you
want to dedicate a program to only handle screens (and I would use ABAP Classes for the model and
controller parts).
Although it's still used a lot, I agree that it's deprecated technology (replaced by Fiori App) and that you should
inform at the beginning of the blog post.
I never use LEAVE PROGRAM, it's too excessive and to be reserved to special cases (like LEAVE
TRANSACTION and LEAVE TO TRANSACTION), instead I'd use SET SCREEN 0 to leave the screen and return
after the CALL SCREEN. It will help people when they use several screens. NB: it will not change anything in
your example.
You should not define subroutines in the TOP include, better create a dedicated include for forms.
Note that subroutines are officially obsolete since 7.02, it was 13 years ago. Use methods instead. I would also
mention that in the blog post.
Like 5 | Share
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 9/11
12/20/22, 1:40 PM Module Pool Programming from scratch | SAP Blogs
Paul Hardy
June 21, 2022 at 8:33 am
Now I would have to agree that there are so many existing ABAP programs using DYNPRO screens and the
good old PBO/PAI modules to do all the business logic. Moreover I have no doubt dozens of new ones are
being created every single day all throughout the world in SAP systems.
Nonetheless that does not change the fact that putting business logic in PBO/PAI modules became obsolete
in the year 2000.with the advent of SAP 4.6 when ABAP OBJECTS was introduced.
Unlike Java there is no equivalent of SWING in the SAP GUI. The workaround - in 2000 and to this day - is to
have as little business logic as possible (preferably none at all) in the PBO/PAI modules.
Methods cannot call screens and so you need a function module to actually bring the screen up and that
function module has the screen definition within it. But really that function module should have no "smarts" at
all - the controller class gets the current data from the model and calls the view class which calls the function
module.
The function module then does nothing except return what command the user chose or what data the user
changed on the screen.
That might sound horrificly complicated compared to what you can do with PBO/PAI but that is the way to
apply the "separation of concerns" or the MVC pattern. Many people (including me circa 2012) thought all this
OO stuff was nonsense and people were only being pushed to do this because it was "cool" and that is what
other languages did.
As it turns out there are valid reasons why the traditional module pool approach of having business logic all
mixed up with the UI was declared obsolete 22 years ago. One reason I can think of straight off is I could web
enable my programs because none of the business logic was in the GUI.
Like 0 | Share
Paul Hardy
June 21, 2022 at 8:41 am
And yes - the extended program check would warn you against putting routines in the TOP INCLUDE. That is
not what the TOP INCLUDE is for. So do not do that ever and never tell beginners to do it.
And as I said on another blog I really am unhappy with telling beginners to use FORM routines. Once they start
they will never stop.
Like 2 | Share
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 10/11
12/20/22, 1:40 PM Module Pool Programming from scratch | SAP Blogs
Find us on
Newsletter Support
https://blogs.sap.com/2022/06/17/module-pool-programming-from-scratch/ 11/11