0% found this document useful (0 votes)
223 views72 pages

Modulepool - Dialog Programing

This document provides an overview of module pool (also known as ABAP transactions) programming and screen flow logic in SAP. It discusses the transaction code for creating module pool programs, key events in module pool programming like PBO, PAI, POV and POH. It also covers modularization techniques and components of screens like attributes, element list and flow logic. The document contains an example requirement to design a screen to display material details using forms and buttons.

Uploaded by

SUDHARSANA S
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
223 views72 pages

Modulepool - Dialog Programing

This document provides an overview of module pool (also known as ABAP transactions) programming and screen flow logic in SAP. It discusses the transaction code for creating module pool programs, key events in module pool programming like PBO, PAI, POV and POH. It also covers modularization techniques and components of screens like attributes, element list and flow logic. The document contains an example requirement to design a screen to display material details using forms and buttons.

Uploaded by

SUDHARSANA S
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 72

Introduction to module pool (Dnipros or ABAP Transactions) programming and

screen, flow logic in module pool programs

It is a special type of programming which is used to create custom SAP screens.


Transaction code for creating module pool programs is SE80.
Dynpros programming is Dialog programming, dialog programming is to extract data and even to
manipulate data.
Program type is : Module pool
Every module pool program must be executed with a transaction (T-code).

Events in Module pool programming


There are four events available in module pool programming.
PBO (Process Before Output):Triggered before MPP screen is displayed.
PAI (Process After Input): Triggered after MPP screen is displayed whenever user raises an
action. Now PBO is also triggered.
POV (Process On Value Request): Triggered when User Clicks on search help or F4 Button.
POH (Process On Help Request): Triggered when User Clicks on help or F1 Button.

Modularization techniques in Module Pool


Basically there are four include programs which are created automatically for an MPP program.

_TOP "top include program ,All data declarations.


_O01 "PBO include program , All logic related to PBO event
_I01 "PAI include program , All logic related to PAI event
_F01 "Forms include program , All logic related to subroutines

SCREEN
It is a visible layout which is displayed in the output. The components of the Screen are
Components of Screen:

 Attributes : Properties of screen


 Element List : List of UI/Library elements (fields)
 Flow-Logic : Abap logic related to MPP
 Layout : Screen Designing Area

Flow Logic in module pool


It will contain the logic related to screen in the form of modules by default, 2 events will be available
with their corresponding modules as below: Just uncomment the modules and create them and write
the abap logic. Flow logic by default have PBO and PAI based on these two events can maintain
communication.

PROCESS BEFORE OUTPUT.


*MODULE STATUS_0100.
PROCESS AFTER INPUT.
*MODULE USER_COMMAND_0100.

MODULE:

 It is an sub-program which contains the ABAP code for a screen .


 Flow-Logic cannot understand ABAP statements. So the entire ABAP code is written in the
form of modules.
 Since the entire abap logic is divided in the form of modules, that is why it is called MODULE
POOL PROGRAMMING

FCT codes in ABAP Transaction: FCT means Function Control codes


With FCT code functionality system variable SY-UCOMM can control dialog programming.
Transaction codes to work with Dynpros are
SE38 -> ABAP Editor to create Module pool
SE51 -> Screen Painter it’s have Layout Flow logic
Layout is to design Application in screen painter. Flow logic by default have PBO and PAI
SE93 -> to Create transaction code for Application.
In Real time we work with tcode SE80 instead of above 3 tcodes.

Requirement: design the below screen and write the logic for buttons.

Goto se80 select program and provide name as : ZDIALOG_PROG

Click Enter and click Yes


Remove tick in check box , Enter
Save it in a local object.
Select Program name, Right click on program name, create, screen.
Provide screen number to design application : 100

Maintain description to application: Application based on without internal table


SAVE
Click on screen number, select Layout
Select goto -> secondary window -> Dictionary program fields
Provide table KNA1
Select fields KUNNR, NAME1, LAND1
Enter
Drop it in Layout area
From tool box select Push Button, drop it in layout area
Click on push button to maintain properties
In properties enter name i.e. INSERT , enter text i.e. Insert , enter FCT code i.e. INSERT
Close properties
Repeat same procedure for UPDATE, DELETE, DISPLAY and EXIT.
SAVE screen design and Active
(Now Logic should maintain in ModulePool)
From screen painter select Flow Logic
From Flow Logic select PAI, from that select its module, remove comment and SAVE
(We took PAI because operations are done after screen displays)
Select PAI module , double click on that.
Select Main Program, Enter
TABLES : KNA1.
Write below logic inside of Module ….. End Module of PAI.
MODULE USER_COMMAND_0100 INPUT.
case sy-ucomm.
  when 'INSERT'.
    insert kna1.
  when 'UPDATE'.
    update kna1.
  when 'DELETE'.
    delete kna1.
  when 'DISPLAY'.
    select * from kna1 where kunnr = kna1-kunnr.
      endselect.
  when 'EXIT'.
    leave program.
