You are on page 1of 64

ABAP/4 Dialog programming Basics

Contents
Introduction to ABAP ABAP/4 Development Architecture Why Dialog programming Differences between report & Dialog programming Structure of a Dialog program with example transaction. Main components in Dialog programming. Screen painter in ABAP/4. Menu painter in ABAP/4. Interaction between screen painter and ABAP/4 modules. How communication is maintained in ABAP/4 modules. How to create simple dialog program with screen shots. Testing the transaction.

Introduction to ABAP

ABAP/4 Features

ABAP/4 is a programming language developed by SAP for the interactive development of application programs. ABAP/4 is a fourth-generation programming language that is the backbone of the R/3 System.

The language is event-driven with user actions and system events controlling the execution of the applications.
You can use the ABAP/4 programming language to create entirely new client/server applications, as well as extend existing R/3 modules, which is the most common use of the ABAP/4 language.

ABAP/4 Development Workbench Architecture


The Development Workbench provides access to SAPs development tools.

ABAP/4 Editor ABAP/4 Dictionary Data Modeller

Reporting

Screen Painter Menu Painter

R/3 Repository

Function Modules

ABAP/4 Development Workbench Architecture (cont) All programs are stored in the R/3 Repository.
A program is simply an object.

All definitions are kept in the data dictionary.


e.g. variable descriptions and parameters of fields.

Double-clicking will navigate you to wherever the object is stored. Remote call functions let you access other systems.

ABAP/4 Programming Types


1.Reports
A report program in ABAP/4 is a program which reads and analyzes data from database tables without modifying the database.

2. Dialog programming
In dialog programming you use the Screen Painter to create screens and program the sequence in which they appear. You write an ABAP/4 program (ABAP/4 module pool) for your screens. This is a collection of dialog modules which are called by the flow logic of your screens. You use dialog programs for both reading and changing database tables.

Report Vs Dialog Program

Reports and dialog programming

Why Dialog programming


A dialog program must offer:
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.

ABAP/4 offers a variety of tools and language elements to meet the requirements for creating and running dialog programs

Structure of a Dialog Program


A dialog program consists of the following basic components: Screens (dynpros)
Each dialog in an SAP system is controlled by dynpros. A dynpro (Dynamic Program) consists of a screen and its flow logic and controls exactly one dialog step. The flow logic determines which processing takes place before displaying the screen (PBO-Process Before Output) and after receiving the entries the user made on the screen (PAI-Process After Input).

ABAP/4 module pool Each dynpro refers to exactly one ABAP/4 dialog program. Such a

dialog program is also called a module pool, since it consists of interactive modules. The flow logic of a dynpro contains calls of modules from the corresponding module pool. Interactive modules called at the PBO event are used to prepare the screen template in accordance to the context, for example by setting field contents or by suppressing fields from the display that are not needed. Interactive modules called at the PAI event are used to check the user input and to trigger appropriate dialog steps, such as the update task.

Structure of a Dialog Program (Flow)

Sample Transaction

Transaction Explanation
This transaction consists of one dynpro only. The user enters the ID of an airline company and a flight number to request flight information. When the user chooses Display, the system retrieves the requested data from the database and displays it. SAP Transaction Screens An R/3 transaction is a series of business-related, logically consistent dialog steps. The transaction uses a program that conducts a dialog with the user. In a typical dialog, the system displays a screen on which the user can enter or request information. As a reaction on the the user input or request, the program executes the appropriate actions: it branches to the next screen, displays an output, or changes the database.

Transaction Flow

Main Components of a Dialog Program

You use the Screen Painter and the Menu Painter to create and design screen templates and screen programs. You define the processing logic in an ABAP/4 program (module pool).

Data structures are defined in the ABAP/4 Dictionary. You can access these structures from the ABAP/4 program and when defining screen fields. The dialog processor controls the flow of your dialog program.

Main Components of a Dialog Program Overview

Dynpro

Each screen contains fields used to display or request

information. Fields can be text strings, input or output fields, radio buttons, checkboxes, or pushbuttons. An SAP dynpro consists of several components: Flow logic: Calls of the ABAP/4 modules for a screen. Screen layout: Positions of the texts, fields, pushbuttons, and so on for a screen. Screen attributes: Number of the screen, number of the subsequent screen, and others. Field attributes: Definition of the attributes of the individual fields on a screen.

DYNPRO PARTS
Parts of dynpro (screen) will be like this.

Screen painter In ABAP/4


To create a screen, take the following steps: Define the basic features of a screen (screen attributes) Design the screen layout (in the full screen editor) Define the field attributes (field list) Write the screen flow logic The most important ABAP/4 program components are found in the following objects: Global data or Dictionary structures in the TOP include program (data declarations) PBO (Process Before Output) module PAI (Process After Input) module Subroutines (if required)

Screen painter-ABAP/4 (cont)

ABAP/4 Module Pool


In the Object Browser, the module pool code belongs to one of the following categories: Global fields: data declarations that can be used by all modules in the module pool PBO modules: modules that are called before displaying the screen PAI modules: modules that are called in response to the user input Subroutines: subroutines that can be called from any position within the module pool .

ABAP/4 Module Pool (cont)

Interactions between Screens and ABAP/4 Modules

In its most simple form, a transaction is a collection of screens and ABAP/4 routines, controlled and executed by a dialog processor. The dialog processor processes screen after screen, thereby triggering the appropriate ABAP/4 processing for each screen.

For each screen, the system executes the flow logic that contains the corresponding ABAP/4 processing. The control passes from screen flow logic to ABAP/4 code and back.

