Top Banner
India SAP CoE, Slide 1 Topic: ABAP report – Module Pool Programming Created By: SAP Team Approved By: Sachin Dayma Date of Release: July, 2008 Version: 1.0
123

Ab1011 Modulepoolprogramming 130610085946 Phpapp02

Nov 10, 2015

Download

Documents

Jaya Sankar

Modulepoolprogramming
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
India SAP CoECreated By: SAP Team
Approved By: Sachin Dayma
Version: 1.0
Module Pool program.
Module Pool Program (also called Online programs , dialog programs, or transactions) do not produces lists. These programs are a collection of screens, their Flow Logic, and the code within the main ABAP program.
A dialog program offers:
• A user-friendly user interface
• Format and consistency checks for the data entered by the user
• Easy correction of input errors
• Access to data by storing it in the database.
India SAP CoE, Slide *
Purpose
For performing any kind of task in SAP R/3 system, a transaction is used. SAP provides a standard set of transactions to manipulate data in the system. But sometimes, the need to create a customer specific transaction arise due to following reasons :
Standard SAP may not support that task.
A particular transaction needs to be customized to suit the customer requirements .
A transaction (also called module pool programs, dialog programs) is defined as a collection of screens (the actual, physical image that the users sees), their Flow Logic (code behind the screens ), and the code within the main ABAP program.
India SAP CoE, Slide *
Application
Online program name must begin with either a “Y” or “Z”.
Go back to Repository Browser, not source code.
“With TOP INCL.” should be checked.
Creating an Online Program
India SAP CoE, Slide *
Module Pool Program Components
India SAP CoE, Slide *
An online program consists not only of the screens and their Flow Logic, but also ABAP program components: Global data, PBO modules, PAI modules, and subroutines.
Global data: It is declared in the Top Include program.
PBO and PAI modules: It contain the main processing logic of online program and are “called” from within the Flow Logic of the screens.
The subroutines (if necessary) are in a separate include program.
Module Pool Program
Tools used:
When creating an module pool program, you will use many tools within the ABAP Development Workbench: Screen Painter, ABAP Editor, Menu Painter, ABAP Dictionary, and Repository Browser.
ABAP Editor (SE38) – To maintain main ABAP program. Program contains data declarations and modules.
Module pool programs are also called as dialog programs, Online programs or transactions
These programs are a collection of screens, their Flow Logic, and the code within the main ABAP program.
The term “screen” refers to the actual, physical image that the users sees.
The term “flow logic” refers to the code behind the screens (i.e., the logic that initializes screens and responds to a user’s requests on the screens). Each screen has its own Flow Logic.
The term “dynpro” (dynamic program) refers to the combination of the screen and its Flow Logic.
Menu will also have user interface for ABAP programs.
India SAP CoE, Slide *
Menu Painter(SE41) – Used to design GUI.
Maintain Transaction(SE93) – To create transaction code for program.
Object Navigator (Repository Browser)(SE80) - You should always use the object navigator for online programs because you will be able to see the hierarchy. From this hierarchy list, you will be able to branch to the Screen Painter, ABAP Editor, Menu Painter, and ABAP Dictionary.
You should always use the Repository Browser to create online programs because the system will automatically maintain an online program’s sub-objects and you will be able to see the hierarchy list of these sub-objects. From this hierarchy list, you will be able to branch to the Screen Painter, ABAP Editor, Menu Painter, and ABAP Dictionary.
Tools used:
Create a program using transaction SE38. Program name as Z_MODULE_TRAINING.
Program type should be Module Pool. Save and activate the program.
Use object navigator(SE80) to further develop the object.
India SAP CoE, Slide *
Program Structure
Module pool program when viewed from SE80 transaction will have structure as below,
India SAP CoE, Slide *
Assigning transaction code
Dialog program is executed using transaction code. We can not execute this like normal report using execute or pressing F8 button.
Transaction is created using SE93 transaction or from object browser by right clicking on transaction, click on create. Give name and description and select the radio button Program and screen (dialog transaction)
India SAP CoE, Slide *
Screen is a interface between user and SAP.
Using screen user can provide input to program and in turn program will display result on screen.
Screen is made up of screen elements such as text box, input/output field, check box, radio button etc.
One of the strength is that screen elements are combined with the ABAP dictionary to allow check the consistency of the data that user has entered.
India SAP CoE, Slide *
Screen Painter
To start the Screen Painter, choose the corresponding pushbutton on the initial screen of the ABAP Workbench or enter Transaction SE51.
Best practice is to go to transaction SE80, enter program name and you can perform one of the below,
1. Create new screens.
3. Create new components for an existing screen.
Screen is always created for an existing program.
India SAP CoE, Slide *
Overview of Screen Painter
Developing Screen
From Object navigator (SE80) we can create the screen as shown,
Click on Screen, right click and select create option.
Now enter screen number.
India SAP CoE, Slide *
Developing Screen
Screen numbers can be up to 4 characters long, all of which must be digits.
The number 1000 is reserved for table screens and report selection screen.
Screen numbers from 9000 are reserved for customer-specific screens.
The use of screen numbers is namespace-dependent.
For screens in programs in the SAP namespace, numbers less than 9000 are reserved for SAP screens, numbers between 9000 and 9500 are reserved for SAP partners, and numbers greater than 9500 are for customers.
India SAP CoE, Slide *
For screens in programs in the Customize namespace, any four digit number can be used as screen number except 1000 as mentioned above.
Usual practice is to have screen numbers for customize module pool program, starting with 100 then continue as 200, 300 etc.
Enter screen number and click on create.
Developing Screen
India SAP CoE, Slide *
Package – Identifies the package with which screen is saved
Last changed on/by – Date & time screen is last changed
Last generation – Date & time screen is last generated.
India SAP CoE, Slide *
Subscreen – To indicate the screen as a subscreen
Modal dialog box – used to display details in a dialog box. Used for data input, confirmation/error/help messages.
Selection screen – Identifies selection screen. The system sets this attribute automatically.
Settings
Hold data – On checking this, system can hold entries made on the screen at runtime. System automatically displays this data if the user calls the particular screen again.
India SAP CoE, Slide *
Settings
Switch off runtime compress – On setting this option, the screen is not compressed at runtime.
Template non executable – This attribute is primarily for internal use by SAP.
Hold scroll position – On setting the attribute, the scroll position is retained when the user returns to the screen after processing another screen.
Without application tool bar – To suppress the display of the application toolbar belonging to the current program status.
Other Attributes
India SAP CoE, Slide *
Screen Attributes
Other Attributes
Cursor position – Identifies the screen element that contains the cursor when a screen is first displayed. If you leave this field blank, the system uses the first screen field that can accept input.
Screen group – Specifies a four-character identifier of a group of associated screens.
Line/Columns –
Occupied – Specifies the size of the screen area currently occupied with screen elements
Maintained – Size of the screen in rows/columns.
Context menu – It will hold a routine name required to set up the context menu in the program. This routine connects the screen (elements) from the Screen Painter to the context menu of the program.
India SAP CoE, Slide *
Screen Layout Mode
The Screen Painter has a layout editor that you use to design your screen layout.
It works in two modes:
Graphical mode – Drag and drop interface is used, similar to a drawing tool.
Alphanumeric mode – Keyboard and menus are used for designing.
Both modes offer the same functions but use different interfaces. Graphical mode of screen designing is commonly used.
India SAP CoE, Slide *
To start screen design, click on layout button on screen.
Graphical Screen painter will start loading.
India SAP CoE, Slide *
Components of Layout Editor
Element palette – Used for creating screen elements. These can be drag & dropped on screen.
Work Area – Screen design is done in this area.
Element bar – screen element attributes appear in this line. You can also change these attributes in the corresponding field.
India SAP CoE, Slide *
Radio Button
Click on the Radio Button Icon and Click on the Screen.
Create at least two Radio Buttons
Name the Radio Buttons and Activate it.
India SAP CoE, Slide *
Defining Radio Button Group
Select the Radio Buttons and Follow the steps.
India SAP CoE, Slide *
Click on the Check Box Icon and Click on the Screen.
Name the Check Box and Activate it.
Special input/output fields that the user can either select (value ‘X’) or deselect (value SPACE). Checkbox elements can be linked with function codes.
Creating Check Box
Screen Components
Screen element properties can be seen in detail by double clicking on the element.
Properties of an element can be set here, such as variable length, F4 help, input/output, mode of display etc.
Best practice is to define screen elements by adopting the corresponding field from the ABAP Dictionary. However, you can also use field descriptions that you defined in your program. To do this you must generate the program first.
India SAP CoE, Slide *
Each element will have unique name.
Function code will be assigned for push buttons, tab titles in tab strip controls, Input/output fields with the "Dropdown box" attribute.
Each element will have its position on screen, visible/definite length, mode of display etc.
India SAP CoE, Slide *
Screen Elements
Push Button –
Can be placed on screen by drag & drop from Element palette.
To set the properties, double click on it.
Each screen element should have unique name.
In addition to that push button will have text and function code assigned to it.
India SAP CoE, Slide *
Assign Parameter ID to Input / Output Field
Dict. Tab is Selected
Program Tab is Selected
Entries in (*********)
Screen Elements
Screen Elements
Once screen is designed, it should be saved and checked for errors and activated. Screen looks as below,
Input Box
Screen can tested by executing F8 or click on button
India SAP CoE, Slide *
Flow Logic
Default flow logic for any screen is generated as shown below,
India SAP CoE, Slide *
Menu Painter
In all programs GUI consists of a menu bar, a standard toolbar, an application toolbar and title bar.
A program’s GUI is created in Menu Painter.
To Create a Menu for a screen, in flow logic uncomment MODULE STATUS_0400. in PBO event
PROCESS BEFORE OUTPUT.
Menu Painter
Now double click on STATUS_0400. A pop up window will appear. Click on Yes.
Module will be created as below,
*&---------------------------------------------------------------------*
Menu Painter
Uncomment the line SET PF-STATUS 'xxxxxxxx'. and replace 'xxxxxxxx‘ with name ‘STATUS_400’.
Click on STATUS_400. Click Yes on the pop-up.
India SAP CoE, Slide *
Menu Painter
Enter description and choose the status type as Normal screen which is default.
India SAP CoE, Slide *
Menu Painter
Click on to expand the menu bar, application toolbar and function keys.
System and Help are default in menu bar
India SAP CoE, Slide *
Creating Menu bar
To create a user defined menu enter the name of the menu and double click on it. We can define options for the menu here as below,
India SAP CoE, Slide *
Creating Application Tool bar
Application tool bar can also be created in same way as menu bar.
India SAP CoE, Slide *
Assigning function keys
We can assign code to existing function keys. Only keys for which code is assigned will be active. We can see this when the menu painter is executed.
India SAP CoE, Slide *
Execution
We can test the menu painter by clicking on F8 key or execute button
Enter a screen number and title if you want to simulate a whole screen. If you do not enter a screen number, the system simulates the status using an empty test screen.
India SAP CoE, Slide *
Execution
Output as below, New Menu is added, Find Item in Application tool bar, Save, Back & Print button on standard tool bar enabled.
India SAP CoE, Slide *
More on Flow Logic
Flow logic refers to code behind the screens. It is the code that processes a screen.
Flow Logic commands are different than ABAP commands
(e.g., IF … ENDIF is not valid in Flow Logic).
Dynamic Processor (DYNPRO) controls the flow logic and prepares data to be displayed on the screen.
India SAP CoE, Slide *
More on Flow Logic
Each screen has its own Flow Logic which is divided into four main events:
PROCESS BEFORE OUTPUT (PBO) - event processed before the screen is displayed.
PROCESS AFTER INPUT (PAI) - event processed after the user has invoked a function code (e.g., clicked on a pushbutton) or pressed the ‘Enter’ key.
Process on Value Request (POV) - Triggered when the user requests Value help (F4)
Process on Value Request (POH) - Triggered when the user requests field help (F1)
Each screen must be generated. If you make a change to any component of a screen, the screen must be re-generated before execution.
India SAP CoE, Slide *
Keyword
Function
MODULE
FIELD
Specifies the point at which the contents of a screen field should be transported
ON
VALUES
CHAIN
ENDLOOP
India SAP CoE, Slide *
PBO Event
By default the module created in PBO event will be like
MODULE STATUS_<screen number>
This module will be processed before the screen is displayed.
*&---------------------------------------------------------------------*
PBO Event
Menu bar and title bar can be set in this module.
Menu Bar-
To set menu bar uncomment the SET PF_STATUS and give a name to status as ,
SET PF-STATUS 'STATUS100'.
Double click on STATUS100 and click yes to create GUI status.
India SAP CoE, Slide *
PBO Event
Title Bar
To assign a title uncomment SET TITLEBAR and give a name as,
SET TITLEBAR 'TITLE100'.
Double click on TITLE100 and click yes to create GUI title. Enter title as below and click on , save and activate.
Once all the modules in the PBO block are processed, the system copies the content of the fields in the ABAP work area to their corresponding fields in the screen work area.
India SAP CoE, Slide *
MODULE USER_COMMAND_<screen number>.
Ex:- MODULE USER_COMMAND_0100.
This event is triggered once the user invokes function code or presses Enter key on the screen.
System variable SY-UCOMM will hold the function code assigned to the screen elements (push button, radio button, check box etc).
Within the above module code has to written to branch to group of code based on the function code from SY-UCOMM.
The system copies the contents of the fields in the screen work area to their corresponding fields in the ABAP work area once user clicks Enter key on screen or any function code is invoked.
India SAP CoE, Slide *
PAI Event- Sample Code
FROM ekpo
Includes
To have structured way of code it is best practice to have includes.
There should be a TOP include which will have the data declarations.
Include for PBO modules, include for PAI modules.
Include for POV and POH modules if any.
India SAP CoE, Slide *
Includes
To create include right click on object name, select Include from the Create menu.
India SAP CoE, Slide *
Includes
We can gave the include names as Z<Program>_TOP, Z<Program>_PBO, Z<Program>_PAI. This will help to understand which modules are covered in each include.
Each include program will insert a include statement in the main program.
India SAP CoE, Slide *
t – Message type
nnn –Message Number
WITH – This is optional. It is needed if variables are used in a message. A message can contain up to four variables, indicated with an ampersand (&) in the message text.
We can code the Message statement in the PAI event.
India SAP CoE, Slide *
E: error X
The message type determines where the message is displayed and what action the user can or must take on the current screen.
I
Success message is displayed at the bottom of the screen.
If you have next screen then the message will be displayed at the bottom of the next screen.
Information message is displayed in a dialog box in same screen.
After pressing Enter key on dialog box user will be taken to next screen. The user is not restricted from going on to the next screen.
India SAP CoE, Slide *
Messages
Abend message is displayed on the current screen in a dialog box.
The user cannot make any changes to the values on the current screen.
After pressing the ‘Enter’ key on the dialog box, transaction will be terminated.
Exit message is identical to the ABEND message except that the transaction is terminated with a short dump instead of the message in a dialog box.
WARNING message is displayed at the bottom of the current screen.
On pressing the ‘Enter’ key on the current screen, the user will be taken to the next screen even if no changes were made on the current screen . Thus user is not restricted from going on to the next screen.
India SAP CoE, Slide *
Messages
ERROR message is displayed at the bottom of the current screen.
The user must make changes to the values on the current screen.
On pressing the ‘Enter’ key on the current screen, the user will be taken to the next screen only if the appropriate corrections were made on the current screen.
If no corrections were made, the error message would be redisplayed at the bottom of the current screen.
When a warning or error message is triggered the system will stop at current screen, prompting the user to make corrections. However the input fields on the screen will be disabled for input.
India SAP CoE, Slide *
There are 2 ways to issue error/warning messages.
Issue an error or warning message with the Flow Logic SELECT statement.
Define valid values for a screen field with the Flow Logic VALUES statement.
FIELD statement is a Flow Logic command, not an ABAP command.
The purpose of the “FIELD” statement is to keep a single screen field open for input after an error or warning message is issued.
FIELD statement is used in PAI event.
Syntax is: FIELD <screen field> MODULE <module name>.
India SAP CoE, Slide *
FIELD with select statement
Screen field can be validated against entry in database table.
To validate Purchase order number in PAI module,
PROCESS AFTER INPUT.
module paycheck input.
if sy-subrc ne 0.
India SAP CoE, Slide *
FIELD with Values Check
The Flow Logic VALUES statement defines a set of valid values for the screen field specified in the FIELD statement.
If the value entered in this field is not in the valid set, an error message will be issued by the system.
PROCESS AFTER INPUT.
field PO_NO values ('1', '100').
This indicates PO_NO can take input as either 1 or 100. For any other value system will through error and the field will be open for input.
With VALUES parameter for field, we can get a list of possible values by clicking on the drop-down arrow of the screen fields or pressing the ‘F4’ key. It will list the values mentioned.
India SAP CoE, Slide *
India SAP CoE, Slide *
CHAIN Statement
To keep multiple screen fields open for input after an error or warning message is displayed, you need to use the “CHAIN” and “ENDCHAIN” Flow Logic commands.
These statements group the “FIELD” statements and the “MODULE” statements together.
The basic syntax of these statements is:
CHAIN.
ENDCHAIN.
If an error or warning message is issued in <module name>, all the screen fields listed in the “FIELD” statements will be open for input.
India SAP CoE, Slide *
Cursor Position
By default, the cursor will be positioned in the first field open for input on a screen.
Cursor position can be changed in two ways –
1. By setting the cursor position in PBO event-
Syntax - SET CURSOR FIELD <field name>
Cursor will be placed on the screen field mentioned.
2. Cursor position in screen attributes-
Mention the field name where cursor to be placed on screen in cursor position attribute .
India SAP CoE, Slide *
Screen commands
The LEAVE SCREEN statement ends the current screen and calls the subsequent screen.
When the system encounters the “SET SCREEN <screen #>” ABAP statement, it temporarily overrides the “Next Screen” attribute with this <screen #> and the PAI processing continues. After all PAI modules are executed, the system goes to the PBO event of
<screen #>.
Screen commands
“LEAVE TO SCREEN <screen #>” ABAP statement, terminates the screen’s PAI event and immediately goes to the PBO of <screen #>.
The “LEAVE TO SCREEN <screen #> statement performs the functionality of two statements: “SET SCREEN <screen #>“ and “LEAVE SCREEN”.
“CALL SCREEN <screen #>” ABAP statement, temporarily suspends the current screen’s PAI processing and immediately goes to the PBO event of <screen #>. When control returns back to the “calling” screen, its PAI processing will resume.
India SAP CoE, Slide *
More on PAI modules
All modules listed in the PAI event get executed from top to bottom.
We can control the execution of the modules using additions to MODULE.
Additions are,
ON INPUT
ON REQUEST
AT EXIT-COMMAND
AT CURSOR-SELECTION
ON INPUT
With the “ON INPUT” addition to the “MODULE” statement, a module will be executed only if the specified field’s value is not equal to the initial value appropriate to its data type
Ex- blanks for character fields and zeroes for numeric fields.
The basic syntax for this conditional execution Flow Logic command is:
FIELD <screen field> MODULE <module> ON INPUT.
The PAI <module> will be executed only if the value in <screen field> is not equal to its initial value.
The “ON INPUT” addition must be used with a “FIELD” statement because this condition depends on the value of a particular field.
India SAP CoE, Slide *
ON REQUEST
With the “ON REQUEST”, a module will be executed only if a value has been entered in the specified field since the screen was displayed.
The basic syntax for this conditional execution Flow Logic command is:
FIELD <screen field> MODULE <module> ON REQUEST.
The PAI <module> will be executed only if a value was entered in <screen field> since the screen was displayed.
The “ON REQUEST” addition must be used with a “FIELD” statement because this condition depends on the value of a particular field.
If you want to conditionally execute a module that is coded within a
“CHAIN … ENDCHAIN”, you must use “ON CHAIN-REQUEST”.
India SAP CoE, Slide *
AT EXIT-COMMAND
With the “AT EXIT-COMMAND” addition to the “MODULE” statement, a module will be executed only if the user invokes a function code with the ‘E’ function type.
Function type assigning is explained in slide 73.
The basic syntax for this conditional execution Flow Logic command is:
MODULE <module> AT EXIT-COMMAND.
India SAP CoE, Slide *
AT EXIT-COMMAND
The PAI <module> will be executed only if the user invokes a FUNCTION type ‘E’.
The “AT EXIT-COMMAND” addition cannot be used with a
“FIELD” statement.
If the user invokes a type ‘E’ function code, a module with the “AT EXIT-COMMAND” addition will be executed immediately.
It will be executed even before the automatic field checks.
India SAP CoE, Slide *
Assigning Function type
Function type can be assigned for screen buttons and for menu painter keys.
In menu painter, click on the required key. In the pop-up window select function type as ‘E’ from drop down.
India SAP CoE, Slide *
AT CURSOR-SELECTION
You can specify that a module should only be called if the cursor is positioned on a particular screen element.
Syntax - MODULE <mod> AT CURSOR-SELECTION.
The module <mod> is called whenever the function code of the user action is CS with function type S.
The module is called in the sequence in which it occurs in the flow logic.
It does not bypass the automatic input checks.
India SAP CoE, Slide *
AT CURSOR-SELECTION
You can also combine this MODULE statement with the FIELD statement:
FIELD <f> MODULE <mod> AT CURSOR-SELECTION.
For more than one field:
CHAIN.
Modifying Screen Fields
All fields of the current screen are stored in the system table SCREEN with their attributes.
The LOOP AT SCREEN statement places this information in the header line of the system table.
We can modify the attributes of the fields and update the screen table using MODIFY SCREEN.
Sample code:
You can dynamically modify the following attributes of a field:
ACTIVE
REQUIRED
INPUT
OUTPUT
INTENSIFIED
INVISIBLE
LENGTH
DISPLAY 3D
VALUE HELP
A field attribute is turned “on” with a value of 1. It is turned “off” with a value of 0.
The statements LOOP AT SCREEN ... ENDLOOP define a loop around a statement block.
Sample code:
endif.
endloop.
This will enable the screen field GV_OBJ_ID for input. SCREEN is an internal table provided by SAP.
India SAP CoE, Slide *
Logical Unit of Work (LUW)
LUW refers to a collection of actions performed at the database level as a complete unit.
In this ex: LUW is selecting A and B from the database, updating A, and deleting B.
This would be the desired LUW because we would want to rollback all changes if any of these actions failed.
Screen
2
Screen
1
Screen
3
LUW
Changes will be saved (commit work) in database at the end of third screen.
An SAP LUW will end with either the COMMIT WORK or ROLLBACK WORK statement.
A logical unit consisting of dialog steps, whose changes are written to the database in a single database LUW is called an SAP LUW.
If an SAP LUW contains database changes, you should either write all of them or none at all to the database.
Include a database commit when the transaction has ended successfully, and a database rollback in case the program detects an error.
India SAP CoE, Slide *
LUW
Since database changes from a database LUW cannot be reversed in a subsequent database LUW, you must make all of the database changes for the SAP LUW in a single database LUW.
In our example, we need to perform UPDATE A and DELETE B at the end of third screen.
India SAP CoE, Slide *
SAP Locks
R/3 system contain lock mechanism for SAP LUWs called SAP Locks.
Lock object is created in ABAP Dictionary.
A lock object definition contains the database tables and their key fields on the basis of which you want to set a lock.
System automatically generates two function modules with the names ENQUEUE_<lock object name> and DEQUEUE_<lock object name> when a lock is generated.
Locks can be set and released on corresponding database table by calling these function modules in program.
India SAP CoE, Slide *
Consider below example,
When user clicks on change, the program locks the relevant database object by calling the corresponding ENQUEUE function.
You can release the lock by calling DEQUEUE function when user clicks on SAVE or when user clicks on BACK button.
India SAP CoE, Slide *
Table Control
A table control is an area on the screen where the system displays data in a tabular form. It is processed using a loop.
To create a table control, drag & drop table control from screen elements on screen painter. Give a name to table control.
Select the table definition and fields clicking on Dictionary/Program fields object button.
Each table control need to be declared in declaration part of the program as,
CONTROLS <ctrl> TYPE TABLEVIEW USING SCREEN <scr>.
where <ctrl> is the name of the table control on a screen.
India SAP CoE, Slide *
Table Control
You must code a LOOP statement in both the PBO and PAI events for each table in your screen.
This is because the LOOP statement causes the screen fields to be copied back and forth between the ABAP program and the screen field.
For this reason, at least an empty LOOP...ENDLOOP must be there.
India SAP CoE, Slide *
tab2-current_line.
ENDLOOP.
Subscreen
A subscreen is a screen that is displayed in a specified area of the main screen.
A subscreen cannot be displayed by itself.
The subscreen displayed in the predefined area will depend on the user’s request on the main screen.
Subscreen is used to vary the fields displayed on a screen. As an example:
The “main” screen contains the customer number, name, and a predefined area for a subscreen.
One subscreen contains customer address information.
Another subscreen contains customer bank information.
India SAP CoE, Slide *
In main screen,
In the screen layout, place the screen element ‘subscreen’ on layout.
You can set the length and width of the subscreen by double clicking on subscreen.
Provide unique name to subscreen, save and activate it.
Subscreen
Screen type should be subscreen.
Specify the screen length and height as in main screen.
Save the subscreen and go to screen layout. Here subscreen are will be displayed.
India SAP CoE, Slide *
India SAP CoE, Slide *
Call subscreen in PBO
To include a subscreen in a predefined area on the “main” screen, use the “CALL SUBSCREEN” statement in the “main” screen’s PBO event.
syntax :CALL SUBSCREEN <area> INCLUDING <program> <subscreen #>.
<area> : name of the subscreen area defined on the “main” screen. This subscreen area will be the location of the subscreen. This <area> cannot be enclosed in single quotes.
<program> : name of the program where the subscreen exists.
India SAP CoE, Slide *
Call subscreen in PBO
<subscreen #> : number of the subscreen to display in the subscreen area.
The <program> and <subscreen #> can be literals (i.e. enclosed in single quotes) or variables.
When the “CALL SUBSCREEN” statement is encountered in the “main” screen’s PBO event, the system executes the PBO event of the subscreen. Then, the system returns to finish the PBO event of the “main” screen.
India SAP CoE, Slide *
Call subscreen in PAI
If the subscreen contains any PAI code, use the “CALL SUBSCREEN” statement in the PAI event of the “main” screen.
Syntax : CALL SUBSCREEN <area>.
The <area> is the name of the subscreen area defined on the “main” screen. This <area> cannot be enclosed in single quotes.
The “CALL SUBSCREEN” statement must be used to invoke the PAI event of the subscreen.
- When the “CALL SUBSCREEN” statement is encountered in the “main” screen’s PAI event, the system executes the PAI event of the subscreen.
India SAP CoE, Slide *
Call subscreen in PAI
Then, the system returns to finish the PAI event of the “main” screen.
Without this “CALL SUBSCREEN” statement in the PAI event of the “main” screen, the PAI event of the subscreen cannot be processed by the system.
If the subscreen does not contain any PAI code, this “CALL SUBSCREEN” statement is not needed in the PAI event of the “main” screen.
In both the PBO and PAI of the “main” screen, the “CALL SUBSCREEN” statement cannot be used inside a “LOOP” or a “CHAIN”.
India SAP CoE, Slide *
Subscreen Restrictions
The following ABAP/4 statements cannot be used in a subscreen’s PBO or PAI modules (instead, they must be used in the “main” screen):
SET PF-STATUS
SET TITLEBAR
SET SCREEN
CALL SCREEN
Note: These ABAP/4 statements in a subscreen will pass a syntax check; however, they will result in runtime errors.
India SAP CoE, Slide *
Tab Strip Controls
Each tab page consists of a tab title and a page area.
If the area occupied by the tab strip control is too narrow to display all of the tab titles, a scrollbar appears, allowing you to reach the titles that are not displayed.
Tab strips allow users to access multiple sub screens on one normal screen.
This allows for a more intuitive user interface by logically separating the information presented to the user into different headings.
The user can sort through the information by clicking on a corresponding tab
A tab strip control is a screen object consisting of two or more pages.
India SAP CoE, Slide *
Tab Strip Control components
Tab Title – Title of the component to which user can
navigate. They are push buttons.
Tab title row - All tab titles will appear in a row.
Tab Page - A tab page contains a collection of fields that logically belong together. Tab pages are implemented using subscreens.
For designing and using tab strip controls, see Transaction BIBS .
Tab Strip Control components
India SAP CoE, Slide *
Tab Strip Controls
Tab strip controls allow you to place a series of screens belonging to an application on a single screen, and to navigate between them easily.
From a technical point of view, a tab page is a sunscreen with a pushbutton assigned to it, which is displayed as the tab title.
When you create a tab strip control, you must: ……….
Define the tab area on a screen and the tab titles.
Assign a subscreen area to each tab title.
Program the screen flow logic.
Program the ABAP processing logic.
India SAP CoE, Slide *
Paging in the SAPgui
                  area2 INCLUDING [prog2] dynp2,
                  area3 INCLUDING [prog3] dynp3,