endcase.
ENDMODULE.        

Leave program is sap keyword which can move control out of application.
SAVE and ACTIVATE go BACK and ACTIVATE
Select the program name, right click create -> Transaction
Use Tcode

Check the actions in KNA1 Table.

Same as Above Requirement but with Internal Table


Goto se80 select program and provide name as : ZDIALOG_PROG1
Click Enter and click Yes
Remove tick in check box , Enter
Save it in a local object.
Select Program name, Right click on program name, create, screen.
Provide screen number to design application: 100
Maintain description to application: Application based on with internal table
SAVE
Click on screen number, from screen painter select Layout

Select goto -> secondary window -> Dictionary program fields


Provide table KNA1
Select fields KUNNR, NAME1, LAND1
Enter
Drop it in Layout area
From tool box select Push Button, drop it in layout area
Click on push button to maintain properties
In properties enter name i.e. DISPLAY , enter text i.e. Display , enter FCT code i.e. DISPLAY
Close properties
Repeat same procedure for EXIT.
SAVE screen design and Active
(Now Logic should maintain in Module Pool)
From screen painter select Flow Logic
From Flow Logic select PAI, from that select its module, remove comment and SAVE
(We took PAI because operations are done after screen displays)
Select PAI module , double click on that.
Select Main Program, Enter
TABLES : KNA1.
Types : Begin of TY_KNA1,
KUNNR type KUNNR,
NAME1 type NAME1_GP,
LAND1 type LAND1_GP,
End of TY_KNA1.
DATA: wa_kna1 type ty_kna1,
I_kna1 type table of ty_kna1.
Write below logic inside of Module ….. End Module of PAI.
MODULE USER_COMMAND_0100 INPUT.
case sy-ucomm.
  when 'DISPLAY'.
    select kunnr name1 land1 from kna1 into table I_kna1
where kunnr = kna1-kunnr.
  when 'EXIT'.
    leave program.
endcase.
ENDMODULE.        

SAVE and ACTIVATE. Go BACK


Select PBO, select its module , remove comment. SAVE
Double click on that module, Select Main Program
Write below logic inside of Module ….. End Module of PBO to transfer data from Body to screen via
work area.
IF NOT I_KNA1 IS INITIAL.
LOOP AT I_KNA1 INTO WA_KNA1.
MOVE-CORRESPONDING WA_KNA1 TO KNA1.
ENDLOOP.
ENDIF.
SAVE & ACTIVATE. Go BACK (F3)
Select the program name, right click create -> Transaction
Provide Transaction code : ZMPPIN and Description: Transaction for Zdialog_prog1
Select radio button : Program and screen (dialog transaction)

Use Tcode:
Check the actions in KNA1 Table.

Note: Flow logic Sequence: - PBO triggered, screen displayed. After screen displayed, customer
number entered and perform Display. With this PAI triggered. So that data kept in body. Then PBO
triggered and screen refreshed. Then from body data transfers to screen via work area.
Flow Logic sequence is PBO + PAI + PBO

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 ZSAP_HELLO_WORLD and press
enter.

A pop up will open click Yes.


Provide a program name ZSAP_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.


Double click on program name, Go to change mode, 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 and do same as above.

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 MENU100 to create menu. Activate

Double click on TITLE01 to create title GUI status for the program.

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. ZMPP

Example module pool program to display material details, module pool program
using form and button

Requirement: Display material details for a material input by designing a module pool screen.
Go to SE80, select program from drop down, provide name and press enter.

A popup will come just click yes.


Check 'Create with TOP module' and enter.

Provide a top include name and enter.

Select module pool and save.

Expand program, double click on top include and add below code.
Right click on program name, create -> screen.

Provide a screen number and enter.

Provide short description and click on layout.


Activate the Module Pool Program
Module Pool layout designer will open, click on 'Dictionary/Program fields icon' (see below image), a
popup will open, provide name as WA_MARA, click on 'Get from program', select all rows and enter.

Move mouse cursor on layout and place the form in suitable position.
Now click on text icon, put it before any input field and enter text.

Similarly create labels for all fields.


Insert button, provide text as 'Get Data', double click, provide a name , fct code, enter and close.
Save and Activate.

Close the layout and go to program and click on flow logic.


uncomment modules.
Double click on each module and create them in main program.

After creating two modules, go to PAI and add below code.

IF SY-UCOMM = 'GETM' .
SELECT SINGLE * FROM MARA INTO CORRESPONDING FIELDS OF WA_MARA
WHERE MATNR = WA_MARA-MATNR.
ENDIF.

