70
Dialog Programming Overview 

08.ABAP Dialog Programming Overview

  • Upload
    snnagar

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

  • Dialog Programming Overview

  • SAP System : Dialog Processing (Report)Database ServerApplication ServerDispatcherRequestQueueDDDDSAP BufferProgram134568910Report zpsm1.Tables customers.Select single * from customers where id = 1.Write: / customers-name.Execute ABAP statementCheck Program in Program Buffer7Load&Gen ProgramSQL RequestSend ListGenerate Screen(List)Send RequestRequestList2Search for free WPStore request to queueSend request to WPSAP GUI

  • Dialog WP : Executable ProgramDialog WP TaskHandlerDYNPRO ProcessorABAP ProcessorDatabaseLocal MemoryMemory SpaceDB Interface List BufferResult Set Memory

  • Types of ABAP Report1. Report Listing2. Drill-down Report3. Control-break Report4. ALV Report134

  • SAP System : Dialog Processing (DIALOG)Database ServerApplication ServerDispatcherRequestQueueDDDDSAP BufferProgram134568910Program sapmzex001.Include .Set screen 100.Execute ABAP statementCheck Program in Program Buffer7Load&Gen ProgramSQL RequestSend ListGenerate Dialog ScreenSend RequestRequestScreen2Search for free WPStore request to queueSend request to WPSAP GUI

  • Dialog WP : Dialog ProgramDialog WP TaskHandlerDYNPRO ProcessorABAP ProcessorDatabaseLocal MemoryABAP Memory DB Interface Screen BufferResult Set Memory

  • Dialog Program : Transaction

  • Dialog Program ComponentsTransaction CodeScreen : 100(Screen Layout)

    Screen : 200(Screen Layout)

    Flow LogicFlow LogicPBOPAIABAP Module PoolABAP Module PoolPBOPAIABAP Module PoolABAP Module Pool

    Dialog Program

    Program Naming Convention : SAPM

  • SAP TransactionAn 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 displayIn the course of a Dialog step,The PAI modules belonging to the current screen and the PBO modules belonging to the next screenDB CommitDB Commit

  • Data Transfer (Local Memory) Screen Buffer

    ABAP Memory Space

    Screen Work AreaABAP Work AreaPBOPAIcustomers-idcustomers-namecustomers id name city 0000000ok_codeok_codeLocal MemoryElement List

  • Flow LogicProcess 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.

  • OK Code Field in ScreenOK Code Field orCommand Field(ok_code in Element List)

  • Defining Screen (4 Steps) Screen AttributeScreen LayoutFlow LogicElement ListElement List(ok_code field)

  • Flow Logic in Screen 100PROCESS BEFORE OUTPUT.MODULE STATUS_0100.

    PROCESS AFTER INPUT. MODULE USER_COMMAND_0100.

  • PBO in Screen 100MODULE status_0100 OUTPUT.SET PF-STATUS 0100. SET TITLEBAR 0100.ENDMODULE.

  • PAI in Screen 100MODULE 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.

  • How to Create Dialog ProgramTransaction SE80 : Create Dialog ProgramCreate Screen(4 steps)Screen AttributeScreen LayoutFlow Logic(PBO,PAI)Define Variable ok_code in Element ListDefine Data Object in ABAP Work Area at TOP Include(Tables, Data,...)Check and Activate Dialog ProgramCreate Transaction Code

  • Example IMaintain Customers DataScreen : 100Screen : 200

  • Example ICreate Dialog Program SAPMZEX for changing Customers tableScreen 100Field customers-idScreen 200Field customers-id and customers-name

  • Example IScreen 100

    PROCESS BEFORE OUTPUT. MODULE STATUS_0100.

    PROCESS AFTER INPUT. MODULE USER_COMMAND_0100.

  • Example IScreen 100

    MODULE status_0100 OUTPUT. SET PF-STATUS 0100. SET TITLEBAR 0100. ENDMODULE.

  • Example IScreen 100MODULE 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.

  • Example IScreen 200

    PROCESS BEFORE OUTPUT. MODULE STATUS_0200.

    PROCESS AFTER INPUT. MODULE USER_COMMAND_0200.

  • Example IScreen 200

    MODULE status_0200 OUTPUT. SET PF-STATUS 0200. SET TITLEBAR 0200. ENDMODULE.

  • Example IScreen 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.

  • Example ITOP IncludeTABLES customers.DATA ok_code TYPE sy-ucomm.Create Transaction CodeTransaction Code : ZEX

  • ExerciseCreate Dialog Program : SAPMZCUSTTransaction Code : ZCUST

  • Exercise : Customers MaintenanceScreen : 100Screen : 200

  • Setting the Cursor Position DynamicallyCursor PositionPROCESS BEFORE OUTPUT. MODULE STATUS_0200. MODULE set_cursor.

    MODULE set_cursor OUTPUT. SET CURSOR FIELD CUSTOMERS-CITY OFFSET 3. ENDMODULE.

  • Avoiding the Unexpected Processing Step of ok_code Field

  • 1. Auxiliary OK_CODE VariableTOP IncludeTABLES customers.DATA ok_code TYPE sy-ucomm.DATA save_ok TYPE sy-ucomm.

  • Example I - ChangeScreen 100 : PAIMODULE 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.

  • Example I - ChangeScreen 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.

  • 2. Specify the Enter Function at GUI Status

  • Check Enter FunctionScreen 100 : PAIMODULE 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.

  • 3. Clear OK_CODE at PBOScreen 100 : Flow Logic

    PROCESS BEFORE OUTPUT. MODULE STATUS_0100. MODULE clear_ok_code.

    PROCESS AFTER INPUT. MODULE USER_COMMAND_0100.

  • Clear OK_CODE at PBOScreen 100 : PBOMODULE status_0100 OUTPUT. SET PF-STATUS 0100. SET TITLEBAR 0100. ENDMODULE.

    MODULE clear_ok_code OUTPUT. CLEAR ok_code. ENDMODULE.

  • Checking User Input

  • Example IIMaintain Customers Data Check Input Data Manually

  • Example IIScreen 100 : PAIMODULE user_command_0100 INPUT. ... WHEN SPACE. SELECT SINGLE * FROM customers WHERE id = customers-id. IF sy-subrc 0. MESSAGE S000(38) WITH Customers data not found. LEAVE TO SCREEN 100. ELSE. LEAVE TO SCREEN 200. ENDIF. ENDCASE. ENDMODULE.

  • Example IIIMaintain Customers Data Check Input Data Using Field Command

  • Example III Field StatementScreen 100 : Flow Logic (PAI) PROCESS AFTER INPUT. FIELD customers-id MODULE user_command_0100.

  • Example IIIScreen 100 : PAIMODULE user_command_0100 INPUT. ... WHEN SPACE. SELECT SINGLE * FROM customers WHERE id = customers-id. IF sy-subrc 0. MESSAGE E000(38) WITH Customers data not found. ELSE. LEAVE TO SCREEN 200. ENDIF. ENDCASE. ENDMODULE.

  • Field Input CheckingIf 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

  • Field Statement With More Than 1 FieldScreen 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.

  • Field Statement & Data TransportPROCESS AFTER INPUT. MODULE a. FILED f1 MODULE b. FILED f2 MODULE c. MODULE d.

    f1f2f3f4Screen 100Transfer f3,f4Call module aTransfer f1Call module bTransfer f2Call module cCall module d

  • Required Field

  • Required Field

  • Required Field

  • At exit-command

  • Function Type : Exit Command

  • When user chooses a function with type E,the screen flow logic jumps directly to the following statement MODULE AT EXIT-COMMAND No other screen fields are transported to the program except OK Code fieldAt exit-command

  • At exit-commandScreen 100 : Flow Logic

    PROCESS BEFORE OUTPUT. MODULE STATUS_0100.

    PROCESS AFTER INPUT. MODULE exit AT EXIT-COMMAND. MODULE USER_COMMAND_0100.

  • At exit-commandScreen 100 : PAI

    MODULE exit INPUT. CASE ok_code. WHEN EXIT. LEAVE PROGRAM. ENDCASE. ENDMODULE.LEAVE PROGRAM.

  • Function Module (POPUP_TO_CONFIRM_LOSS_OF_DATA)

  • Example IVMaintain Customer Data Popup confirmation data using function POPUP_TO_CONFIRM_LOSS_OF_DATA

  • Example IVTOP Include... DATA ans.

  • Example IVScreen 100 : PAIMODULE exit INPUT. CALL FUNCTION POPUP_TO_CONFIRM_LOSS_OF_DATA 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.

  • SAP Transaction : Enqueue Lock Object

  • SAP Transaction & DB TransactionEach 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 transactionsA rollback in one Dialog step has no effect on database updates performed in previous Dialog steps

  • SAP Transaction(LUW)DB CommitDB CommitSAP LUWDB LUW

  • SAP Database Maintenance Steps Check data locking by calling function ENQUEUE_Read data from Database Ex. Select single Data Processing Ex. Update ...Release lock by calling function DEQUEUE_

  • SAP Lock ObjectTransaction SE11 : Lock objectENQUEUE_DEQUEUE_

  • SAP Lock Object : Function Module

  • Example IVENQUEUE /DEQUEUELock Object(SE11)CALL FUNCTION ENQUEUE_EZCUST CALL FUNCTION DEQUEUE_EZCUST

    User 1User 2

  • Example IV (I)Screen 100 : PAIMODULE user_command_0100 INPUT. ... WHEN SPACE. CALL FUNCTION ENQUEUE_EZCUST00 EXPORTING id = customers-id EXCEPTIONS ... IF sy-subrc 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. ...

  • Example IV (II)Screen 100 : PAIMODULE user_command_0100 INPUT. ... WHEN SPACE. CALL FUNCTION ENQUEUE_EZCUST00 EXPORTING id = customers-id ... IF sy-subrc 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.

  • Example IVScreen 200 : PAIMODULE user_command_0200 INPUT. ... WHEN BACK. CALL FUNCTION DEQUEUE_EZCUST00 EXPORTING id = customers-id. LEAVE TO SCREEN 100.

  • Example IVScreen 200 : PAIMODULE 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. ... ...

  • Monitoring Enqueue Lock : SM12