Title: Dialog Programming Overview
1Dialog Programming Overview
2SAP System Dialog Processing (Report)
SAP GUI
Report zpsm1. Tables customers. Select single
from customers where id 1. Write /
customers-name.
Request
List
Generate Screen(List)
1
10
Application Server
Send Request
Store request to queue
Dispatcher
3
SAP Buffer
Send List
2
Search for free WP
Request Queue
9
Program
Check Program in Program Buffer
7
Send request to WP
Execute ABAP statement
5
4
D
D
D
D
6
8
LoadGen Program
SQL Request
Database Server
3Dialog WP Executable Program
Dialog WP
Local Memory
Memory Space
TaskHandler
ABAP Processor
List Buffer
DYNPRO Processor
DB Interface
Result Set Memory
Database
4Types of ABAP Report
1
3
1. Report Listing 2. Drill-down Report 3.
Control-break Report 4. ALV Report
4
5SAP System Dialog Processing (DIALOG)
SAP GUI
Program sapmzex001. Include . Set screen 100.
Request
Screen
Generate Dialog Screen
1
10
Application Server
Send Request
Store request to queue
Dispatcher
3
SAP Buffer
Send List
2
Search for free WP
Request Queue
9
Program
Check Program in Program Buffer
7
Send request to WP
Execute ABAP statement
5
4
D
D
D
D
6
8
LoadGen Program
SQL Request
Database Server
6Dialog WP Dialog Program
Dialog WP
Local Memory
ABAP Memory
TaskHandler
ABAP Processor
Screen Buffer
DYNPRO Processor
DB Interface
Result Set Memory
Database
7Dialog Program Transaction
8Dialog Program Components
Transaction Code
Dialog Program
Program Naming Convention SAPM
Screen 100 (Screen Layout)
ABAP Module Pool
PBO
Flow Logic
ABAP Module Pool
PAI
Screen 200 (Screen Layout)
ABAP Module Pool
PBO
Flow Logic
ABAP Module Pool
PAI
9SAP Transaction
DB Commit
DB Commit
- An SAP transaction consists of Dialog steps. A
Dialog step begins when the user press
Enter,activates a function by pressing a function
key,double-clicks or chooses a function from a
menu.It ends when the next screen is display - In the course of a Dialog step,The PAI modules
belonging to the current screen and the PBO
modules belonging to the next screen
10Data Transfer (Local Memory)
Local Memory
Screen Work Area
ABAP Work Area
ok_code
Screen Buffer
ABAP Memory Space
PBO
Element List
customers
id name city
customers-id
0000000
customers-name
ok_code
PAI
11Flow Logic
- Process Before Output(PBO)
- After it has processed all of the modules in the
PBO processing block, the system copies the
contents of the fields in the ABAP work area to
their corresponding fields in the screen work
area. - Process After Input(PAI)
- Before it processes the first module in the PAI
processing block, the system copies the contents
of the fields in the screen work area to their
corresponding fields in the ABAP work area.
12OK Code Field in Screen
OK Code Field or Command Field (ok_code in
Element List)
13Defining Screen (4 Steps)
- Screen Attribute
- Screen Layout
- Flow Logic
- Element List
Element List(ok_code field)
14Flow Logic in Screen 100
- PROCESS BEFORE OUTPUT.
- MODULE STATUS_0100.
- PROCESS AFTER INPUT.
- MODULE USER_COMMAND_0100.
15PBO in Screen 100
- MODULE status_0100 OUTPUT.
- SET PF-STATUS 0100.
- SET TITLEBAR 0100.
- ENDMODULE.
-
16PAI in Screen 100
- MODULE user_command_0100 INPUT.
- CASE ok_code.
- WHEN EXIT.
Leave program - SET SCREEN 0. LEAVE SCREEN. Leave to
screen 0 - WHEN SAVE.
- UPDATE customers.
- MESSAGE S000(38) WITH Update OK.
- SET SCREEN 50. LEAVE SCREEN.
- ENDCASE.
- ENDMODULE.
17How to Create Dialog Program
- Transaction SE80 Create Dialog Program
- Create Screen(4 steps)
- Screen Attribute
- Screen Layout
- Flow Logic(PBO,PAI)
- Define Variable ok_code in Element List
- Define Data Object in ABAP Work Area at TOP
Include(Tables, Data,...) - Check and Activate Dialog Program
- Create Transaction Code
18Example I
Screen 200
Screen 100
19Example I
- Create Dialog Program SAPMZEXltnngt for changing
Customers table - Screen 100
- Field customers-id
- Screen 200
- Field customers-id and customers-name
20Example I
- Screen 100
- PROCESS BEFORE OUTPUT.
- MODULE STATUS_0100.
- PROCESS AFTER INPUT.
- MODULE USER_COMMAND_0100.
-
21Example I
- Screen 100
- MODULE status_0100 OUTPUT.
- SET PF-STATUS 0100.
- SET TITLEBAR 0100.
- ENDMODULE.
-
22Example I
- Screen 100
- MODULE user_command_0100 INPUT.
- CASE ok_code.
- WHEN BACK.
- LEAVE PROGRAM. leave to screen 0
- WHEN space. if not assign Enter Key
- SELECT SINGLE FROM customers
- WHERE id customers-id.
- LEAVE TO SCREEN 200.
- ENDCASE.
- ENDMODULE.
-
23Example I
- Screen 200
- PROCESS BEFORE OUTPUT.
- MODULE STATUS_0200.
- PROCESS AFTER INPUT.
- MODULE USER_COMMAND_0200.
-
24Example I
- Screen 200
- MODULE status_0200 OUTPUT.
- SET PF-STATUS 0200.
- SET TITLEBAR 0200.
- ENDMODULE.
-
25Example I
- Screen 200
- MODULE user_command_0200 INPUT.
- CASE ok_code.
- WHEN BACK.
- LEAVE TO SCREEN 100. set screen 100
- WHEN SAVE.
- UPDATE customers.
- MESSAGE S000(38) WITH Update OK!.
- LEAVE TO SCREEN 100.
- ENDCASE.
- ENDMODULE.
-
26Example I
- TOP Include
- TABLES customers.
- DATA ok_code TYPE sy-ucomm.
- Create Transaction Code
- Transaction Code ZEXltnngt
27Exercise
- Create Dialog Program SAPMZCUSTltnngt
- Transaction Code ZCUSTltnngt
28Exercise Customers Maintenance
Screen 200
Screen 100
29Setting the Cursor Position Dynamically
PROCESS BEFORE OUTPUT. MODULE STATUS_0200.
MODULE set_cursor.
MODULE set_cursor OUTPUT. SET CURSOR FIELD
CUSTOMERS-CITY OFFSET 3. ENDMODULE.
Cursor Position
30Avoiding the Unexpected Processing Step of
ok_code Field
311. Auxiliary OK_CODE Variable
- TOP Include
- TABLES customers.
- DATA ok_code TYPE sy-ucomm.
- DATA save_ok TYPE sy-ucomm.
32Example I - Change
- Screen 100 PAI
- MODULE user_command_0100 INPUT.
- save_ok ok_code.
- CLEAR ok_code.
- CASE save_ok.
- WHEN BACK.
- LEAVE PROGRAM.
- WHEN space.
- SELECT SINGLE FROM customers WHERE id
customers-id. - LEAVE TO SCREEN 200.
- ENDCASE.
- ENDMODULE.
-
33Example I - Change
- Screen 200 PAI
- MODULE user_command_0200 INPUT.
- save_ok ok_code.
- CLEAR ok_code.
- CASE save_ok.
- WHEN BACK.
- LEAVE TO SCREEN 100.
- WHEN space.
- LEAVE TO SCREEN 200.
- WHEN SAVE.
- UPDATE customers.
- MESSAGE s000(38) WITH Update OK!.
- LEAVE TO SCREEN 100.
- ENDCASE.
- ENDMODULE.
-
342. Specify the Enter Function at GUI Status
35Check Enter Function
- Screen 100 PAI
- MODULE user_command_0100 INPUT.
- CASE ok_code.
- WHEN BACK.
- LEAVE PROGRAM.
- WHEN ENTE.
- SELECT SINGLE FROM customers
- WHERE id customers-id.
- LEAVE TO SCREEN 200.
- ENDCASE.
- ENDMODULE.
-
363. Clear OK_CODE at PBO
- Screen 100 Flow Logic
- PROCESS BEFORE OUTPUT.
- MODULE STATUS_0100.
- MODULE clear_ok_code.
- PROCESS AFTER INPUT.
- MODULE USER_COMMAND_0100.
-
37Clear OK_CODE at PBO
- Screen 100 PBO
- MODULE status_0100 OUTPUT.
- SET PF-STATUS 0100.
- SET TITLEBAR 0100.
- ENDMODULE.
- MODULE clear_ok_code OUTPUT.
- CLEAR ok_code.
- ENDMODULE.
-
38Checking User Input
39Example II
- Maintain Customers Data
- Check Input Data Manually
40Example II
- Screen 100 PAI
- MODULE user_command_0100 INPUT.
- ...
- WHEN SPACE.
- SELECT SINGLE FROM customers WHERE id
customers-id. - IF sy-subrc ltgt 0.
- MESSAGE S000(38) WITH Customers data
not found. - LEAVE TO SCREEN 100.
- ELSE.
- LEAVE TO SCREEN 200.
- ENDIF.
- ENDCASE.
- ENDMODULE.
-
41Example III
- Maintain Customers Data
- Check Input Data Using Field Command
42Example III Field Statement
- Screen 100 Flow Logic (PAI)
-
- PROCESS AFTER INPUT.
- FIELD customers-id MODULE user_command_0100.
-
43Example III
- Screen 100 PAI
- MODULE user_command_0100 INPUT.
- ...
- WHEN SPACE.
- SELECT SINGLE FROM customers WHERE id
customers-id. - IF sy-subrc ltgt 0.
- MESSAGE E000(38) WITH Customers data
not found. - ELSE.
- LEAVE TO SCREEN 200.
- ENDIF.
- ENDCASE.
- ENDMODULE.
-
44Field Input Checking
- If you want to check input values in the module
pool and start dialog in the event of a negative
result,you use the FIELD statement with the
addition MODULE. - If the module results in an error(E) or
warning(W) message,the screen is redisplayed
without processing the PBO modules.The message
text is displayed and only the field being
checked by this module becomes ready for input
again
45Field Statement With More Than 1 Field
- Screen 100 Flow Logic (PAI)
- PROCESS AFTER INPUT.
- CHAIN.
- FIELD customers-id,customers-custtype
- MODULE user_command_0100.
- ENDCHAIN.
PROCESS AFTER INPUT. CHAIN. FIELD
customers-id MODULE user_command_0100. FIELD
customers-custtype MODULE user_command_0100.
ENDCHAIN.
46Field Statement Data Transport
- PROCESS AFTER INPUT.
- MODULE a.
- FILED f1 MODULE b.
- FILED f2 MODULE c.
- MODULE d.
- Transfer f3,f4
- Call module a
- Transfer f1
- Call module b
- Transfer f2
- Call module c
- Call module d
Screen 100
f1
f2
f3
f4
47Required Field
48Required Field
49Required Field
50At exit-command
51Function Type Exit Command
52At exit-command
- When user chooses a function with type
E,the screen flow logic jumps directly to the
following statement - MODULE ltmodulegt AT EXIT-COMMAND
- No other screen fields are transported to the
program except OK Code field
53At exit-command
- Screen 100 Flow Logic
- PROCESS BEFORE OUTPUT.
- MODULE STATUS_0100.
- PROCESS AFTER INPUT.
- MODULE exit AT EXIT-COMMAND.
- MODULE USER_COMMAND_0100.
-
54At exit-command
- Screen 100 PAI
- MODULE exit INPUT.
- CASE ok_code.
- WHEN EXIT.
- LEAVE PROGRAM.
- ENDCASE.
- ENDMODULE.
-
LEAVE PROGRAM.
55Function Module (POPUP_TO_CONFIRM_LOSS_OF_DATA)
56Example IV
- Maintain Customer Data
- Popup confirmation data using function
- POPUP_TO_CONFIRM_LOSS_OF_DATA
57Example IV
- TOP Include
- ...
- DATA ans.
-
-
58Example IV
- Screen 100 PAI
- MODULE exit INPUT.
- CALL FUNCTION POPUP_TO_CONFIRM_LOSS_OF_DA
TA - EXPORTING
- textline1 Are you sure?
- titel Please Confirm!!!
- IMPORTING
- answer ans.
- IF ans J. J Ja in German Yes in
English - LEAVE PROGRAM.
- ELSE.
- ENDIF.
- ENDMODULE.
59SAP Transaction Enqueue Lock Object
60SAP Transaction DB Transaction
- Each Dialog step can contain update
requests(INSERT,DELETE,UPDATE) - After each Dialog step,the R/3 system
automatically passes a database commit to the
database system.The database system then
distributes the update requests from the
individual dialog steps across several database
transactions - A rollback in one Dialog step has no effect on
database updates performed in previous Dialog
steps
61SAP Transaction(LUW)
DB Commit
DB Commit
DB LUW
SAP LUW
62SAP Database Maintenance Steps
- Check data locking by calling function
ENQUEUE_ltlock objectgt - Read data from Database Ex. Select single
- Data Processing Ex. Update ...
- Release lock by calling function DEQUEUE_ltlock
objectgt
63SAP Lock Object
- Transaction SE11 Lock object
- ENQUEUE_ltlock objectgt
- DEQUEUE_ltlock objectgt
64SAP Lock Object Function Module
65Example IV
- ENQUEUE /DEQUEUELock Object(SE11)
- CALL FUNCTION ENQUEUE_EZCUSTltnngt
- CALL FUNCTION DEQUEUE_EZCUSTltnngt
-
User 2
User 1
66Example IV (I)
- Screen 100 PAI
- MODULE user_command_0100 INPUT.
- ...
- WHEN SPACE.
- CALL FUNCTION ENQUEUE_EZCUST00
- EXPORTING
-
- id customers-id
- EXCEPTIONS
- ...
- IF sy-subrc ltgt 0.
- MESSAGE ID SY-MSGID TYPE SY-MSGTY
NUMBER SY-MSGNO - WITH SY-MSGV1 SY-MSGV2
SY-MSGV3 SY-MSGV4. - ELSE.
- SELECT SINGLE FROM customers WHERE id
customers-id. - ...
67Example IV (II)
- Screen 100 PAI
- MODULE user_command_0100 INPUT.
- ...
- WHEN SPACE.
- CALL FUNCTION ENQUEUE_EZCUST00
- EXPORTING
- id customers-id
- ...
- IF sy-subrc ltgt 0.
- CONCATENATE Data was locked by
sy-msgv1 INTO mess. - MESSAGE E000(38) WITH mess.
- ELSE.
- SELECT SINGLE FROM customers WHERE id
customers-id. - ...
message id sy-msgid type sy-msgty number
sy-msgno with sy-msgv1
sy-msgv2 sy-msgv3 sy-msgv4.
68Example IV
- Screen 200 PAI
- MODULE user_command_0200 INPUT.
- ...
- WHEN BACK.
- CALL FUNCTION DEQUEUE_EZCUST00
- EXPORTING
-
- id customers-id.
- LEAVE TO SCREEN 100.
-
69Example IV
- Screen 200 PAI
- MODULE user_command_0200 INPUT.
- ...
- WHEN SAVE.
- UPDATE customers.
- MESSAGE S000(38) WITH Update OK!.
- CALL FUNCTION DEQUEUE_EZCUST00
- EXPORTING
-
- id customers-id.
- LEAVE TO SCREEN 100.
- ...
- ...
70Monitoring Enqueue Lock SM12