Right click on program, create -> transaction.


Provide transaction code as ZSAP_MAT, provide short text and enter.
Provide program name as ZSAP_MPP_MATERIAL, screen no as 100 and save in a local object.
Now go to t-code ZSAP_MAT, provide a material no and click on get data button, it will get output.
SUB SCREEN Concept in ABAP Transactions.
Application can be design with three screens

Such sub screens are for Reusability. User can reuse sub screens with in application and even
across applications. Here 120 screen is sub screen because it calls 100 and 110 screens.
Sub Screen area is a part of Normal screen. sub screen can be displayed in sub screen area.
Sub screen Logic: CALL SUBSCREEN <sub screen area name> INCLUDING <module pool
program name> <sub screen number>
With this syntax sub screen can be displayed in normal screen.
Every screen have separate PBO and PAI that is Flow Logic.

Requirement is as below:

Flow logic sequence: - Normal screen triggered, with that call sub screen logic executed. So
that normal screen can display along with sub screen. After display customer entered then
Display perform with this normal screen PAI triggered, then data kept in body. Finally sub
screen PBO triggers, then sub screen can be refreshed. Later data transfers from body to sub
screen fields via work area.
Select SE80, provide module pool program name: ZDLG_SUBSCREEN
Provide screen No: 100
Select ‘create’ to switch over to screen painter
Maintain description: Normal screen to sub screen application
SAVE
Select LAYOUT from screen painter. Go to -> secondary window -> dictionary program fields
Select only customer field and provide customer field in layout (kna1 -> kunnr)
From tool box select ‘sub screen area’ to maintain properties
Properties means name only i.e. SUB (we can take any name)
Maintain DISPLAY and EXIT operations by using Push Button.
SAVE and ACTIVE normal screen design
Select SE80, provide module pool program name: ZDLG_SUBSCREEN
Provide screen No: 120
Select ‘create’ to switch over to screen painter
Maintain description: Sub screen to normal screen
Select screen type : SUBSCREEN radio button
Select LAYOUT, Go to -> secondary window -> dictionary program fields
Select fields Customer Name(NAME1) and City(ORT01). Drop it in layout at the corner because
we don’t know the exact place of the sub screen area which is in Normal screen
SAVE and ACTIVATE sub screen design
Screen 100 flow logic: -
Select se80, provide module pool program name : ZDLG_SUBSCREEN
select screen number : 100
Select CHANGE (ctrl+F1)
In PBO, Process before output
Call subscreen SUB including ‘ZDLG_SUBSCREEN’ ‘120’.
* MODULE STATUS_0100.

Select PAI module and un comment it and double click on its module
Select main program
Tables: kna1.
Types: Begin of ty_kna1,
Kunnr type kunnr,
Name1 type name1_gp,
Ort01 type ort01_gp,
End of ty_kna1.
Data: wa_kna1 type ty_kna1,
I_kna1 type standard table of ty_kna1.
Select module .. end module of PAI
Case sy-ucomm.
When ‘DISPLAY’.
Select kunnr name1 ort01 from kna1 into table i_kna1 where kunnr = kna1-kunnr.
When ‘EXIT’.
Leave program.
Endcase.

SAVE and ACTIVATE.


Screen 120 flow logic: -
Select se80, provide module pool program name : ZDLG_SUBSCREEN
Select screen number: 120
Select CHANGE
Select PBO module and un comment it and double click on its module
Select main program
Select module .. end module of PBO
Logic to transfer the data to sub screen
IF not I_kna1 is initial.
Loop at i_kna1 into wa_kna1.
Move-corresponding wa_kna1 to kna1.
Endloop.
Endif.

SAVE and ACTIVATE back(F3) and ACTIVATE


Select SE80 choose program right click -> create -> Transaction
Warranty Application in Module pool

Step1: Table creation for warranty application


Select se80, select edit object, select dictionary, provide z table name: ZWT_TAB
Click on create
Maintain short description to table: Warranty application table
Delivery class: A, Display maintenance allowed
Select fields and provide fields to warranty application
PID PNAME PDATE WDATE
Enable primary key to PID, assign data elements to fields
ZPID ZPNAME ZPDATE ZWDATE
SAVE
Select Technical settings and provide
Data class: APPL0 Size category: 0
SAVE, back (F3) and ACTIVATE Table.
Select SE80 and create module program for warranty application: ZWT_TAB_PRG
Select program right click ->Create-> screen. Screen number: 100
Maintain description to warranty application
SAVE
From screen painter (click on screen number)
Select LAYOUT, Go to -> secondary window -> dictionary program fields.
Select All fields from Z table (ZWT_TAB) and drop it in Layout
Maintain operations INSERT, UPDATE, DELETE EXIT and MODIFY with using of Push Button.

