Você está na página 1de 67

DIALOG PROGRAMMING

2010 Wipro Ltd - Confidential

Contents
Introduction Why do we need Dialog programming Differences between report & Dialog programming Structure of a Dialog program Main components in Dialog programming Events 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

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Introduction
DIALOG PROGRAMMING
Dialog program is an ABAP development which consists of many screens which when linked together make up an application which allows the user to perform a specific functionality These screens are referred too as dynpros (DYnamic PROgrams) and are made up of the actual user screen and its associated flow logic which are all stored within an SAP module pool. In dialog programming we use the Screen Painter to create screens and program the sequence in which they appear. We write an ABAP/4 program (ABAP/4 module pool) for our screens. This is a collection of dialog modules which are called by the flow logic of our screens. We use dialog programs for both reading and changing database tables.

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Why Dialog Programming


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

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Reports and Dialog Programming

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Reports and Dialog Programming

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Components of the dialog program

2010 Wipro Ltd - Confidential

Components Of Dialog Programming

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Basic Components 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.
Flow logic: Calls of the ABAP/4 modules for a screen. 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 (PAIProcess After Input).

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Basic Components of 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 Screen type Field attributes: Definition of the attributes of the individual fields on a screen

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.

10

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Structure Of A Dialog Programming

11

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Events

12

2010 Wipro Ltd - Confidential

Events
PBO (Process Before Output) : A processing event which is called before the screen is displayed. Its tasks include the initialization of the screen fields and supply default data values for the screen. PAI (Process After Input) : A processing event taking place after you leave a screen. Its tasks are to process the input data or initiate the update of the database. POH (Process On Help Request) : A processing event taking place when user requests field help (F1) . Process On Help-Request ... Field <f> Module <mod>. ...

13

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Events
After the PROCESS ON HELP-REQUEST statement, you can only use the MODULE statement together with the FIELD statement. When the user chooses F1 for a field <f>, the system calls the module <mod> belonging to the FIELD <f> statement. If there is more than one FIELD statement for the same field <f>, only the first is executed. HELP_OBJECT_SHOW_FOR_FIELD :This function module displays the data element documentation for components of any structure or database table from the ABAP Dictionary. You pass the name of the component and structure or table to the import parameters FIELD and TABLE. HELP_OBJECT_SHOW: Use this function module to display any SAP script document. You must pass the document class (for example, TX for general texts, DE for data element documentation) and the name of the document to the import parameters DOKCLASS and DOKNAME.

14

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Events
POV (Process On Value Request) : A processing event takes place when user request F4 help. Process On Value Request. ... Field <f> Module <mod>. ... F4IF_FIELD_VALUE_REQUEST: Calls the input help of the ABAP Dictionary dynamically. We can pass the component names of a structure or database table of the ABAP Dictionary to the function module in the import parameters TABNAME and FIELDNAME. The function module starts the ABAP dictionary input help for this component. All of the relevant screen fields are read. If we specify the import parameters DYNPPROG, DYNPNR, and DYNPROFIELD, the users selection is returned to the corresponding field on the screen. If we specify the table parameter RETURN_TAB, the selection is returned into the table instead.

15

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Events
F4IF_INT_TABLE_VALUE_REQUEST: This function module displays a value list that we created in an ABAP program. The value list is passed to the function module as the table parameter VALUE_TAB. If you specify the import parameters DYNPPROG, DYNPNR, and DYNPROFIELD, the users selection is returned to the corresponding field on the screen. If we specify the table parameter RETURN_TAB, the selection is returned into the table instead.

16

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Transaction Flow

17

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Starting a Screen Sequence

There are two ways of starting a sequence of screens. 1) Using a Transaction Code 2) From ABAP program

18

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Using a Transaction Code

When you use a transaction code to start a screen sequence, the corresponding ABAP program is automatically loaded as well. The processing logic of the program is controlled by the screen flow logic. On reaching the end of the screen sequence (next screen 0), the entire program terminates, and control returns to the point from which the transaction was called.

19

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

From an ABAP Program


You can start a screen sequence from an ABAP program using the CALL SCREEN <dynnr> statement. At the end of the screen sequence (next screen 0), the program continues processing directly after the CALL SCREEN statement. Starting a sequence from an ABAP program allows you to insert a sequence of screens into the existing program flow.

20

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

21

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

22

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Screen objects

23

2010 Wipro Ltd - Confidential

Screen objects

24

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

25

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

26

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

When a screen is processed, the system table SCREEN contains an entry for each screen object that has been created in the Screen Painter for that screen. The SCREEN table is initialized in the PBO of each screen. It is filled with the screen objects belonging to that screen. You can handle the system table SCREEN like any other internal table, although you do not have to declare it in your program. It is maintained internally by the system, and updated each time a new screen is displayed.
27
2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

28

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Modifying Attributes Dynamically: Example

Display/Change

Display/Change

A B

A B

Output field

Input/Output field

SAP AG

29

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

30

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Dynamic next screen


You can set a static sequence of screens by entering a screen number in the Next screen attribute of the relevant screens. You can also set the screen sequence dynamically in one of the following ways: Using SET SCREEN. This temporarily overrides the Next screen attribute. CALL SCREEN. This inserts one or more screens into the sequence. When that sequence finishes, processing resumes with the statement following the CALL SCREEN statement. The next screen is processed either when the current screen processing ends, or when you terminate it using the LEAVE SCREEN statement. To specify the next screen and leave the current screen in a single step, use the LEAVE TO SCREEN <nnnn> statement

31

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Sample Transaction

32

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

CREATING A SIMPLE TRANSACTION

33

2010 Wipro Ltd - Confidential

CREATING A SIMPLE TRANSACTION


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

34

2010 Wipro Ltd - Confidential

Give program name like SAPMZSAMPLEPRG

35

2010 Wipro Ltd - Confidential

TOP include Creation


TOPINCLUDE will be created with name MZSAMPLEPRGTOP.

36

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

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

37

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Main program view


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

38

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

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.

39

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Complex structure of Main program

40

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Defining screens

41

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

To create screen for Transaction


Right click on program to create screen

42

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Screen creation initial screen


Provide the screen number and proceed.

43

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Screen Attributes
Provide the details and save it.

44

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Screen Flow Logic


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

45

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Creating PBO,PAI Modules


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

46

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

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.

47

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Sample screen of Screen painter

48

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

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

49

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

DICT/PROG fields initial screen


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

50

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Dict/Program Fields selection view

51

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

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.

52

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Placing required fields on screen

53

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Cosmetic changes on screen


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

54

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Screen Design

55

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Ok_code Declaration in screen elements list


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

56

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

PBO initial code


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

57

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

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.

58

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

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.

59

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Setting PF-status For screen


Select the functions required on the screen and provide names.

60

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

PBO Module Code


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

61

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

PAI Module Code


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

62

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Transaction creation
Create transaction to test the report.

63

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

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.

64

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

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.

65

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Result

66

2010 2010 Wipro Wipro Ltd Ltd - Confidential Confidential

Thank You

2010 Wipro Ltd - Confidential

Você também pode gostar