Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Dialog Programming Overview

4,632 views

Published on

8th part of series shared on http://sapdocs.info/sap/abap/documents-for-sap-abap-beginners/

Published in: Business, Technology
  • I have done a couple of papers through ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ they have always been great! They are always in touch with you to let you know the status of paper and always meet the deadline!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • See how I make over $7,293 a month from home doing REAL online jobs! ■■■ http://t.cn/AisJWzdm
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ♥♥♥ http://bit.ly/39pMlLF ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Sex in your area is here: ♥♥♥ http://bit.ly/39pMlLF ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Dialog Programming Overview

  1. 1. Dialog Programming Overview
  2. 2. SAP System : Dialog Processing (Report) Database Server Application Server Dispatcher Request Queue D D D D … SAP Buffer Program … … 1 3 4 5 6 8 9 10 Report zpsm1. Tables customers. Select single * from customers where id = 1. Write: / customers-name. Execute ABAP statement Check Program in Program Buffer 7 Load&Gen Program SQL Request Send List Generate Screen(List) Send Request Request List 2 Search for free WP Store request to queue Send request to WP SAP GUI
  3. 3. Dialog WP : Executable Program <ul><ul><ul><ul><li>Dialog WP </li></ul></ul></ul></ul>TaskHandler DYNPRO Processor ABAP Processor Database Local Memory Memory Space DB Interface List Buffer Result Set Memory
  4. 4. Types of ABAP Report 1. Report Listing 2. Drill-down Report 3. Control-break Report 4. ALV Report 1 3 4
  5. 5. SAP System : Dialog Processing (DIALOG) Database Server Application Server Dispatcher Request Queue D D D D … SAP Buffer Program … … 1 3 4 5 6 8 9 10 Program sapmzex001. Include …. Set screen 100. … Execute ABAP statement Check Program in Program Buffer 7 Load&Gen Program SQL Request Send List Generate Dialog Screen Send Request Request Screen 2 Search for free WP Store request to queue Send request to WP SAP GUI
  6. 6. Dialog WP : Dialog Program <ul><ul><ul><ul><li>Dialog WP </li></ul></ul></ul></ul>TaskHandler DYNPRO Processor ABAP Processor Database Local Memory ABAP Memory DB Interface Screen Buffer Result Set Memory
  7. 7. Dialog Program : Transaction
  8. 8. Dialog Program Components Transaction Code Screen : 100 (Screen Layout) Screen : 200 (Screen Layout) Flow Logic Flow Logic PBO PAI ABAP Module Pool ABAP Module Pool PBO PAI ABAP Module Pool ABAP Module Pool Dialog Program Program Naming Convention : SAPM …
  9. 9. SAP Transaction <ul><li>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 </li></ul><ul><li>In the course of a Dialog step,The PAI modules belonging to the current screen and the PBO modules belonging to the next screen </li></ul>DB Commit DB Commit
  10. 10. Data Transfer (Local Memory) Screen Buffer ABAP Memory Space Screen Work Area ABAP Work Area PBO PAI customers-id customers-name customers id name city … 0000000 ok_code ok_code Local Memory Element List
  11. 11. Flow Logic <ul><li>Process Before Output(PBO) </li></ul><ul><ul><li>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. </li></ul></ul><ul><li>Process After Input(PAI) </li></ul><ul><ul><li>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. </li></ul></ul>
  12. 12. OK Code Field in Screen OK Code Field or Command Fi e ld (ok_code in Element List)
  13. 13. Defining Screen (4 Steps) <ul><li>Screen Attribute </li></ul><ul><li>Screen Layout </li></ul><ul><li>Flow Logic </li></ul><ul><li>Element List </li></ul>Element List(ok_code field)
  14. 14. Flow Logic in Screen 100 <ul><li>PROCESS BEFORE OUTPUT. </li></ul><ul><li>MODULE STATUS_0100. </li></ul><ul><li>PROCESS AFTER INPUT. </li></ul><ul><li>MODULE USER_COMMAND_0100. </li></ul>
  15. 15. PBO in Screen 100 <ul><li>MODULE status_0100 OUTPUT. </li></ul><ul><li>SET PF-STATUS ‘0100’. </li></ul><ul><li>SET TITLEBAR ‘0100’. </li></ul><ul><li>ENDMODULE. </li></ul>
  16. 16. PAI in Screen 100 <ul><li>MODULE user_command_0100 INPUT. </li></ul><ul><li>CASE ok_code. </li></ul><ul><li>WHEN ‘EXIT’. “Leave program </li></ul><ul><li>SET SCREEN 0. LEAVE SCREEN. “Leave to screen 0 </li></ul><ul><li>WHEN ‘SAVE’. </li></ul><ul><li>UPDATE customers. </li></ul><ul><li>MESSAGE S000(38) WITH ‘Update OK’. </li></ul><ul><li>SET SCREEN 50. LEAVE SCREEN. </li></ul><ul><li>ENDCASE. </li></ul><ul><li>ENDMODULE. </li></ul>
  17. 17. How to Create Dialog Program <ul><li>Transaction SE80 : Create Dialog Program </li></ul><ul><li>Create Screen(4 steps) </li></ul><ul><ul><li>Screen Attribute </li></ul></ul><ul><ul><li>Screen Layout </li></ul></ul><ul><ul><li>Flow Logic(PBO,PAI) </li></ul></ul><ul><ul><li>Define Variable ok_code in Element List </li></ul></ul><ul><li>Define Data Object in ABAP Work Area at TOP Include(Tables, Data,...) </li></ul><ul><li>Check and Activate Dialog Program </li></ul><ul><li>Create Transaction Code </li></ul>
  18. 18. Example I Maintain Customers Data Screen : 100 Screen : 200
  19. 19. Example I <ul><li>Create Dialog Program SAPMZEX < nn > for changing Customers table </li></ul><ul><ul><li>Screen 100 </li></ul></ul><ul><ul><ul><li>Field customers-id </li></ul></ul></ul><ul><ul><li>Screen 200 </li></ul></ul><ul><ul><ul><li>Field customers-id and customers-name </li></ul></ul></ul>
  20. 20. Example I <ul><li>Screen 100 </li></ul><ul><li>PROCESS BEFORE OUTPUT. </li></ul><ul><li> MODULE STATUS_0100. </li></ul><ul><li>PROCESS AFTER INPUT. </li></ul><ul><li>MODULE USER_COMMAND_0100. </li></ul>
  21. 21. Example I <ul><li>Screen 100 </li></ul><ul><li>MODULE status_0100 OUTPUT. </li></ul><ul><li>SET PF-STATUS ‘0100’. </li></ul><ul><li>SET TITLEBAR ‘0100’. </li></ul><ul><li>ENDMODULE. </li></ul>
  22. 22. Example I <ul><li>Screen 100 </li></ul><ul><li>MODULE user_command_0100 INPUT. </li></ul><ul><li>CASE ok_code. </li></ul><ul><li>WHEN ‘BACK’. </li></ul><ul><li>LEAVE PROGRAM. “leave to screen 0 </li></ul><ul><li>WHEN space. “if not assign Enter Key </li></ul><ul><li>SELECT SINGLE * FROM customers </li></ul><ul><li>WHERE id = customers-id. </li></ul><ul><li>LEAVE TO SCREEN 200. </li></ul><ul><li>ENDCASE. </li></ul><ul><li>ENDMODULE. </li></ul>
  23. 23. Example I <ul><li>Screen 200 </li></ul><ul><li>PROCESS BEFORE OUTPUT. </li></ul><ul><li> MODULE STATUS_0200. </li></ul><ul><li>PROCESS AFTER INPUT. </li></ul><ul><li>MODULE USER_COMMAND_0200. </li></ul>
  24. 24. Example I <ul><li>Screen 200 </li></ul><ul><li>MODULE status_0200 OUTPUT. </li></ul><ul><li>SET PF-STATUS ‘0200’. </li></ul><ul><li>SET TITLEBAR ‘0200’. </li></ul><ul><li>ENDMODULE. </li></ul>
  25. 25. Example I <ul><li>Screen 200 </li></ul><ul><li>MODULE user_command_0200 INPUT. </li></ul><ul><li>CASE ok_code. </li></ul><ul><li>WHEN ‘BACK’. </li></ul><ul><li>LEAVE TO SCREEN 100. “set screen 100 </li></ul><ul><li>WHEN ‘SAVE’. </li></ul><ul><li>UPDATE customers. </li></ul><ul><li>MESSAGE S000(38) WITH ‘Update OK!’. </li></ul><ul><li>LEAVE TO SCREEN 100. </li></ul><ul><li>ENDCASE. </li></ul><ul><li>ENDMODULE. </li></ul>
  26. 26. Example I <ul><li>TOP Include </li></ul><ul><li>TABLES customers. </li></ul><ul><li>DATA ok_code TYPE sy-ucomm. </li></ul><ul><li>Create Transaction Code </li></ul><ul><li>Transaction Code : ZEX< nn > </li></ul>
  27. 27. Exercise Create Dialog Program : SAPMZ CUST< nn > Transaction Code : Z CUST< nn >
  28. 28. Exercise : Customers Maintenance Screen : 100 Screen : 200
  29. 29. Setting the Cursor Position Dynamically Cursor Position PROCESS BEFORE OUTPUT. MODULE STATUS_0200. MODULE set_cursor. MODULE set_cursor OUTPUT. SET CURSOR FIELD ‘CUSTOMERS-CITY’ OFFSET 3. ENDMODULE.
  30. 30. Avoiding the Unexpected Processing Step of ok_code Field
  31. 31. 1. Auxiliary OK_CODE Variable <ul><li>TOP Include </li></ul><ul><li>TABLES customers. </li></ul><ul><li>DATA ok_code TYPE sy-ucomm. </li></ul><ul><li>DATA save_ok TYPE sy-ucomm. </li></ul>
  32. 32. Example I - Change <ul><li>Screen 100 : PAI </li></ul><ul><li>MODULE user_command_0100 INPUT. </li></ul><ul><li>save_ok = ok_code. </li></ul><ul><li>CLEAR ok_code. </li></ul><ul><li>CASE save_ok. </li></ul><ul><li>WHEN ‘BACK’. </li></ul><ul><li>LEAVE PROGRAM. </li></ul><ul><li>WHEN space. </li></ul><ul><li>SELECT SINGLE * FROM customers WHERE id = customers-id. </li></ul><ul><li>LEAVE TO SCREEN 200. </li></ul><ul><li>ENDCASE. </li></ul><ul><li>ENDMODULE. </li></ul>
  33. 33. Example I - Change <ul><li>Screen 200 : PAI </li></ul><ul><li>MODULE user_command_0200 INPUT. </li></ul><ul><li>save_ok = ok_code. </li></ul><ul><li>CLEAR ok_code. </li></ul><ul><li>CASE save_ok. </li></ul><ul><li>WHEN ‘BACK’. </li></ul><ul><li>LEAVE TO SCREEN 100. </li></ul><ul><li>WHEN space. </li></ul><ul><li>LEAVE TO SCREEN 200. </li></ul><ul><li>WHEN ‘SAVE’. </li></ul><ul><li>UPDATE customers. </li></ul><ul><li>MESSAGE s000(38) WITH ‘Update OK!’. </li></ul><ul><li>LEAVE TO SCREEN 100. </li></ul><ul><li>ENDCASE. </li></ul><ul><li>ENDMODULE. </li></ul>
  34. 34. 2. Specify the Enter Function at GUI Status
  35. 35. Check Enter Function <ul><li>Screen 100 : PAI </li></ul><ul><li>MODULE user_command_0100 INPUT. </li></ul><ul><li>CASE ok_code. </li></ul><ul><li>WHEN ‘BACK’. </li></ul><ul><li>LEAVE PROGRAM. </li></ul><ul><li>WHEN ‘ ENTE ’. </li></ul><ul><li>SELECT SINGLE * FROM customers </li></ul><ul><li>WHERE id = customers-id. </li></ul><ul><li>LEAVE TO SCREEN 200. </li></ul><ul><li>ENDCASE. </li></ul><ul><li>ENDMODULE. </li></ul>
  36. 36. 3. Clear OK_CODE at PBO <ul><li>Screen 100 : Flow Logic </li></ul><ul><li>PROCESS BEFORE OUTPUT. </li></ul><ul><li> MODULE STATUS_0100. </li></ul><ul><li>MODULE clear_ok_code. </li></ul><ul><li>PROCESS AFTER INPUT. </li></ul><ul><li>MODULE USER_COMMAND_0100. </li></ul>
  37. 37. Clear OK_CODE at PBO <ul><li>Screen 100 : PBO </li></ul><ul><li>MODULE status_0100 OUTPUT. </li></ul><ul><li>SET PF-STATUS ‘0100’. </li></ul><ul><li>SET TITLEBAR ‘0100’. </li></ul><ul><li>ENDMODULE. </li></ul><ul><li>MODULE clear_ok_code OUTPUT. </li></ul><ul><li>CLEAR ok_code. </li></ul><ul><li>ENDMODULE. </li></ul>
  38. 38. Checking User Input
  39. 39. Example II <ul><li>Maintain Customers Data </li></ul><ul><li>Check Input Data Manually </li></ul>
  40. 40. Example II <ul><li>Screen 100 : PAI </li></ul><ul><li>MODULE user_command_0100 INPUT. </li></ul><ul><li>... </li></ul><ul><li>WHEN SPACE. </li></ul><ul><li>SELECT SINGLE * FROM customers WHERE id = customers-id. </li></ul><ul><li>IF sy-subrc <> 0. </li></ul><ul><li>MESSAGE S000(38) WITH ‘Customers data not found’. </li></ul><ul><li>LEAVE TO SCREEN 100. </li></ul><ul><li>ELSE. </li></ul><ul><li>LEAVE TO SCREEN 200. </li></ul><ul><li>ENDIF. </li></ul><ul><li>ENDCASE. </li></ul><ul><li>ENDMODULE. </li></ul>
  41. 41. Example III <ul><li>Maintain Customers Data </li></ul><ul><li>Check Input Data Using Field Command </li></ul>
  42. 42. Example III – Field Statement <ul><li>Screen 100 : Flow Logic (PAI) </li></ul><ul><li>PROCESS AFTER INPUT. </li></ul><ul><li>FIELD customers-id MODULE user_command_0100. </li></ul>
  43. 43. Example III <ul><li>Screen 100 : PAI </li></ul><ul><li>MODULE user_command_0100 INPUT. </li></ul><ul><li>... </li></ul><ul><li>WHEN SPACE. </li></ul><ul><li>SELECT SINGLE * FROM customers WHERE id = customers-id. </li></ul><ul><li>IF sy-subrc <> 0. </li></ul><ul><li>MESSAGE E000(38) WITH ‘Customers data not found’. </li></ul><ul><li>ELSE. </li></ul><ul><li>LEAVE TO SCREEN 200. </li></ul><ul><li>ENDIF. </li></ul><ul><li>ENDCASE. </li></ul><ul><li>ENDMODULE. </li></ul>
  44. 44. Field Input Checking <ul><li>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. </li></ul><ul><li>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 </li></ul>
  45. 45. Field Statement With More Than 1 Field <ul><li>Screen 100 : Flow Logic (PAI) </li></ul><ul><li>PROCESS AFTER INPUT. </li></ul><ul><li>CHAIN. </li></ul><ul><li>FIELD: customers-id,customers-custtype </li></ul><ul><li>MODULE user_command_0100. </li></ul><ul><li> ENDCHAIN. </li></ul>PROCESS AFTER INPUT. CHAIN. FIELD customers-id MODULE user_command_0100. FIELD customers-custtype MODULE user_command_0100. ENDCHAIN.
  46. 46. Field Statement & Data Transport <ul><li>PROCESS AFTER INPUT. </li></ul><ul><li>MODULE a. </li></ul><ul><li>FILED f1 MODULE b. </li></ul><ul><li>FILED f2 MODULE c. </li></ul><ul><li>MODULE d. </li></ul>f1 f2 f3 f4 Screen 100 <ul><li>Transfer f3,f4 </li></ul><ul><li>Call module a </li></ul><ul><li>Transfer f1 </li></ul><ul><li>Call module b </li></ul><ul><li>Transfer f2 </li></ul><ul><li>Call module c </li></ul><ul><li>Call module d </li></ul>
  47. 47. Required Field
  48. 48. Required Field
  49. 49. Required Field
  50. 50. At exit-command
  51. 51. Function Type : Exit Command
  52. 52. <ul><li>When user chooses a function with type E,the screen flow logic jumps directly to the following statement </li></ul><ul><li> MODULE <module> AT EXIT-COMMAND </li></ul><ul><li>No other screen fields are transported to the program except OK Code field </li></ul>At exit-command
  53. 53. At exit-command <ul><li>Screen 100 : Flow Logic </li></ul><ul><li>PROCESS BEFORE OUTPUT. </li></ul><ul><li> MODULE STATUS_0100. </li></ul><ul><li>PROCESS AFTER INPUT. </li></ul><ul><li>MODULE exit AT EXIT-COMMAND. </li></ul><ul><li>MODULE USER_COMMAND_0100. </li></ul>
  54. 54. At exit-command <ul><li>Screen 100 : PAI </li></ul><ul><li>MODULE exit INPUT. </li></ul><ul><li>CASE ok_code. </li></ul><ul><li>WHEN ‘EXIT’. </li></ul><ul><li>LEAVE PROGRAM . </li></ul><ul><li>ENDCASE. </li></ul><ul><li>ENDMODULE. </li></ul>LEAVE PROGRAM.
  55. 55. Function Module ( POPUP_TO_CONFIRM_LOSS_OF_DATA)
  56. 56. Example IV <ul><li>Maintain Customer Data </li></ul><ul><li>Popup confirmation data using function </li></ul><ul><li>‘ POPUP_TO_CONFIRM_LOSS_OF_DATA’ </li></ul>
  57. 57. Example IV <ul><li>TOP Include </li></ul><ul><li>... </li></ul><ul><li>DATA ans. </li></ul>
  58. 58. Example IV <ul><li>Screen 100 : PAI </li></ul><ul><li>MODULE exit INPUT. </li></ul><ul><li>CALL FUNCTION ‘ POPUP_TO_CONFIRM_LOSS_OF_DATA ’ </li></ul><ul><li>EXPORTING </li></ul><ul><li>textline1 = ‘Are you sure?’ </li></ul><ul><li>titel = ‘Please Confirm!!!’ </li></ul><ul><li>IMPORTING </li></ul><ul><li>answer = ans. </li></ul><ul><li>IF ans = ‘J’. “J = Ja in German= Yes in English </li></ul><ul><li>LEAVE PROGRAM. </li></ul><ul><li>ELSE. </li></ul><ul><li>ENDIF. </li></ul><ul><li>ENDMODULE. </li></ul>
  59. 59. SAP Transaction : Enqueue Lock Object
  60. 60. SAP Transaction & DB Transaction <ul><li>Each Dialog step can contain update requests(INSERT,DELETE,UPDATE) </li></ul><ul><li>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 </li></ul><ul><li>A rollback in one Dialog step has no effect on database updates performed in previous Dialog steps </li></ul>
  61. 61. SAP Transaction(LUW) DB Commit DB Commit SAP LUW DB LUW
  62. 62. SAP Database Maintenance Steps <ul><li>Check data locking by calling function ‘ENQUEUE_< lock object >’ </li></ul><ul><li>Read data from Database Ex. Select single … </li></ul><ul><li>Data Processing Ex. Update ... </li></ul><ul><li>Release lock by calling function ‘DEQUEUE_< lock object >’ </li></ul>
  63. 63. SAP Lock Object <ul><li>Transaction SE11 : Lock object </li></ul><ul><ul><li>ENQUEUE_< lock object > </li></ul></ul><ul><ul><li>DEQUEUE_< lock object > </li></ul></ul>
  64. 64. SAP Lock Object : Function Module
  65. 65. Example IV <ul><li>ENQUEUE /DEQUEUELock Object(SE11) </li></ul><ul><li>CALL FUNCTION ‘ENQUEUE_EZCUST < nn > ’ </li></ul><ul><li>CALL FUNCTION ‘DEQUEUE_EZCUST < nn > ’ </li></ul>User 1 User 2
  66. 66. Example IV (I) <ul><li>Screen 100 : PAI </li></ul><ul><li>MODULE user_command_0100 INPUT. </li></ul><ul><li>... </li></ul><ul><li>WHEN SPACE. </li></ul><ul><li>CALL FUNCTION ‘ENQUEUE_EZCUST00’ </li></ul><ul><li>EXPORTING </li></ul><ul><li>… </li></ul><ul><li>id = customers-id </li></ul><ul><li>EXCEPTIONS </li></ul><ul><li>... </li></ul><ul><li>IF sy-subrc <> 0. </li></ul><ul><li>MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO </li></ul><ul><li>WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. </li></ul><ul><li>ELSE. </li></ul><ul><li> SELECT SINGLE * FROM customers WHERE id = customers-id. </li></ul><ul><li>... </li></ul>
  67. 67. Example IV (II) <ul><li>Screen 100 : PAI </li></ul><ul><li>MODULE user_command_0100 INPUT. </li></ul><ul><li>... </li></ul><ul><li>WHEN SPACE. </li></ul><ul><li>CALL FUNCTION ‘ENQUEUE_EZCUST00’ </li></ul><ul><li>EXPORTING </li></ul><ul><li>id = customers-id </li></ul><ul><li>... </li></ul><ul><li>IF sy-subrc <> 0. </li></ul><ul><li>CONCATENATE ‘Data was locked by :’ sy-msgv1 INTO mess. </li></ul><ul><li>MESSAGE E000(38) WITH mess. </li></ul><ul><li>ELSE. </li></ul><ul><li> SELECT SINGLE * FROM customers WHERE id = customers-id. </li></ul><ul><li>... </li></ul>message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  68. 68. Example IV <ul><li>Screen 200 : PAI </li></ul><ul><li>MODULE user_command_0200 INPUT. </li></ul><ul><li>... </li></ul><ul><li>WHEN ‘BACK’. </li></ul><ul><li>CALL FUNCTION ‘DEQUEUE_EZCUST00’ </li></ul><ul><li>EXPORTING </li></ul><ul><li>… </li></ul><ul><li>id = customers-id. </li></ul><ul><li>LEAVE TO SCREEN 100. </li></ul><ul><li>… </li></ul>
  69. 69. Example IV <ul><li>Screen 200 : PAI </li></ul><ul><li>MODULE user_command_0200 INPUT. </li></ul><ul><li>... </li></ul><ul><li>WHEN ‘SAVE’. </li></ul><ul><li>UPDATE customers. </li></ul><ul><li>MESSAGE S000(38) WITH ‘Update OK!’. </li></ul><ul><li>CALL FUNCTION ‘DEQUEUE_EZCUST00’ </li></ul><ul><li>EXPORTING </li></ul><ul><li>… </li></ul><ul><li>id = customers-id. </li></ul><ul><li>LEAVE TO SCREEN 100. </li></ul><ul><li>... </li></ul><ul><li>... </li></ul>
  70. 70. Monitoring Enqueue Lock : SM12

×