SAVE and ACTIVATE screen design


Select flow logic from screen painter

Select PAI module and Un Comment the module, SAVE


Double Click on PAI module, select Main program
Tables: ZWT_TAB.
Types : Begin of fs,
pid type zpid,
pname type zpname,
pdate type zpdate,
wdate type zwdate,
End of fs.
Data: wa type fs,
Itab type standard table of fs.
Select module… End module of PAI
Logic for operations (operations are always in PAI)
CASE SY-UCOMM.
When ‘INSERT’.
Transferring data from screen to wa then to body
MOVE zwt_tab to wa. “here table name zwt_tab means screen
APPEND wa to itab.
INSERT INTO ZWT_TAB VALUES WA.
Message to know record inserted or not
If sy-subrc = 0.
Message I000(0) with ‘Inserted’. “
Else.
Message E001(0) with ‘Not Inserted’.
Endif.
(I means Information, it can be used for there would be no errors; 000 means Message
number ; with is syntax ; text: Inserted ; (0) means Default message class )
When ‘UPDATE’.
Transferring data from screen to wa then to body
MOVE zwt_tab to wa. “here table name zwt_tab means screen
APPEND wa to itab.
UPDATE ZWT_TAB FROM WA.
Message to know record updated or not
If sy-subrc = 0.
Message I001(0) with ‘Updated’. “
Else.
Message E002(0) with ‘Not updated’.
Endif.
When ‘DELETE’.
Transferring data from screen to wa then to body
MOVE zwt_tab to wa. “here table name zwt_tab means screen
APPEND wa to itab.
DELETE FROM ZWT_TAB where PID = WA-PID.
If sy-subrc = 0.
Message I002(0) with ‘Deleted’. “
Else.
Message E003(0) with ‘Not Deleted’.
Endif.
When ‘EXIT’.
LEAVE PROGRAM.
When 'MODIFY'.
*Transferring data from screen to wa then to body
MOVE zwt_tab to wa.  "here table name zwt_tab means screen
APPEND wa to itab.
MODIFY ZWT_TAB FROM WA.

Endcase.
ENDMODULE.
SAVE and ACTIVATE , F3 ,ACTIVATE
Select SE80 choose program right click -> create -> Transaction
Provide t code :zwt_tr

NOTE: - Insert and update operations are known as MODIFY


MODIFY is a sap key word it can insert record in date base whenever record enter in screen
does not exist in date base
It can update record in date base whenever record enter in screen exists in date base.
MODIFY = INSERT + UPDATE

Table Control Concept in Module pool


Using table controls concept user can perform operation on multiple records.
Select se80 create module pool program for table controls applications: ZDLG_TABCTRL.
Right click program create screen, screen no is 100
Maintain description to Applications: table control applications
SAVE
From screen painter select layout, provide customer field ( KUNNR ) in layout
Go to  secondary window  dictionary program field  KNA1 select field KUNNR
From tool box select table control and drop it in layout,

Click on table control to maintain properties i.e. name only: VCONTROL


Check the 4 check boxes resizing: vertical and horizontal, separators: vertical and horizontal
Again Goto  secondary window  dictionary program field  VBAK  select fields VBELN
and ERDAT
Select VBELN, ERDAT from VBAK table and drop it in table control.
Select POSNR, MATNR from VBAP table and drop it in table control.
Select Area of vbeln in properties provide name: WA-VBELN. Repeat the same for erdat, posnr,
matnr and provide WA-ERDAT, WA-POSNR, WA-MATNR in their properties.
Maintain DISPLAY and EXIT operations by using push buttons.
Provide name, text and FCT code in properties.
SAVE screen design
Select flow logic from screen painter select PAI module and delete comment
Double Click on that module to switch over to module pool
Select Main program

Tables:kna1, “customer table