Interactions between Screens and ABAP/4 Modules (cont)

Communication: ScreenABAP/4 Module pool

Overview: Creating a Dialog Program


In the following, we are going to create a dialog program which displays a planned flight connection. On the first screen, the user can enter values for the key fields of the planned flight connection. On the second screen, the system displays the contents of the corresponding entry in table SPFLI.

Creating a Program Explanation


You create your program (ABAP/4 module pool) in the ABAP/4 Development Workbench. Customer dialog programs must be called SAPMZxxx or SAPMYxxx. The TOP include program contains only the PROGRAM statement at first, but will later also contain all data declarations and TABLES statements (global data). If you are working with includes, the system proposes names for them according to the following convention: The first 5 characters of the name are the same as the last 5 characters of the program name. The sixth character is an identification code for the particular contents of the include, for example, O for a PBO module, F for form routines (subroutines). The seventh and eighth characters are 01, except in the case of the TOP include. Example: the TOP include for ABAP/4 module pool SAPMZXXX would be MZXXXTOP; the include for the PAI module of this program would be MZXXXI01. In the program attributes, you maintain the title, the program type and the application. For program type, enter the value M (module pool) and select appropriate application.

Creating a Program Overview

Creating dialog program from SE80


Step1 : Go to SE80 select package and right click to create program .

Creating dialog program from SE80 (cont)

Step2 : Give program name like SAPMZSAMPLEPRG

TOP include Creation


Step3 : TOPINCLUDE will be created with name MZSAMPLEPRGTOP.

Saving Program
Step 4 : Give the title and select the program attributes as TYPE : M Status : S. save it in the package.

Main program view


The main program screen will appear like this, with TOP include and PBO,PAI includes commented at first.

PBO,PAI Includes creation


To create PBO,PAI include for screen right click on program->create-> PBO module (OR) uncomment PBO,PAI include in main program and double click to create.

Complex structure of Main program

Defining screens

To create screen for Transaction


Right click on program to create screen.

Screen creation initial screen


Provide the screen number and proceed.

Screen Attributes
Provide the details and save it.

Screen Flow Logic


Screen will contain attributes, elements list, flow logic parts. Flow logic part will as in below screen.

Creating PBO,PAI Modules


Uncomment PBO module (MODULE STATUS_9000) and double to create and the appropriate subroutine. similarly for PAI module.

some points about Screen painter


Screen Layout (Graphical Screen Painter) . To design screens, you use the Screen Painter.
The interface of the graphical Screen Painter contains easy-to-use functions for defining the various screen elements (e.g. input/output fields, field texts, boxes, etc.). You choose each screen element and position it on the screen using the mouse. This is WYSIWYG graphical design using drag-and-drop. To delete screen elements, you select the element with the mouse and then choose Delete. To move screen elements, you use the mouse to drag the element to the required position.

sample screen of Screen painter

Field List Flow logic

Import Dictionary/Tables Fields Field Attributes


Current Field Properties Graphical Drawing Elements

Screen Layout
Click on lay out it will take to screen painter.

DICT/PROG fields initial screen


Click on (F6) or get form dictionary\program then screen will be like this.

Dict/Program Fields selection view


Select Field/s Table/Field Name
Retrieve Table/Field From

Copy Field/s to Screen Painter

Selecting Fields required on Screen


Provide table name and click on get from dictionary button. and select required fields. and click on enter to place on screen.

Placing required fields on screen

Cosmetic changes on screen


Arrange some boxes around fields to look good and provide appropriate names to them.

Screen Design

Ok_code Declaration in screen elements list


In elements list declare ok as ok_code and in program ok_code like sy-ucomm.

PBO initial code


In PBO Code SET PF-STATUS will be commented initially. uncomment SET pf-status and give status name in caps (ZSAMPLE),double click to create.

Status Creation (Menu painter)


It will go to se41(menu painter), after filling The initial screen details select function buttons required the screen will appear like this.

Menu painter Overview


Use of Menu Painter
You use the Menu Painter to define functions on a screen in a particular status and assign them to the appropriate menu bar, standard toolbar and application toolbar. You also define the title. In general, you define a menu bar for each dialog program and assign it to a status. For each status, you define which menu functions are to be active/inactive. All the statuses of a dialog program make up the user interface. If you add a new status, you have to regenerate the interface. You assign a status and a title to a screen in the appropriate PBO module using the SET PF-STATUS and SET TITLEBAR statements respectively. The status can be up to 8 characters long, while the title code should consist of no more than 3 characters.

Setting PF-status For screen


Select the functions required on the screen and provide names.

PBO Module Code


Final PBO code will be like this. with code for selected functions on screen. (PBO Include).

PAI Module Code


In the PAI module write the code code for display button (PAI Include).

Transaction creation
Create transaction to test the report.

Transaction creation initial screen


It will take to SE93 (transaction creation initial screen). give name as ZSAMPLE ,provide short text &object type save it, activate it.

Test Transaction
Click on F8 to test the transaction on se93of transaction or give transaction name on command filed or on se80 right click on transaction->execute->direct processing. Provide the carrid and connid in the respective fields and click on display for result.

Result
The required details will be displayed on the corresponding fields in the same screen.

Conclusion
This is the way we will create dialog program . We can also insert, update the data from database with this screen by adding some other buttons and we can also Add table control on the screen by Using Dialog programming.

The PPT will cover the Basics ,I hope it will be helpful for beginners.

References

References: www.help.sap.com