In the below example we will create a simple Module Pool Program to display hello world.
Go to SE80, select program from drop down, provide name as ZSAPN_HELLO_WORLD and press enter.
A pop up will open click Yes.
Provide a program name ZSAPN_HELLO_WORLD (same name as given above), select create with top include check box and enter.
Provide a top include name, enter.
Click Save on the pop up window.
Save it in a local object.
Go to change mode, double click on program name, uncomment all include programs, double click on each include and create (TIP- Just double click on each include enter, enter, save in local object, save, back(F3)) .Now to double click on program name, right click , activate.
Right click on program name, create, screen.
Provide Screen number as (0100), enter.
Provide short description and click on flow logic tab.
Uncomment the available MODULES, double click to create them.
Double click on MODULE STATUS_0100,yes, select main include and enter.
Save, click back (F3) and create another module.
Click on Layout ( toolbar button), it will open Module Pool layout designer (If you are using it first time it might take some time...If you failed to open layout it might be due to some missing configuration, at that time contact basis/admin).
The layout will be like below, drag and drop Text Field element on to screen area.
Provide name and text.
Save, close windows, go to flow logic, double click on each module and add below code.
Double click on menu name and title to create GUI status for the program...checkout creating a custom menu in SAP to create menu.
Double click on program name, right click, activate.
To execute a module pool program we need to create a t-code, to create a t-code right click on program name, create, transaction.
Provide a T-code name, short text and enter.
Provide program name, screen number, save.
Now T-code is created, execute the T-code and test.