vbak, “sales header table
vbap . “sales item table
TYPES: BEGIN of FS,
VBELN TYPE VBELN_VA,
ERDAT TYPE ERDAT,
POSNR TYPE POSNR_VA,
MATNR TYPE MATNR,
End of FS.
Data: wa type fs,
Itab type table of fs.
Maintain table control syntax
CONTROLS: VCONTROL TYPE TABLEVIEW USING SCREEN 100.
(VCONTROLE = name of table control kept in properties)
Select module ……end module of PAI. Maintain logics for operations
CASE SY-UCOMM.
When ‘DISPLAY’.
Select vbak~vbeln “(here more than one table so we take inner join concept)
Vbak~erdat Vbap~posnr Vbap~matnr
Into table itab from vbak inner join vbap on vbak~vbeln = vbap~vbeln where kunnr = kna1-
kunnr.
When ‘EXIT’.
Leave program.
Endcase.
SAVE and ACTIVATE then F3 (back)
Under PAI ,logic to read data having in body.
Process After Input.
LOOP AT ITAB.
ENDLOOP.
Module usercommand_100
Under PBO, logic to transfer read data from body to screen via work area.
Process Before Output.
LOOP AT ITAB INTO WA WITH CONTROL VCONTROL.
Module status_0100.
ENDLOOP.
Select PBO module and delete comment double click on the module
Select main program, select module …….endmodule of PBO
Maintain screen fields details.
MOVE –CORRESPONDING WA TO VBAK .
MOVE –CORRESPONDING WA TO VBAP.
Logic to enable table control vertical scroll bar.
VCONTROL-LINES = SY-DBCNT .
SY-DBCNT is a system variable to calculate no of records extract from database
SY_DBCNT means database count
SAVE and ACTIVATE. F3, ACTIVATE.
Select program from se80 right click -> create -> transaction.
Flow logic sequence: PBO treggerd screen displayed after screen displayed customer no enterd
and perform display with this PAI triggerd so that data keept it in body .then using loop-
endloop,PAI readed data from body .PBO triggered screen refreshed. Then reded data transfer
from body to screen via workarea

Table Control using Wizard


Purpose of this:

This is to demonstrate the step by step tutorial of how to make use of table control with wizard, where the
developer’s effort to write code with table control without wizard is avoided.  

Table control with wizard is the control provided by SAP, in which the users are not needed to code
separately for table control operations. It generates automatically system generated code for the following
table control operations.  

1. Insertion
2. Deletion
3. Scrolling
4. First
5. Last
6. Next
7. Previous
8. Select
9. Select all
10. Deselect
11. Deselect all  

Go to se80 create module pool program : ZDLG_TABCTRL_WIZARD

 Double click the program, Create an internal table and work area, which we are going to deploy
in table control. 

tables :mara.
types: BEGIN OF ty_mara,
       mark type c,
       matnr type matnr,
   ersda type ersda,
   ernam type ernam,
   END OF ty_mara.

data: it_mara type table of ty_mara,
        wa_mara type ty_mara.

ACTIVATE the Program.

 Create a screen Input the screen number as 0100


Fill up the screen attribute values.
Go to the layout of the screen, where you can find the table control with wizard. Drag and drop the table
control with wizard to the layout of the screen.  

Once you drag and drop the control a popup will appear.  
Press Continue. In the next screen enter the table control name as ‘TBC_0100’ or your own name.  

In the next screen you input the internal table and work area which has been created earlier.  

Note: Before it is done, you must activate the page, in which you have declared the internal table and
work area. Then only this table control screen will take its properties. 
The next screen will automatically retrieve the fields available in the internal table and show. We have to
select those fields, which and all should be displayed in table control.

If you have declared any character field for table control line selection, that should not be selected in this
screen

Select the input/output attributes as ‘Input control’ and give the field for selection of table control rows.
Select the multiple line selection.  

Click on Continue.
Click on Continue.

Click on Continue. The table control with auto generated code will automatically be created.  
Click Complete

This will automatically create PBO & PAI modules for table control operations.  

ACTIVATE the screen.

Select Program right click -> create -> Transaction.


For testing this tutorial, write a simple query to populate the internal table of table control and test the
input controls associated with it.  

After PBO, create a new Module with name : Select_Records

Double click on ‘select_records’ and select Main program.

In Module.. Endmodule of Select_record write below code.

select matnr ersda ernam from mara into CORRESPONDING FIELDS OF TABLE it_mara
  up to 10 rows.

The expected output will be like  


Validations in ABAP Transaction

All sap applications by default follows screen level validations. To apply field level validations
Logic should kept explicitly using CHAIN … ENDCHAIN syntax.
Application based on field level validations:

In application tool bar we can keep DISPLAY | SORDER | BACK | EXIT


To keep like this we use menu painter (se41)
Leave-to list-processing is syntax which can move control from dialog programming to ABAP
programming (moves control from abap transactions to abap reports)
If we perform BACK -> ABAP Programming move back to dialog programming

Select se80 and create Module pool program for field level validations: ZDLG_VALIDATIONS
Right click program -> Create -> Screen
Provide screen number: 100; Maintain description: Field level validations application
SAVE
Select Layout, provide Customer, Name, City fields in layout screen
Go to  secondary window  dictionary program field  KNA1 select field KUNNR
SAVE screen design
Select flow logic from screen painter, select PAI module and delete comment
Double click on that module, select Main program
TABLES: KNA1, VBAK.
TYPES: BEGIN OF TY_KNA1,
KUNNR TYPE KUNNR,
NAME1 TYPE NAME1,
ORT01 TYPE ORT01,
END OF TY_KNA1.
DATA: WA_KNA1 TYPE TY_KNA1,
IT_KNA1 TYPE TABLE OF TY_KNA1.

