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.

Reports

325 views

Published on

  • Be the first to comment

Reports

  1. 1. Introduction to Interactive Reporting | 4.01 March-2005 Introduction to Interactive Reporting
  2. 2. 2 March-2005 Introduction to Interactive Reporting | 4.01 Objectives • The participants will be able to: – Identify why sometimes is necessary to have Interactive nature for a report. – Relate how ABAP has provided a solution by means of Interactive Reporting.
  3. 3. 3 March-2005 Introduction to Interactive Reporting | 4.01 The Requirement
  4. 4. 4 March-2005 Introduction to Interactive Reporting | 4.01 The Solution in ABAP
  5. 5. 5 March-2005 Introduction to Interactive Reporting | 4.01 Summary • Interactive Reports first provide a basic list and then a detail list depending on the user interaction for one or more records. • User Interaction invokes an event that helps an ABAP programmer to design his program to respond to the user action.
  6. 6. 6 March-2005 Introduction to Interactive Reporting | 4.01 Questions • Why do we need Interactive Reporting ? • How does the programmer recognize a user action ?
  7. 7. ABAP Events | 4.02 March-2005 ABAP Events
  8. 8. 8 March-2005 ABAP Events | 4.02 Objectives  The participants will be able to:  Interpret ABAP Event-Driven Programming.  Identify the System Triggered events that are executed during runtime of a Report program  Identify the User Invoked List Display events, that are triggered after the report has generated the basic list.
  9. 9. 9 March-2005 ABAP Events | 4.02 REPORT ZPB001. TABLES: BSIK. DATA: VAR1(4) VALUE ‘0001’. GET BSIK. IF SY-LINNO < 5. WRITE: / BSIK-LIFNR, VAR1. ENDIF. END-OF-SELECTION. WRITE: / ‘END-OF-SELECTION’, ‘has occurred’. START-OF-SELECTION. WRITE: / ‘START-OF-SELECTION’, ‘has occurred’. Program Code Program List Flow Produced 1 3 2 Program Header START-OF-SELECTION has occurred 100000 0001 END-OF-SELECTION has occurred ABAP Event-Driven Programming
  10. 10. 10 March-2005 ABAP Events | 4.02 Runtime Event : INITIALIZATION Execute a processing block before the selection screen
  11. 11. 11 March-2005 ABAP Events | 4.02 Runtime Event : AT SELECTION-SCREEN Trigger a function code on the selection screen
  12. 12. 12 March-2005 ABAP Events | 4.02 Runtime Event: START-OF-SELECTION Can be coded explicitly, but need not be.
  13. 13. 13 March-2005 ABAP Events | 4.02 Runtime Events : GET and GET LATE Select records from logical database tables
  14. 14. 14 March-2005 ABAP Events | 4.02 Runtime Event : END-OF-SELECTION Last system event to occur. Occurs only once
  15. 15. 15 March-2005 ABAP Events | 4.02 Output Event : TOP-OF-PAGE Used for page headers for the basic list only
  16. 16. 16 March-2005 ABAP Events | 4.02 Output Event : TOP-OF-PAGE DURING LINE-SELECTION Used for page headers on detail lists
  17. 17. 17 March-2005 ABAP Events | 4.02 Output Event : END-OF-PAGE Used for page footers
  18. 18. 18 March-2005 ABAP Events | 4.02 Demonstration • Observe the following system-triggered events during execution of a Report program. – INITIALIZATION. – AT SELECTION-SCREEN. – START-OF-SELECTION. – GET <table>. – GET <table> LATE. – END-OF-SELECTION. – TOP-OF-PAGE. – END-OF-PAGE.
  19. 19. 19 March-2005 ABAP Events | 4.02 Practice • Observe the following system-triggered events during execution of a Report program. – INITIALIZATION. – AT SELECTION-SCREEN. – START-OF-SELECTION. – GET <table>. – GET <table> LATE. – END-OF-SELECTION. – TOP-OF-PAGE. – END-OF-PAGE.
  20. 20. 20 March-2005 ABAP Events | 4.02 List Display (User) Events Order of execution determined by user
  21. 21. 21 March-2005 ABAP Events | 4.02 List Display Event : AT PF## Triggered by function code PF##
  22. 22. 22 March-2005 ABAP Events | 4.02 List Display Event : AT LINE- SELECTION Triggered by function code PICK
  23. 23. 23 March-2005 ABAP Events | 4.02 List Display Event : AT USER- COMMAND Triggered by function code All Others besides PICK or PF##
  24. 24. 24 March-2005 ABAP Events | 4.02 Demonstration • Observe the following user-invoked List Display events after the Basic List has been generated by a Report Program. – AT PF##. – AT LINE-SELECTION. – AT USER-COMMAND.
  25. 25. 25 March-2005 ABAP Events | 4.02 Practice • Observe the following user-invoked List Display events after the Basic List has been generated by a Report Program. – AT PF##. – AT LINE-SELECTION. – AT USER-COMMAND.
  26. 26. 26 March-2005ABAP Events | 4.02 List Display Events (“User” Events) - Typical Usage Event Triggered by Function Code Typical User Action Assigned AT PF## PF## Function key pressed AT LINE-SELECTION PICK Mouse double-click, Or single click + F2 AT USER-COMMAND ALL OTHER CODES Click on a push- button, or select a menu item
  27. 27. 27 March-2005 ABAP Events | 4.02 When Is a List Displayed?
  28. 28. 28 March-2005 ABAP Events | 4.02 Summary • Flow of an ABAP program is controlled by events. Execution order of events does not depend on the order in which they are coded in the program. • All ABAP statements that are not coded as part of an event, are part of the event START-OF-SELECTION. This event does not need to be coded explicitly in an ABAP program. It gets triggered automatically. • END-OF-SELECTION is the last system triggered event to be processed during the runtime of a program. It occurs after all database retrievals has finished and before any User-invoked events. It occurs only once during the execution of an ABAP program. • AT PF## (when any Function key is pressed), AT LINE-SELECTION (when the user double-clicks on a line) and AT USER-COMMAND (Clicking on a pushbutton or selecting a menu item) are three different user-invoked events that are handled from an ABAP program.
  29. 29. 29 March-2005 ABAP Events | 4.02 Questions • What are the different events in an ABAP program that can be triggered before user interaction ? When do they get triggered ? • What are the user-invoked events for a list display ? • What are the events used for displaying Headers and Footers in a list ? When are these events invoked ? • Which part of a code in a program are executed for an event ?
  30. 30. The AT PF ## Event | 4.03 March-2005 The AT PF ## Event
  31. 31. 31 March-2005 The AT PF ## Event | 4.03 Objectives  The participants will be able to:  Define the AT PF ## EVENT.  Identify Function Keys reserved by ABAP.  View and experiment coding examples.  Apply the SY-LSIND system field.
  32. 32. 32 March-2005 The AT PF ## Event | 4.03 Starts at the beginning of the code Completes at the end of the code Event-driven Language The events can execute in any order. Some may never even execute at all. 1st 3rd 2nd VSProcedural Language Event z Event y Event x Event w ABAP is an Event-Driven Language
  33. 33. 33 March-2005 The AT PF ## Event | 4.03 List Display Event : AT PF## Triggered by function code: PF##
  34. 34. 34 March-2005 The AT PF ## Event | 4.03 REPORT Y190XX01. TABLES: LFA1. START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. ENDSELECT. AT PF06. WRITE: / ‘The user has just pressed the F6 key’. SYNTAX: AT PF<##>. PF## Coding Example A New ABAP Event . SELECT * SY-SUBRC CHECK
  35. 35. 35 March-2005 The AT PF ## Event | 4.03 F1 Reserved for the Help function F2 The user will press the F2 key to select a specific line of interest in your report. F3 The user will press the F3 key to go back one screen in your report. Just as a test, place your mouse on the green back arrow on the ABAP Editor toolbar. What does the little yellow flag say? F4 The user will press the F4 key to see possible values that can be entered into a field. F10 The user will press the F10 key to switch into menu select mode. Try it. Go to the ABAP Editor and press F10. F12 The user will press the F12 key to quit. Its the same as clicking on the red X that is located on the ABAP Editor toolbar. F15 (Shift + F3) The user will press the F15 key to End. Its the same as clicking on the yellow up arrow that is located on the ABAP Editor toolbar. F21 (Shift + F9) The user will press the F21 key to scroll to the beginning. F22 (Shift + F10) The user will press the F22 key to scroll back one page. F23 (Shift + F11) The user will press the F23 key to scroll forward one page. F24 (Shift + F12) F24 -> scroll to the end. Function Keys Reserved by SAP
  36. 36. 36 March-2005 The AT PF ## Event | 4.03 Demonstration • Invoking AT PF## Events from a basic list.
  37. 37. 37 March-2005 The AT PF ## Event | 4.03 Practice • Invoking AT PF## Events from a basic list.
  38. 38. 38 March-2005 The AT PF ## Event | 4.03 Coding Example : AT PF## with Multiple Events . . REPORT Y190XX01. TABLES: LFA1. START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. ENDSELECT. AT PF06. WRITE: / ‘The user just pressed the F6 key’. AT PF07. WRITE: / ‘The user just pressed the F7 key’. When the user presses the F6 key only the code between the two arrows will execute.
  39. 39. 39 March-2005 The AT PF ## Event | 4.03 *--BEGIN OF AT PF06 EVENT MODULE.----------------------------------------- AT PF06. WRITE: / ‘The user just pressed the F6 key’. *--END OF AT PF06 EVENT MODULE.-------------------------------------------- *--BEGIN OF AT PF07 EVENT MODULE.----------------------------------------- AT PF07. WRITE: / ‘The user just pressed the F7 key’. *--END OF AT PF07 EVENT MODULE.-------------------------------------------- Commenting Events in ABAP Commenting in this manner helps to make the start and end of an event more apparent.
  40. 40. 40 March-2005 The AT PF ## Event | 4.03 Coding Example : Opening a Window SYNTAX: WINDOW STARTING AT <# #> ENDING AT <# #>. . . REPORT Y190XX01. TABLES: LFA1. START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. ENDSELECT. AT PF06. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘The user just pressed the F6 key’. AT PF07. WRITE: / ‘The user just pressed the F7 key’. A New ABAP Reserved WordSELECT * SY-SUBRC CHECK
  41. 41. 41 March-2005 The AT PF ## Event | 4.03 TITLE COLUMN 10 COLUMN 77 TITLE ROW 4 ROW 12 WINDOW STARTING AT… ENDING AT... SYNTAX: WINDOW STARTING AT <# #> ENDING AT <# #>.
  42. 42. 42 March-2005 The AT PF ## Event | 4.03 Potential Problems with Creating Additional Screens Hey!?! What’s up here??? 1. 2. 3.
  43. 43. 43 March-2005 The AT PF ## Event | 4.03 The SY-LSIND System Field Basic List SY-LSIND = 0 1st Detail List SY-LSIND = 1 2nd Detail List SY-LSIND = 2 A New ABAP System FieldSYSTEM FIELD: SY-LSIND F6 F6
  44. 44. 44 March-2005 The AT PF ## Event | 4.03 AT PF06. CHECK SY-LSIND = 1. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘SY-LSIND =’, SY-LSIND. WRITE: / ‘The user just pressed the F6 key’. AT PF07. WRITE: / ‘The user just pressed the F7 key’. Coding Example : SY-LSIND System Field Check that SY-LSIND is equal to 1. If SY-LSIND is not equal to one, then the rest of the AT PF06 event block does not execute.
  45. 45. 45 March-2005 The AT PF ## Event | 4.03 Here SY-LSIND is equal to 0. The user attempts to create another list. The user attempts to create another list, but cannot because CHECK SY-LSIND = 1 returns false. The contents of the initial list remain unchanged. Now SY-LSIND is equal to 1. Strategies for Dealing with Detail Lists using the SY-LSIND System Field
  46. 46. 46 March-2005 The AT PF ## Event | 4.03 Here SY-LSIND is equal to 0. The user attempts to create another list. The user attempts to create another list, but cannot because CHECK SY-LSIND = 1 returns false. The contents of the initial list remain unchanged. Now SY-LSIND is equal to 1. Lists using the SY-LSIND System Field (Contd.)
  47. 47. 47 March-2005 The AT PF ## Event | 4.03 Demonstration • Creation of additional screens from a list and restricting the user from creating redundant screens.
  48. 48. 48 March-2005 The AT PF ## Event | 4.03 Practice • Creation of additional screens from a list and restricting the user from creating redundant screens.
  49. 49. 49 March-2005 The AT PF ## Event | 4.03 START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. ENDSELECT. *-----BEGINNING OF TOP-OF-PAGE EVENT -----* TOP-OF-PAGE. WRITE: / ‘This is the header of the basic list’. *-----END OF TOP-OF-PAGE EVENT-----------------* AT PF06. CHECK SY-LSIND = 1. WRITE: / ‘The user just pressed the F6 key’. A New ABAP Event SYNTAX: TOP-OF-PAGE. Prior to the TOP-OF-PAGE event, column headings were managed via text elements. The TOP-OF-PAGE event allows you to manage your column headings through code. SELECT * SY-SUBRC CHECK Programmatically Managing Column Headings for Your Report
  50. 50. 50 March-2005 The AT PF ## Event | 4.03 *-------------------BEGINNING OF TOP-OF-PAGE----------------------* TOP-OF-PAGE. WRITE: / ‘This is the header of the basic list’. *-------------------END OF TOP-OF-PAGE *BEG. OF TOP-OF-PAGE DURING LINE-SELECTION EVENT-* TOP-OF-PAGE DURING LINE-SELECTION. WRITE: / ‘This is the header of the detail list’. *END OF TOP-OF-PAGE DURING LINE-SELECTION EVENT--* *------------------- BEGINNING OF AT PF06 EVENT-------------------* AT PF06. CHECK SY-LSIND = 1. WRITE: / ‘The user just pressed the F6 key’. The TOP-OF-PAGE DURING LINE- SELECTION event allows you to manage the column headings of the detail lists through code. SYNTAX: TOP-OF-PAGE DURING LINE-SELECTION. A New ABAP Event Coding Example : Programmatically Managing the Column Headings for Your Drill-Down Windows
  51. 51. 51 March-2005 The AT PF ## Event | 4.03 Summary • In an ABAP program, events are recognized by the Function codes. Which event has been triggered by the user is determined by the Function code. • At a time 20 detail lists can be opened. • Some Function keys are reserved for ABAP Functions. Though, ABAP program can be written to override these, but typically, reserved keys are not used unless required. • System field SY-LSIND contains the number of additional lists the user has created. This field can be used to restrict the user from creating additional windows. • TOP-OF-PAGE event triggers when the first statement for the basic list, i.e. WRITE, SKIP etc. Similarly, TOP-OF-PAGE DURING LINE- SELECTION is triggered when first list statements are encountered in a detail list.
  52. 52. 52 March-2005 The AT PF ## Event | 4.03 Questions • How does the order of execution depends on the way the events are coded inside the program ? • What is a detailed list ? • How the user can be restricted from creating unnecessary windows by pressing the same Function key or pushbutton ? • How will you create new windows with specific size ? • How can you programmatically manage the heading of basic and detail lists ?
  53. 53. The AT USER-COMMAND Event and Menu Painter | 4.04 March-2005 The AT USER-COMMAND Event and Menu Painter
  54. 54. 54 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 Objectives  The participants will be able to:  Apply the AT USER-COMMAND syntax.  Use the Graphical User Interface.  Use the SY-UCOMM system field.
  55. 55. 55 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 Graphical User Interface (GUI) Titlebar Menubar Standard Toolbar Application Toolbar
  56. 56. 56 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 Menu Painter Menu Painter Creates Function Codes Function Key Assignments Standard Toolbar Application Toolbar Menubar
  57. 57. 57 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 GUI Status The GUI Status (Graphical User Interface Status) Programmer Defined Buttons and Menus : In this sample GUI Status, the programmer decided to create a “DOCUMENTS” button, and a “LIST” menu.
  58. 58. 58 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 GUI Title The GUI Title (Graphical User Interface Title) Programmer defined titlebar
  59. 59. 59 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 ABAP Code The ABAP code TABLES: LFA1. START-OF-SELECTION. SET PF-STATUS ‘TEST1’. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, 30 LFA1-NAME1. ENDSELECT. AT USER-COMMAND. CASE SY-UCOMM. WHEN ‘RUNX’. SET PF-STATUS ‘TEST2’. SET TITLEBAR ‘TB2’. WHEN ‘RUNY’. . . . . ENDCASE. SELECT * SY-SUBRC CHECK
  60. 60. 60 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 Activating the AT USER-COMMAND Event 3rd. Behind the scenes, the ABAP processor reacts and triggers the AT USER- COMMAND event. 1st. The user clicks on a button that the programmer created on the GUI Status. 2nd. The system detects that ‘RUNY’ has been assigned as the function code behind this button.
  61. 61. 61 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 The AT USER-COMMAND Event *--begin of AT USER-COMMAND event-------------------------------- AT USER-COMMAND. WRITE: / ‘The user just clicked on a pushbutton, selected’, / ‘a menu path, or pressed a function key’. *--end of AT USER-COMMAND event----------------------------------- Do not write this code, we will learn the complete syntax momentarily. A New ABAP Event SYNTAX: AT USER-COMMAND.
  62. 62. 62 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 3rd. Behind the scenes, the ABAP processor reacts and triggers the AT USER-COMMAND event. 1st. The user clicks on a button that the programmer created on the GUI Status. 2nd. The SY-UCOMM system field is updated with the four byte “tag” RUNY A New ABAP System Field SYSTEM FIELD: SY-UCOMM The SY-UCOMM System Field
  63. 63. 63 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 *--BEGIN OF AT USER-COMMAND EVENT MODULE.-------------- AT USER-COMMAND. CASE SY-UCOMM. WHEN ‘RUNX’. WRITE: / ‘The user just pressed button X’. WHEN ‘RUNY’. WRITE: / ‘The user just pressed button Y’. ENDCASE. *--END OF AT USER-COMMAND EVENT MODULE.---------------- Using AT USER-COMMAND with the SY-UCOMM System Field Must be in all caps and single quotes
  64. 64. 64 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 Two programmer defined buttons, BUTTON X, and BUTTON Y. This is what our first interactive report, that utilises a GUI status, will look like. A programmer defined a menu containing two menu items, (menu Item X, and menu Item Y), will duplicate the functionality of our buttons. Interactive Report that Utilizes a GUI Status
  65. 65. 65 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 Demonstration •Use of AT USER-COMMAND event, system field SY-UCOMM and creation and usage of GUI components. •Create a program generating a basic list and create different kind of detail lists from the basic list depending on User Interaction.
  66. 66. 66 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 Practice • Use of AT USER-COMMAND event, system field SY-UCOMM and creation and usage of GUI components. • Create a program generating a basic list and create different kind of detail lists from the basic list depending on User Interaction.
  67. 67. 67 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 Summary • System assigns a default GUI status to all report programs. • GUI status for a program is created through ‘Menu Painter’ transaction ‘SE41’. • GUI for a program contains the following : – Function Key Assignment – Standard Toolbar – Application Toolbar – Menubar – Titlebar • Three components of interactive reporting are : – GUI status – GUI Title – ABAP Code • AT USER-COMMAND event is triggered when the user clicks on a pushbutton or selects a menu item. Which button has been clicked or which Menu item has been selected is determined by the system field SY-UCOMM.
  68. 68. 68 March-2005 The AT USER-COMMAND Event and Menu Painter | 4.04 Questions •What are the components of a GUI ? •What can be managed through the GUI status ? •How will you manage the title of your list ? •Which event is used to recognize the user action on the list ? •How do the programmer recognize which pushbutton has been clicked or which Menu item has been selected ?
  69. 69. Step-by-Step Instructions for Making a GUI |4.05 March-2005 Step-by-Step Instructions for Making a GUI
  70. 70. 70 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Objectives  The participants will be able to:  Use SET PF-STATUS syntax and be able to create a GUI Status.  Assign Function Codes to Function Keys.  Add an Icon to a Function Code.  Create Pushbuttons on the Application Toolbar.  Use The SY-PFKEY System Field.
  71. 71. 71 March-2005 Step-by-Step Instructions for Making a GUI |4.05 TABLES: LFA1. START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, 30 LFA1-NAME1. ENDSELECT. SET PF-STATUS ‘TEST1’. A New ABAP Reserved Word SELECT * SY-SUBRC CHECK  Using SET PF-STATUS and Creating a GUI Status SYNTAX: SET PF-STATUS <status name>. Coding Example
  72. 72. 72 March-2005 Step-by-Step Instructions for Making a GUI |4.05 REPORT YGUI1-XX. TABLES: LFA1. START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, 30 LFA1-NAME1. ENDSELECT. SET PF-STATUS ‘TEST1’. Double-click on the word ‘TEST1’. Double Clicking GUI Status Name SELECT * SY-SUBRC CHECK
  73. 73. 73 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Letting the System Create the GUI Status for You Choose YES
  74. 74. 74 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Entering Administrative Information Enter Some Descriptive text Choose “Normal Screen” as Status Type
  75. 75. 75 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Menu Painter Initial Display You will create that will appear on the Menu Bar of your GUI status by using these white text boxes You create the buttons that will appear on the Application Toolbar of your GUI status by using these white text boxesFunction Key assignments for all buttons are shown here Use the Drop-down button to get the Function Code
  76. 76. 76 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Expanding Menu Painter Display Application Toolbar in the Menu Painter Standard Toolbar in the Menu Painter Standard Toolbar of your program Application Toolbar of your program
  77. 77. 77 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Assigning Function Codes to Function Keys To create a function code with an icon associated to it, double-click on the function code, then choose an icon. Click once here. This is where we will define our first function code. 1st. 2nd.
  78. 78. 78 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Choose any icon. Adding an Icon to a Function Code
  79. 79. 79 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Function Code Attributes
  80. 80. 80 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Creating Pushbuttons on the Application Toolbar Type the function codes (RUNX and RUNY) of your buttons into the next available white text boxes on the application toolbar. Click SAVE to see the icons appear below the white boxes.
  81. 81. 81 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Adding a Menu Select the first available white text box for the menu bar, now populated with <List> and type “Test Menu”. Double-click on this menu title to open it up (see next slide).
  82. 82. 82 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Adding a Menu Path TIP: If you wish to create a menu item with a breakout (submenu), leave the entry in the Func. column blank, and type a menu item name in the Name column. Then type a function code in the breakout menu which appears. Type RUNX and RUNY here.
  83. 83. 83 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Automatic Recognition of Function Codes The GUI must be activated
  84. 84. 84 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Demonstration • Creation of a GUI status with pushbuttons on application toolbar and customized menu.
  85. 85. 85 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Practice • Creation of a GUI status with pushbuttons on application toolbar and customized menu.
  86. 86. 86 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Using AT USER-COMMAND to Detect Function Codes AT USER-COMMAND. CASE SY-UCOMM. WHEN ‘RUNX’. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘The user chose X’. WHEN ‘RUNY’. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘The user chose Y’. ENDCASE. Enter this code for the “AT USER- COMMAND” event.
  87. 87. 87 March-2005 Step-by-Step Instructions for Making a GUI |4.05 GUI Status for Detail Lists Do you notice the problem with this GUI Status?
  88. 88. 88 March-2005 Step-by-Step Instructions for Making a GUI |4.05 For now just use the control menu box to close this window. Problem: How does the user exit this window? There should be a button on the bottom of this window that allows the user to go back. Problem with Detail List GUI Status
  89. 89. 89 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Using a Different GUI Status Type for Dialog Boxes NEW AND IMPROVED: TEST2 Dialog box GUI Statuses automatically contain a red cancel button.
  90. 90. 90 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Demonstration • Creation of Dialog boxes with Exit button.
  91. 91. 91 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Practice • Creation of Dialog boxes with Exit button.
  92. 92. 92 March-2005 Step-by-Step Instructions for Making a GUI |4.05 A Report that Uses more than One GUI Status - Code Add this line of code. Then double-click on the word ‘TEST2’. AT USER-COMMAND. CASE SY-UCOMM. WHEN ‘RUNX’. SET PF-STATUS ‘TEST2’. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘The user chose X’. WHEN ‘RUNY’. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘The user chose Y’. ENDCASE.
  93. 93. 93 March-2005 Step-by-Step Instructions for Making a GUI |4.05 A Report that Uses More than One GUI Status - Administrative Add some descriptive text, then choose “Dialog box” as the Status Type.
  94. 94. 94 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Notice that “Dialog Box” statuses do not have menus or standard toolbars. A Report that Uses More than One GUI Status - Menu Painter
  95. 95. 95 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Function Codes Automatically Recognized by ABAPFunction Code Functionality Associated function key Button on Toolbar BACK Back F3 RW Cancel F12 %EX End F15 P-- Scroll to beginning F21 P- Scroll back one page F22 P+ Scroll forward one page F23 P++ Scroll to end F24
  96. 96. 96 March-2005 Step-by-Step Instructions for Making a GUI |4.05 AT USER-COMMAND. CASE SY-UCOMM. WHEN ‘RUNX’. SET PF-STATUS ‘TEST2’. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘The user chose X’. WHEN ‘RUNY’. SET PF-STATUS ‘TEST3’. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘The user chose Y’. ENDCASE. Add this line of code. Coding Example : A Report that Uses More Than One GUI Status
  97. 97. 97 March-2005 Step-by-Step Instructions for Making a GUI |4.05 SY-PFKEY = ‘TEST1’ SY-PFKEY = ‘TEST3’ A New ABAP System Field Which status is currently being used? SYSTEM FIELD: SY-PFKEY The SY-PFKEY System Field
  98. 98. 98 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Demonstration • Use of more than one GUI Status in a program.
  99. 99. 99 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Practice • Use of more than one GUI Status in a program.
  100. 100. 100 March-2005 Step-by-Step Instructions for Making a GUI |4.05 SYNTAX: SET TITLEBAR <titlebar name>. AT USER-COMMAND. CASE SY-UCOMM. WHEN ‘RUNX’. SET PF-STATUS ‘TEST2’. SET TITLEBAR ‘TB2’. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘The user chose X’. WHEN ‘RUNY’. SET PF-STATUS ‘TEST3’. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘The user chose Y’. ENDCASE. A New ABAP Reserved Word Coding Example: Adding a GUI Title
  101. 101. 101 March-2005 Step-by-Step Instructions for Making a GUI |4.05 First Choose Yes. Second Type in the text that you want to appear in the titlebar of your GUI Status. Use ampersands (&) if you want to use variables. Then choose Save. Adding A GUI Title - Administration
  102. 102. 102 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Program’s GUI Status 1 RUNX RUNY RUNZ Status 2 RUNX RUNA Status 3 RUNC RUNY Status 4 RUNB Function Codes for Entire GUI RUNA RUNB RUNC RUNX RUNY RUNZ Graphical User Interface
  103. 103. 103 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Summary • GUI status name can be up to 20 characters and must be in Capital letters. • SY-PFKEY contains the name of current GUI status. • ‘Dialog Box’ status does not have Menu or a Standard Toolbar. • GUI Title names can be up to 20 characters and must be in Capital letters. • Whenever we create a new window or dialog box, the exit button from the control menu must be used. Options to exit must be provided to the user. • A program can have any number of GUI statuses defined. • Function Codes can be defined with a maximum four characters long.
  104. 104. 104 March-2005 Step-by-Step Instructions for Making a GUI |4.05 Questions • What are the naming restrictions for a PF status ? • What are the naming restrictions for a GUI title ? • What is the difference between a ‘Normal Screen’ and a ‘Dialog Box’ status ? • What is the problem if the no buttons or Function codes are not included from the control menu in a dialog box ? • How many GUI status can be defined for a program ? • Can we pass parameters to GUI title ?
  105. 105. Review of Concepts: Work Areas & Internal Tables | 4.06 March-2005 Review of Concepts: Work Areas & Internal Tables
  106. 106. 106 March-2005 Review of Concepts: Work Areas & Internal Tables | 4.06 Objectives  The participants will be able to:  Recall the concept of work area.  Recall the concept of Internal tables.
  107. 107. 107 March-2005 Review of Concepts: Work Areas & Internal Tables | 4.06 LFA1 WORK AREA BSIK WORK AREA The ABAP TABLES statement creates a work area for each of the tables mentioned. Review of Concepts : Table Work Areas
  108. 108. 108 March-2005 Review of Concepts: Work Areas & Internal Tables | 4.06 DATA SOURCE LFA1 WORK AREA The ABAP SELECT statement takes data from the specified table (data source) and places it, one record at a time, into the work area. RECORD # 1 SELECT * SY-SUBRC CHECK Review of Concepts : Retrieving Data from Database Into Table Work Area
  109. 109. 109 March-2005 Review of Concepts: Work Areas & Internal Tables | 4.06 DATA SOURCE LFA1 WORK AREA RECORD # 1 RECORD # 2 No Longer Available SELECT * SY-SUBRC CHECK Review of Concepts : Replacement of Table Work Area Contents
  110. 110. 110 March-2005 Review of Concepts: Work Areas & Internal Tables | 4.06 DATA SOURCE LFA1 WORK AREA RECORD # 6 INTERNAL TABLE RECORD # 1 RECORD # 2 RECORD # 3 RECORD # 4 RECORD # 5 When an ABAP programmer creates an internal table the data is not lost. It remains available to the programmer. APPEND ITAB Review of Concepts : Using Internal Tables to Capture Incoming Data
  111. 111. 111 March-2005 Review of Concepts: Work Areas & Internal Tables | 4.06 INTERNAL TABLE RECORD # 1 RECORD # 2 RECORD # 3 LFA1 WORK AREA RECORD # 3 CLEAR LFA1. LFA1 WORK AREA REFRESH ITAB. BEFORE AFTER INTERNAL TABLE Review of Concepts : Keywords in Emptying Work Areas
  112. 112. 112 March-2005 Review of Concepts: Work Areas & Internal Tables | 4.06 Demonstration • Using Workareas and Internal tables.
  113. 113. 113 March-2005 Review of Concepts: Work Areas & Internal Tables | 4.06 Practice • Using Workareas and Internal tables.
  114. 114. 114 March-2005 Review of Concepts: Work Areas & Internal Tables | 4.06 Summary • TABLES statement in ABAP creates a workarea for the database table specified. • Workareas can hold only one record during the program execution whereas, an Internal table can hold multiple records at a time. • For the above reason, when we have to retrieve multiple entries from the database, we should be using internal tables instead of an workarea. Because use of workarea will mean we have get the data from database multiple times. • CLEAR statement deletes the content of workarea. It can be used to initialize the header line of an internal table as well. • REFRESH statement wipes off the contents of the internal table.
  115. 115. 115 March-2005 Review of Concepts: Work Areas & Internal Tables | 4.06 Questions • What is the difference between a workarea and an internal table ? • Which of these (workarea vs. Internal table) is better to use in our program when we need to retrieve multiple records ? • What are the statements to initialize workareas and internal tables ?
  116. 116. The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE)
  117. 117. 117 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Objectives  The participants will be able to :  Create drill-down screen.  Use AT LINE-SELECTION Event.  Apply SY-LISEL system field.  Apply the HIDE statement.  Interpret the HIDE memory.
  118. 118. 118 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 A “Drill Down” Screen First the user double-clicks on a record. Then a “drill down” list is created showing data relevant to the record initially selected by the user.
  119. 119. 119 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 The Challenges Second Challenge: How is this record sent back as criteria to an ABAP SELECT statement? First Challenge: How did the ABAP code “know” when and which record the user has selected? SELECT * FROM BSIK WHERE LIFNR = <selected vendor number>.
  120. 120. 120 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Illustration : (The AT LINE- SELECTION Event) A New ABAP Event SYNTAX: AT LINE-SELECTION. •Determining When the User Is Requesting Additional InformationWhen the user double-clicks a line in the report, the “AT LINE-SELECTION” event occurs (because the PICK function code is invoked).
  121. 121. 121 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 The SY-LISEL System Field A New ABAP System Field The Contents of SY-LISEL: 222 Express Vendor Inc CHICAGO SYSTEM FIELD: SY-LISEL When the user selects a line in the report, SY- LISEL is updated with the text from that line. • Determining Which Records the User Is Requesting Additional Information Upon
  122. 122. 122 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 TABLES: LFA1. START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. ENDSELECT. SELECT * SY-SUBRC CHECK Coding Example : AT LINE- SELECTION and SY-LISEL This code is continued on the next page.
  123. 123. 123 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 *--------begin of AT LINE-SELECTION event------------------------* AT LINE-SELECTION. CHECK SY-LSIND = 1. WINDOW STARTING AT 10 4 ENDING AT 77 12. WRITE: / ‘The user double-clicked on a line in the report’. WRITE: / SY-LISEL. *---------end of AT LINE-SELECTION event--------------------------* Coding Example : AT LINE- SELECTION and SY-LISEL
  124. 124. 124 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 AT LINE-SELECTION and SY-LISEL First double-click on a record. Then a second “drill down” list is created showing data relevant to the record you had initially selected. If you double-click here, will another drill window appear? Why or why not?
  125. 125. 125 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Limitations of the SY-LISEL System Field The contents of SY-LISEL: “100141 A B Anders Heidelberg” We can’t send an entire string to an ABAP SELECT statement. SELECT * FROM BSIK WHERE LIFNR = 100141 However, if we could somehow send only individual fields from the selected record, we would then process that data with an ABAP SELECT statement.100141
  126. 126. 126 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Demonstration • Use of AT LINE-SELECTION event and SY-LISEL system field.
  127. 127. 127 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Practice • Use of AT LINE-SELECTION event and SY-LISEL system field.
  128. 128. 128 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 The HIDE ABAP Reserved Word SYNTAX: HIDE <program field>. START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. HIDE: LFA1-LIFNR. ENDSELECT. A New ABAP Reserved Word Extracting Individual Fields from the Record Chosen by the User SELECT * SY-SUBRC CHECK
  129. 129. 129 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 LFA1 WORK AREA RECORD # 2WRITE: / HIDE LIST MEMORY START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. HIDE: LFA1-LIFNR. ENDSELECT. SELECT * SY-SUBRC CHECK The HIDE Memory Area
  130. 130. 130 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, . . . HIDE: LFA1-LIFNR. ENDSELECT. MEMORY LFA1-LIFNR ---- ---- VEND011 VEND012 VEND013 INDEX 1 2 3 4 5 This is what the HIDE memory area and LFA1 work area look like after the SELECT statement above has finished processing. LFA1 WORK AREA RECORD # 3 SELECT * SY-SUBRC CHECK The HIDE Memory Area : (Showing the Index)
  131. 131. 131 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. HIDE: LFA1-LIFNR, LFA1-TELF1. ENDSELECT. HIDE MEMORY LFA1-LIFNR ---- ---- VEND011 VEND012 VEND013 INDEX 1 2 3 4 5 LFA1-TELF1 ---- ---- 555-1111 555-2222 555-3333If we used the HIDE statement to hide both LIFNR and TELF1, our HIDE memory area would look like this. SELECT * SY-SUBRC CHECK The HIDE Memory Area : (with More than One Field Stored)
  132. 132. 132 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 The HIDE Index Numbers VEND012 INDEX 1 2 3 4 MEMORY LFA1 WORK AREA LINE 4 from the screen corresponds with INDEX 4 from the HIDE memory area. The Correlation between the HIDE Memory Area and Line Numbers LFA1-LIFNR ---- ---- VEND011 VEND012 VEND013 INDEX 1 2 3 4 5
  133. 133. 133 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 REPORT Y190XX02. TABLES: LFA1, BSIK. START-OF-SELECTION. SELECT * FROM LFA1. WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. HIDE: LFA1-LIFNR, LFA1-TELF1. ENDSELECT. SELECT * SY-SUBRC CHECK Coding Example :Using the HIDE ABAP Reserved Word
  134. 134. 134 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 What Happens When the System Hides Values? DATA SOURCE field string TABLE WORK AREA HIDE MEMORY LFA1-LIFNR ---- ---- VEND011 VEND012 VEND013 INDEX 1 2 3 4 5 BASIC LIST 1 (header) 2 (uline) 3 VEND011 Star Craft Metal 4 VEND012 Quality Fabr. 5 VEND013 Euro Output SA LFA1-TELF1 ---- ---- 555-1111 555-2222 555-3333 SELECT WRITE HIDE
  135. 135. 135 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 What Happens When the User Selects a Valid Line? data available for further processing TABLE WORK AREA (Field String) HIDE MEMORY LFA1-LIFNR ---- ---- VEND011 VEND012 VEND013 INDEX 1 2 3 4 5 BASIC LIST LFA1-TELF1 ---- ---- 555-1111 555-2222 555-3333 VEND 011 555- 1111 Old Data Old Data Old Data Old Data Old Data Old Data Old Data Old Data Old Data 1 (header) 2 (uline) 3 VEND011 Star Craft Metal 4 VEND012 Quality Fabr. 5 VEND013 Euro Output SA
  136. 136. 136 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 LFA1 WORK AREA ? AT LINE-SELECTION. CHECK SY-LSIND = 1. WINDOW STARTING AT 10 4 ENDING AT 77 12. SELECT * FROM BSIK WHERE LIFNR = LFA1-LIFNR. WRITE: / LFA1-LIFNR, BSIK-BELNR. ENDSELECT. IF SY-SUBRC <> 0. WRITE: / ‘No invoices for vendor’, LFA1-LIFNR. ENDIF. Remember... This is referencing the program field! The value of this field is dependent upon which line you double-clicked in the on-screen report. SELECT * Coding Example :Using the HIDE Memory Area
  137. 137. 137 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Demonstration • Usage of HIDE command in Interactive Reporting.
  138. 138. 138 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Practice • Usage of HIDE command in Interactive Reporting.
  139. 139. 139 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Challenges Revisited Second Challenge: How is this record sent back as criteria to an ABAP SELECT statement? METHOD: HIDE memory area. First Challenge: How did the ABAP code “know” which record the user has selected? METHOD: When a user event is triggered, the system automatically records the line selected (via SY-LISEL and other system fields).
  140. 140. 140 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Restart the program and double-click on the header. Is the User Selecting a Valid Line in the Report?
  141. 141. 141 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Restart the program and double-click on the header. What happens? Where does this data come from? Is the User Selecting a Valid Line in the Report?
  142. 142. 142 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 What Happens When the User Clicks on an Invalid Line First? No values are restored from HIDE into program fields. The last record selected by the “SELECT” statement is still in work area and still available for further processing. HIDE MEMORY LFA1-LIFNR ---- ---- VEND011 VEND012 VEND013 INDEX 1 2 3 4 5 BASIC LIST LFA1-TELF1 ---- ---- 555-1111 555-2222 555-3333 VEND- OR2 555- 9898 PA USA 19103 Mr. Jones $100 NET 30Phila. 123 Main Bacon Inc. 1 (header) 2 (uline) 3 VEND011 Star Craft Metal 4 VEND012 Quality Fabr. 5 VEND013 Euro Output SA
  143. 143. 143 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 SYNTAX: END-OF-SELECTION. A New ABAP Event After all of the other system events have been executed . . . INITIALIZATION. AT SELECTION-SCREEN. START-OF-SELECTION. GET <table>. GET <table> LATE. . . . before the basic list is displayed. . . . the END-OF-SELECTION event occurs . . . The END-OF-SELECTION Event
  144. 144. 144 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 END-OF-SELECTION. CLEAR LFA1-LIFNR. AT LINE-SELECTION. CHECK SY-LSIND = 1. CHECK NOT LFA1-LIFNR IS INITIAL. WINDOW STARTING AT 10 4 ENDING AT 77 12. SELECT * FROM BSIK WHERE LIFNR = LFA1-LIFNR. WRITE: / LFA1-LIFNR, BSIK-BELNR. ENDSELECT. IF SY-SUBRC <> 0. WRITE: / ‘No invoices for vendor’, LFA1-LIFNR. ENDIF. 2 First: Initialise the LFA1-LIFNR program field just before the basic list is displayed. Second: Make sure the LFA1-LIFNR program field is not initial before processing the rest of the user event (i.e. make sure the user selected a valid line). SELECT * 1  Part I - Initializing Fields before Basic List Displayed Handling Invalid Line Selection
  145. 145. 145 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Click on a Valid Line First data available for further processing TABLE WORK AREA (Field String) HIDE MEMORY LFA1-LIFNR ---- ---- VEND011 VEND012 VEND013 INDEX 1 2 3 4 5 LFA1-TELF1 ---- ---- 555-1111 555-2222 555-3333 VEND 012 555- 2222 1 (header) 2 (uline) 3 VEND011 Star Craft Metal 4 VEND012 Quality Fabr. 5 VEND013 Euro Output SA Old Data Old Data Old Data Old Data Old Data Old Data Old Data Old Data Old Data BASIC LIST
  146. 146. 146 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 … Then Click on an Invalid Line TABLE WORK AREA (Field String) No values restored from HIDE into program fields. Values restored from last valid line selected by the user are still in the work area. HIDE MEMORY LFA1-LIFNR ---- ---- VEND011 VEND012 VEND013 INDEX 1 2 3 4 5 LFA1-TELF1 ---- ---- 555-1111 555-2222 555-3333 VEND 012 555- 2222 1 (header) 2 (uline) 3 VEND011 Star Craft Metal 4 VEND012 Quality Fabr. 5 VEND013 Euro Output SA Old Data Old Data Old Data Old Data Old Data Old Data Old Data Old Data Old Data BASIC LIST
  147. 147. 147 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Handling Invalid Line Selection END-OF-SELECTION. CLEAR LFA1-LIFNR. AT LINE-SELECTION. CHECK SY-LSIND = 1. CHECK NOT LFA1-LIFNR IS INITIAL. WINDOW STARTING AT 10 4 ENDING AT 77 12. SELECT * FROM BSIK WHERE LIFNR = LFA1-LIFNR. WRITE: / LFA1-LIFNR, BSIK-BELNR. ENDSELECT. IF SY-SUBRC <> 0. WRITE: / ‘No invoices for vendor’, LFA1-LIFNR. ENDIF. CLEAR LFA1-LIFNR. 2 1 First: Initialise the LFA1-LIFNR program field just before the detail list is displayed. Second: Make sure the LFA1-LIFNR program field is not initial before processing the rest of the user event (i.e. make sure the user selected a valid line). SELECT *  Part II - Initializing Fields after Each Use
  148. 148. 148 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Flow of Data DATA SOURCE BASIC LIST HIDE MEMORY WORK AREA
  149. 149. 149 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Summary • AT LINE-SELECTION event is triggered when a user double-clicks on a line in the list (or single-clicks on a line and clicks on CHOOSE button or presses F2). • System field SY-LISEL contains the contents of the line selected by the user and SY-LILLI contains the number of line selected. • HIDE memory area exists for each lists in a report. This area gets populated with the program fields when the system encounters
  150. 150. 150 March-2005 The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 Question • Which system field contains the content of the selected line ? • What does a HIDE statement do ? • How is the HIDE statement used for producing detail lists ? • What is an invalid line in the context of drill down reporting ? • How do you determine if the user has clicked on a valid line ?
  151. 151. Multiple Line Selection | 4.08 March-2005 Multiple Line Selection
  152. 152. 152 March-2005 Multiple Line Selection | 4.08  The participants will be able to :  Write check boxes in the screen.  Providing additional information on single record on the screen.  Use READ-LINE statement with SY-INDEX. Objectives
  153. 153. 153 March-2005 Multiple Line Selection | 4.08 First the user double-clicks on a record. Then a “drill down” list is created showing data relevant to the record initially selected by the user. Providing Additional Information on a Single Record Only
  154. 154. 154 March-2005 Multiple Line Selection | 4.08 First, the user clicks inside of the checkboxes for the vendors that the user is interested in. Then a drill down window appears that contains the telephone numbers for each of the previously selected vendors. Providing Additional Information on Multiple Records
  155. 155. 155 March-2005 Multiple Line Selection | 4.08 READ LINE 1.. checked? YES or NO READ LINE 2.. checked? YES or NO READ LINE 3 .. checked? YES or NO READ LINE n .. checked? YES or NO First we must learn techniques to “draw” checkboxes on the screen. Then we must learn techniques to loop through each of the lines on the report and determine whether or not they were checked. Challenges
  156. 156. 156 March-2005 Multiple Line Selection | 4.08 REPORT Y190XX03 LINE-SIZE 255. TABLES: LFA1. DATA: CHK1. START-OF-SELECTION. SELECT * FROM LFA1 WHERE TELF1 <> SPACE. WRITE: / CHK1 AS CHECKBOX, LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. SKIP. ENDSELECT. Create a single-character variable. Then WRITE it to the report as a checkbox. SELECT * SY-SUBRC CHECK Coding Example : Writing Checkboxes to the Screen
  157. 157. 157 March-2005 Multiple Line Selection | 4.08 SYNTAX: READ LINE <#>. A New ABAP Reserved Word READ LINE 11 FIELD VALUE LFA1-LIFNR INTO VAR1. MEMORY VAR1 = VEND021 Programmatically Reading a Line in a Report The READ LINE Statement
  158. 158. 158 March-2005 Multiple Line Selection | 4.08 READ LINE 1 READ LINE 2 READ LINE 3 READ LINE n SYSTEM FIELD: SY-INDEX A New ABAP System Field READ LINE SY-INDEX FIELD VALUE LFA1-LIFNR INTO VAR1. Looping through Each of the Lines in the Report The SY-INDEX System Field
  159. 159. 159 March-2005 Multiple Line Selection | 4.08 This code continues on the next page. REPORT Y190XX03 LINE-SIZE 255. TABLES: LFA1. DATA: CHK1. START-OF-SELECTION. SELECT * FROM LFA1 WHERE TELF1 <> SPACE. WRITE: / CHK1 AS CHECKBOX, LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. HIDE: LFA1-NAME1, LFA1-TELF1. SKIP. ENDSELECT. Write this code. SELECT * SY-SUBRC CHECK The READ LINE Statement
  160. 160. 160 March-2005 Multiple Line Selection | 4.08 READ LINE 1 READ LINE 2 READ LINE 3 READ LINE n ..checked? YES or NO .. checked? YES or NO .. checked? YES or NO .. checked? YES or NO AT PF06. WINDOW STARTING AT 10 4 ENDING AT 77 12. DO. CLEAR CHK1. READ LINE SY-INDEX FIELD VALUE CHK1. IF SY-SUBRC <> 0. EXIT. ELSE. CHECK CHK1 = ‘X’. WRITE: / LFA1-NAME1, LFA1-TELF1. ENDIF. ENDDO. Coding Example : The READ LINE Statement
  161. 161. 161 March-2005 Multiple Line Selection | 4.08 When the user has finished reading the data in the drill down window, he/she returns to the initial screen to find that it has been modified to show the records that have already been selected. First the user clicks on the vendors of interest. Then the user presses the F6 key on the keyboard. The MODIFY LINE Statement
  162. 162. 162 March-2005 Multiple Line Selection | 4.08 REPORT Y190XX03 LINE-SIZE 255. TABLES: LFA1. DATA: CHK1. DATA: WAS_USED. SELECT * FROM LFA1 WHERE TELF1 <> SPACE. WRITE: / CHK1 AS CHECKBOX, WAS_USED, LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. HIDE: LFA1-NAME1, LFA1-TELF1. SKIP. ENDSELECT. Add new code here and here. SELECT * SY-SUBRC CHECK Coding Example : The MODIFY LINE Statement
  163. 163. 163 March-2005 Multiple Line Selection | 4.08 AT PF06. WINDOW STARTING AT 10 4 ENDING AT 77 12. DO. CLEAR CHK1. READ LINE SY-INDEX FIELD VALUE CHK1. IF SY-SUBRC <> 0. EXIT. ELSE. CHECK CHK1 = ‘X’. MODIFY CURRENT LINE: FIELD VALUE WAS_USED FROM ‘*’ CHK1 FROM SPACE FIELD FORMAT CHK1 INPUT OFF. WRITE: / LFA1-NAME1, LFA1-TELF1. ENDIF. ENDDO. Add new code here. Coding Example : The MODIFY LINE Statement
  164. 164. 164 March-2005 Multiple Line Selection | 4.08 Demonstration • Writing checkboxes, use of READ LINE and MODIFY LINE statement
  165. 165. 165 March-2005 Multiple Line Selection | 4.08 Practice • Writing checkboxes, use of READ LINE and MODIFY LINE statement
  166. 166. 166 March-2005 Multiple Line Selection | 4.08 Summary • Checkboxes can be written to the list by using ‘AS CHECKBOX’ addition with the WRITE command. • READ LINE statement can be used to read the contents of a list. With this statement, the contents of the line are populated in system field SY-LISEL. • MODIFY LINE statement can be used to modify the list even after it is displayed. The format of the lines in the list can also be
  167. 167. 167 March-2005 Multiple Line Selection | 4.08 Questions • How do you draw checkboxes in the output list ? • How to read the contents of a list ? • How do you modify the contents of a list after it is displayed ?

×