PROCESS BEFORE OUTPUT.
  ...
Handling in the ABAP Program
Create a control for each control in the declaration part of your
program using the following statement:
CONTROLS ctrl TYPE TABSTRIP.
  ...
Assign the function code of the corresponding tab title to the component Activetab:
ctrl-Activetab = fcode.
                    …
Activetab contains the function code of the last active tab title on the screen.
Tab Strip Controls
India SAP CoE, Slide *
Programming the Flow Logic
The flow logic is restricted to that necessary to include the appropriate
subscreen screens in the right subscreen areas.
Local Scrolling at the Front-end
Include subscreen screens in all of your subscreen areas in the
tab strip control.
PROCESS BEFORE OUTPUT.
                    <subscreen_area2> INCLUDING [<progname 2>] <subscreen_scrn 2>,
                   <subscreen_area3> INCLUDING [<progname 3>] <subscreen_scrn 3>,
PROCESS AFTER INPUT
CALL SUBSCREEN: <subscreen_area1>,
India SAP CoE, Slide *
Programming the Flow Logic
The flow logic is restricted to that necessary to include the appropriate
subscreen screens in the right subscreen areas.
Scrolling at the Application Server
Include one subscreen at a time in a single subscreen area.
PROCESS BEFORE OUTPUT.
PROCESS AFTER INPUT
CALL SUBSCREEN < subscreen_area>.
Tab Strip Controls
Step loops are considerable less flexible than table controls.
Used to group screen elements together. A step loop is a repeated series of loop blocks. A loop block consists of one or more loop lines of graphical screen elements.
Loop blocs can be defined as fixed or variable.
In a fixed loop, the lower limit of the loop area always remains as originally defined.
For a variable loop, the number of repetitions is adjusted dynamically in the screen program to suit the size of the current window.
India SAP CoE, Slide *
Creating a Step loop
Open a screen in the layout editor.
In one or more lines, create the elements you want to repeat.
Select all the elements on the desired line(s) as a group.
Choose Edit Grouping Step loop Define.
Your element lines now make up a single step loop block. The block includes the original elements with their attributes and a predefined number of repetition blocks.
Each repetition contains a copy of the first block without attributes.
The repetition blocks are consecutively numbered, so that you can establish a reference to a particular line.
India SAP CoE, Slide *
Step loops
To use a Step-Loop block in an online program, you must create one work area for the Step-Loop block. To hold all the lines of a Step-Loop block in the program’s memory area, use an internal table.
Ex:-TYPES: BEGIN OF TY_REC,
HEADER LINE.
For Step loop the flow logic statement loop must be coded in both PBO and PAI event. One form of the Flow Logic “LOOP” statement is;
LOOP.
PROCESS BEFORE OUTPUT.
PROCESS AFTER INPUT.
call subscreen SUB1.
India SAP CoE, Slide *
Additions with ABAP OOPS
Enjoy SAP controls (ALV Grid , ALV Tree, HTML controls etc) can be displayed in screen.
To place these grids we need to have screen element Custom Control placed on the screen.
Also we need to have ABAP OOPS knowledge. ( Refer package SLIS for examples)
India SAP CoE, Slide *
This event is a user programmed help.
If the user presses the ‘F1’ key with the cursor is positioned in <screen field>, the <supplemental documentation> will be displayed along with the data element’s short text and documentation.
The only other Flow Logic statement that can be used in the POH event is:
FIELD <screen field> MODULE <module>.
India SAP CoE, Slide *
Process on Value
This event is a user-programmed help that occurs when the user presses F4 with the cursor positioned on a screen field.
The modules specified in the subsequent FIELD statement is called instead of the SAP help.
Syntax is:
India SAP CoE, Slide *
Demo Example in IDES system –
1. Demo example has screen designing and Menu painter used.
2. All 4 events (PAI, PBO, POH, and POV) are implemented.
3. Exit-command is used.
Execute the transaction code Z_MOD. Screen below will be displayed.
Here there are 3 menu options- NewMenu, and SAP provided default menus (System and Help). NewMenu is user defined menu.
Click F1 button on the Purchase Order input field. F1 user help will be displayed as shown below.
User will enter purchase order number in this screen.
Enter as 12345 and click on either of the buttons (Details/Next/Get PO Type/From NewMenu option Display PO Type/ Enter key).
An error message will be displayed as “Invalid Purchase Order”.
User can enter purchase order number or can select using F4 help provided.
On clicking F4 help for PO number, list of PO available will be displayed and user can select from this list.
On entering a valid PO number, we can perform the below operations,
1. On clicking Details button, Company and PO Doc Category will be displayed in the subscreen area.
2. On clicking Get PO Type button or from NewMenu Display PO Type option, PO Doc Type will be displayed.
3. On the screen by default radio button Display in Table control is marked. On click on Next button or selecting option Next from NewMenu will display next screen as below,
Here PO number, item number and company code will be displayed in table control. On click on Back function key user will be directed to previous screen.
4. Click on radio button Display in Step loop and click on Next button.
Here the function keys back, cancel and exit are active. On click on Back and cancel will take the user to initial PO screen. Click on exit will leave on SAP main screen.
Click on Details
Exercise 1 – This covers input/output, radio button, table control, screen navigation, flow logic events, Menu painter.
Exercise 2 – This covers tab strip, subscreen, table control, 4 flow logic events, screen navigation, menu painter.
First screen
User will enter Sales Order no (VBAK_VEBLN) on the screen. Provide F4 and F1 help for sales order no. Also validate the sales order against table VBAK and display appropriate error message if order is invalid.
Design a Tab strip with tab titles as Sales Details and Items.
Sales Details and Items will be two sub screens to be designed.
Activate Back function key using Menu painter. Clicking on Back should navigate user to SAP main screen.
Sales Details Subscreen –
All the fields are taken from VBAK table based on sales order number. Field names are as below,
Sold to party (VBAK-KUNNR)
SD doc category (VBAK-AUART)
Item
Material
Save button at the bottom of table control.
Item and material are non-editable field. On double clicking on any material user should navigate to Material screen. Material screen design is given below.
Order Qty is an editable field. User can change the Qty and on save button click qty should get saved.
If no values for quantity is changed and user clicks on save a information pop up with message No changes done should be displayed.
Fields are from VBAP table.
Sales doc item (VBAP-POSNR)
Material no (VBAP-MATNR)
Material description (MAKT-MAKTX)
All fields should be non-editable.
Back function key has to be active in Menu bar. On click on Back user should navigate to Items subscreen.
Sold to party
F4 help for PO number has to be provided.
Po number should be validated before further processing.
There will be 3 radio buttons for Delivery Details, Address and Line item details. At any time only one radio button has to be checked.
Also create a menu bar called PO Menu using Menu Painter.
PO Menu should have below options
Next
Back
Also provide a button on tool bar as Process. This will have the same functionality as Next button and Next option from Menu.
Back will navigate to SAP main sceen.
Delivery Details Screen-
Click on Back should navigate to Purchase Order Entry screen.
Click on Cancel should navigate to SAP main screen.
Filed selection is as below,
Payment terms- EKKO-ZTERM
Discount days – EKKO-ZBD1T
Inco terms – EKKO-INCO1
Address Details-
Get the address of PO from ADRC table. Select data from ADRC table based on Address number ADRNR from EKKO table for the PO. All fields should be non-editable.
Provide back and cancel function keys. Back should navigate user to Purchase Order Entry screen.
Click on Cancel should navigate to SAP main screen.
Provide a button Delivery Details on Tool bar. Clicking on this should navigate user to Delivery details screen.
Street – ADRC-STREET
Location – ADRC-LOCATION
City – ADRC-CITY1
PO Quantity – EKPO-MENGE
Net price – EKPO-NETPR in a step loop.
Provide back and cancel function keys. Back should navigate user to Purchase Order Entry screen.
Click on Cancel should navigate to SAP main screen.
Provide a button Delivery Details and Address Details on Tool bar.
Clicking on Delivery Details should navigate user to Delivery details screen.
Click on Address details should navigate to Address screen.
Purchase Order
Delivery Details
Address Details
Line Items
India SAP CoE, Slide *
Refer help.sap.com
Refer Transaction code ABAPDOCU (check in drop down ABAP User Dialogs) for documentation and examples
For screen elements and controls (table control, tabstrip) refer transaction BIBS.
Refer package SLIS for examples of ALV grids, ALV Tree.
Microsoft Word