TYPES: BEGIN OF TY_VBAK,


VBELN TYPE VBELN,
ERDAT TYPE ERDAT,
END OF TY_VBAK.
DATA: WA_VBAK TYPE TY_VBAK,
IT_VBAK TYPE TABLE OF TY_VBAK.

Select module .. end module of PAI. Logic for operations


CASE SY-UCOMM.
When ‘DISPLAY’.
Select kunnr name1 ort01 from kna1 into table it_kna1 where kunnr = kna1-kunnr.
When ‘SORDER’.
Select vbeln erdat from vbak into table it_vbak where kunnr = kna1-kunnr.
Clear wa_vbak.
We use processing logic because we are in ABAP Programming. i.e.
Loop at it_vbak into wa_vbak.
Write:/ wa_vbak-vbeln, wa_vbak-erdat.
Endloop.
LEAVE TO LIST-PROCESSING. “this is for move from dialog programming to abap prog.
(BACK is a part of predefined means it works automatically, No need to keep logic explicitly)
When ‘EXIT’.
Leave program.
Endcase.
SAVE and ACTIVATE. Back (F3) ACTIVATE.
Select PBO module and delete comment.
Double click on module and select Main program
Select Module … Endmodule of PBO, logic to transfer data from body (IT_KNA1) to screen via
work area (WA_KNA1)
IF NOT It_KNA1 is initial.
Loop at it_kna1 into wa_kna1.
MOVE: wa_kna1-kunnr to kna1-kunnr,
wa_kna1-name1 to kna1-name1,
wa_kna1-ort01 to kna1-ort01.
ENDLOOP.
ENDIF.
(we ignore MOVE-CORRESPONDING and take MOVE for better performance)
Select SET-PF STATUS “ to customize Menu painter
Delete comment, Assign name of that i.e. ‘ZSTATUS’.
SET-PF STATUS ‘ZSTATUS’.
Double click on ZSTATUS to switch over to Menu painter.
Maintain short text: Customizing application bar

Select Application Tool Bar and Expand it.


Provide DISPLAY, double click on DISPLAY
Maintain function text: DISPLAY
Select one freely available function key (ex: F2, F5, F6 ….) to Display
Press ENTER again ENTER
Repeat same procedure for SORDER, BACK and EXIT
SAVE and ACTIVATE menu painter. Back (F3)
Select SET TITLE BAR and delete comment
Assign name to that. ZTITLE.
SET TITLE BAR ‘ZTITLE’.
Double Click on ZTITLE and provide title to the application

Title: Field level validations applications


Select all title (f5) ACTIVATE, back (F3), ACTIVATE, back (F3), ACTIVATE
For field level validations, Event is PAI. Because customer can be entered after screen display.
(Validations is First than operation. So we take validations before module. Because operations
are in module under PAI)

Process After Input.


CHAIN.
FIELD KNA1-KUNNR
Module USER_VAL. “ this is user defined module for his own
ENDCHAIN.
Double Click on USER_VAL, select Main program
Select Module …. ENDmodule of USER_VAL for field level validation logic
Select single * from kna1 where kunnr = kna1-kunnr. “(select single * is extract One Record
only)
IF SY-SUBRC <> 0.
Message E000(0) with ‘Invalid Customer’.
ENDIF.
SVAE and ACTIVATE, back (F3), ACTIVATE

Select Program right click -> create -> Transaction.

Provide ZPROG_VAL_TR as transaction.

Predefined Applications in ABAP Transactions (module pool)


For Example Application working is, vendor master create application
Transaction code is: XK01
Vender is a business partner to material management
1. Navigation to check module pool program name related to sap applications
Select t-code SE93
Provide sap application code i.e. XK01
Select DISPLAY to display module pool program
SAPMF02K is a module pool program to XK01 application
2. Navigation to check screen no’s having in sap application
Select t-code SE15 (REPOSITORY INFORMATION SYSTEM)
Select program library, from that select program sub object, from that select screen and
double click on that
Provide Module pool program name related to applications SAPMF02K
Select execute to display screen no having in XK01

3. Navigation to check source code having in sap application


Select editor SE38
Provide module pool program of application: SAPMF02
Select display
Sap design application source code in INCLUDE
Using top include in abap declaration can be maintained
Click on top include to check declaration
Click on first include to check declarations.

LUW CONCEPT AND UPDATEBUNDLING CONCEPT

LUW stands for logical unit of work.

Using data base LUW, data transfer from screen to data base buffer.
Whenever application terminate in between then whatever data having in data base
buffer that data can be deleted automatically.
Using sap LUW data transfers from buffer to tables

LUW = DATABASE LUW + SAP LUW

By default all sap application can follow LUW concept


In case of LUW network traffic is high between application server and data base server
(this is dis advantage of LUW) (To avoid this disadvantage we send buffer to application
server only) Using update bundling concept buffer can be customized in application
server with this network traffic can be avoided
Regarding update bundling logic should customize explicitly
In case of LUW data is secure because buffer is in data base

Entering data in predefined Application XK01:

Create Vendor Application: XK01


Change Vendor Application: XK02
Display Vendor Application: XK03

Create Customer Application: XD01


Change Customer Application: XD02
Display Customer Application: XD03

Create Material Application: MM01


Change Material Application: MM02
Display Material Application: MM03

TAB STRIP CONTROLS in Module pool

In ABAP transactions FCT codes are mandatory whenever user interaction required.
In this we maintain FCT codes for Customer and Sorder which are in Tab Strip Control.
Select se80 and create Module pool program for Tab strip control application:
ZDLG_TABSTRIP

Right click program -> create -> Screen. Provide screen no: 100

Maintain short description: Normal screen to Sub screen


SAVE
Select Layout, provide customer field (KUNNR) in Layout.
Go to  secondary window  dictionary program field  KNA1 select field KUNNR

From tool box select Tab Strip Control & drop it in layout.
Double click on Tab Strip Control to maintain properties i.e. name only
Name is: STRIP and close it
Click on first control (Tab1) to maintain properties
Name: CUSTOMER, Text: CUSTOMER, FCT code: TAB1

From tool box select Sub Screen Area drop it under CUSTOMER control
Click on sub screen area to maintain properties i.e. Name: SUB
Click on second control (Tab2) to maintain properties
Name: SORDER, Text: SORDER, FCT code: TAB2, Reference field: SUB

Maintain DISPLAY and EXIT operations by Push Button


SAVE & ACTIVATE normal screen design
Right click on program -> create -> screen. Provide screen no: 110
Maintain short description: Sub screen 110 for Tab Strip control
Select screen type: Sub screen radio button
SAVE
Select Layout, provide customer name & city fields in Layout.
Go to  secondary window  dictionary program field  KNA1 select fields NAME1, ORT01

SAVE & ACTIVATE sub screen design


Right click on program -> create -> screen. Provide screen no: 120
Maintain short description: Sub screen 120 for Tab Strip control
Select screen type: Sub screen radio button
SAVE
Select Layout, provide Table control in Layout.
Click on Table control to maintain properties i.e. Name: VCONTROL
Provide VBELN & ERDAT fields from VBAK and drop it in Table control.
Go to  secondary window  dictionary program field  VBAK select fields VBELN,ERDAT
SAVE & ACTIVATE sub screen design
Flow Logic of SCREEN 100:

Double click on screen 100, select CHANGE button


Under PBO maintain call sub screen logic
Process Before Output
CALL SUBSCREEN SUB INCLUDING ‘ZDLG_TABSTRIP’ X.
Double Click on PAI Module, select MAIN PROGRAM

TABLES: KNA1, VBAK.


TYPES: BEGIN OF TY_KNA1,
NAME1 TYPE NAME1,
ORT01 TYPE ORT01,
END OF TY_KNA1.
DATA: WA_KNA1 TYPE TY_KNA1,
IT_KNA1 TYPE TABLE OF TY_KNA1.

TYPES: BEGIN OF TY_VBAK,


VBELN TYPE VBELN,
ERDAT TYPE ERDAT,
END OF TY_VBAK.
DATA: WA_VBAK TYPE TY_VBAK,
IT_VBAK TYPE TABLE OF TY_VBAK.
Tab strip control syntax
CONTROLS: STRIP TYPE TABSTRIP.
Table control syntax
CONTROLS: VCONTROL TYPE TABLEVIEW USING SCREEN 120.
Data object to handle multiple sub screens with one area
DATA: X TYPE SY-DYNNR VALUE 110.
Sy-dynnr is a system variable for screen numbers
Select module .. end module of PAI. Logic for operations

Logic for operations


CASE SY-UCOMM.
WHEN ‘TAB1’.
X = 110.
STRIP-ACTIVETAB = ‘TAB1’.
Activetab is sap provided in tab strip control to activate FCT codes.
WHEN ‘TAB2’.
X = 120.
STRIP-ACTIVETAB = ‘TAB2’.
WHEN ‘DISPLAY’.
SELECT NAME1 ORT01 FROM KNA1 INTO TABLE IT_KNA1
WHERE KUNNR = KNA1-KUNNR.
SELECT VBELN ERDAT FROM VBAK INTO TABLE IT_VBAK
WHERE KUNNR = KNA1-KUNNR.
WHEN ‘EXIT’.
LEAVE PROGRAM.
ENDCASE.
SAVE, ACTIVATE back ACTIVATE
Flow Logic of SCREEN 110:
Double click on screen 110, select CHANGE button

Select PBO Module and double click on that, select MAIN PROGRAM
Select module .. end module of PBO.

Transferring data from body to screen via work area.


IF NOT IT_KNA1 IS INITIAL.
LOOP AT IT_KNA1 INTO WA_KNA1.
MOVE: WA_KNA1-NAME1 TO KNA1-NAME1,
WA_KNA1-ORT01 TO KNA1-ORT01.
ENDLOOP.
ENDIF.
SAVE and ACTIVATE back ACTIVATE.

Flow Logic of SCREEN 120:


Double click on screen 120, select CHANGE button
Under PAI logic to read multiple records from body

Process After Input


LOOP AT IT_VBAK.
ENDLOOP.
Under PBO logic to transfer read data from body to screen via workarea.
Process Before Output
LOOP AT IT_VBAK INTO WA_VBAK WITH CONTROL VCONTROL.
Module status_0120.
ENDLOOP.
Select PBO Module double click on it, select MAIN PROGRAM
Select module .. end module of PBO.
MOVE: WA_VBAK-VBELN TO VBAK-VBELN,
WA_VBAK-ERDAT TO VBAK-ERDAT.
SAVE and ACTIVATE back ACTIVATE
Select program -> right click -> create -> Transaction.

Program name: ZDLG_TABSTRIP, screen: 100


Tab Strip with wizard in Module pool

This is to demonstrate the step by step tutorial of how to make use of table strip with wizard, where the
developer’s effort to write code with tab strip without wizard is avoided.  

Tab strip with wizard is the control provided by SAP, in which the users are not needed to code separately
for tab strip operations. It generates automatically system generated code for the following tab strip
operations.

Go to SE80  Create ZTABSTRIP_CONTROL program.

 Right click on the report  Create  Screen.

Give the Screen number: 600 

The Screen type: Normal


Go to Layout

 Click on the Tab strip (With Wizard) screen element


  

Wizard open in a separate window  Click on Continue

 Give the Tab strip name: Tabstrip


 Select the scrolling in SAPGUI. Click on Continue

Tab Title definition: In this have to mention minimum 2 tabs titles. If we try to create only one tab the
following message is displayed.

Tab Title definition  Tab text  Sales Header Details (One Tab), Sales Item Details (Another Tab).
Click on Continue.
Sub screens (601, 602) for 2 tabs and Function codes are generated in this step. Click on continue.

 PBO and PAI Includes are generated automatically by this wizard in this step. Click on Continue
Tab strip Control is generated. Click On Continue

 Screen 600 is as shown below with 2 tabs and 2 different Sub screen areas.
 Empty Sub screen 601 has been created for tab (Sales Header details)

 Empty Sub screen 602 has been created for tab (Sales Item details)

 Code is auto generated through Wizard.


Empty Sub screens have been generated through the Wizard.

Go to Layout  Design the layout to display Sales Header Details

 Click on Dictionary/Program fields  to select the required fields from VBAK table.

Table/Field Name: VBAK and Click on Get from Dictionary Fields will be displayed.

Select the fields as shown below.


Place the fields on Sub screen 601.

  

Similarly repeat the same steps for the Sub screen 602 to display the Sales Item Details (from VBAP
table). Select the required fields.

Sub screen 602 is as shown below


Go to Screen 600  Flow Logic Code is auto generated by Wizard  

Go to Screen 601  Flow LogicUncomment the MODULE STATUS_0110 to implement the logic

 Double Click the MODULE STATUS PBO status will be created


Create the PBO MODULE STATUS  Main Program

Go to Sub screen 602 Flow Logic  Uncomment the PBO MODULE STATUS

Insert the following Logic in the MODULE STATUS.

SELECT SINGLE vbeln erdat erzet ernam
     FROM vbak
     INTO (vbak-vbeln, vbak-erdat, vbak-erzet, vbak-ernam).

  SELECT SINGLE vbeln posnr matnr matwa
    FROM vbap
    INTO (vbap-vbeln, vbap-posnr, vbap-matnr, vbap-matwa).

Through the code wizard empty PBO and PAI has been generated. Need to implement the logic to call
screens( Normal screen 600, Subscreen 601 and Subscreen 602). And  in PBO MODULE STATUS 

TABLES : VBAK, VBAP.
Activate the program  Right click on program create  Transaction.

The Output is displayed. Tab strip with 2 tabs 1) Sales Header Details and 2) Sales Item Details

When tab Sales Header Details is Clicked VBAK details are displayed


When tab Sales Header Details is Clicked VBAP details are displayed

You might also like