ITB258 ABAP Programming Lecture 11 Using Tables in Transactions
Objectives This lecture aims to introduce the concepts associated with:  Table controls:  graphical screen elements used for displaying more than  n  rows of a table on a single screen screen  flow logic  for handling table controls
Using Tables in a Screen ABAP offers the  Table Control  graphical element as a mechanism for displaying and modifying tabular data in a screen a Table Control is a  screen ‘container’ or object that allows display of multiple rows of a table (database or internal) on a screen Good for displaying a one-to-many relationship on the one screen.
Table Control
Table Controls Table Control features allow horizontal & vertical scrolling column width resizing scrolling within a field (where contents are wider than the screen field width) reordering the sequence of columns saving the current display settings for future use selection of table rows & columns Formatting features include automatic table resizing on window resize separator lines between rows & columns column header fields for all columns
Creating a Table Control In the TOP Include object: CONTROLS  ctrl  TYPE TABLEVIEW  USING SCREEN  scr . TABLEVIEW  corresponds to a complex type (CXTAB_CONTROL defined in the ABAP dictionary) USING SCREEN  determines the screen from which the table control will get its initial values
CXTAB_CONTROL
Adding a Table Control to a Screen In the Graphical Fullscreen Editor choose the  Table Control  element button. Use the left mouse button to position  and size the control on the screen.
Adding a Table Control to a Screen Enter a Name for the Table Control
Adding Fields to a Table Control Press Dict/program fields pushbutton
Adding Fields to a Table Control Enter database table name Select Get From Dictionary
Adding Fields to a Table Control Enter internal table name Select Get From program
Adding Fields to a Table Control Mark the fields to be added to the table control Then click on Copy to select the fields
Adding Fields to a Table Control Drag the selected fields into the table control,  then release the mouse button.
Adding Fields to a Table Control The label for each column is a text field, created by clicking on the text field icon and then dragging the new text field onto the header of the column before typing in the label Text field icon
Table Control Principles Database Table Internal Table (Buffer) 1. Internal Table filled with selected data
Table Control Principles Internal Table (Buffer) 2. Table Control contents filled from internal table Table Control
Table Control Principles Internal Table (Buffer) Table Control 3. Changes to Table Control contents copied to internal table
Table Control Principles Database Table Internal Table (Buffer) 4. When screen is closed, internal table contents copied back to database
Table Control Principles PBO PAI Select rows from the database into an internal table Screen 1 PBO PAI Screen 2 ( with table control ) LOOP ... read internal table into  table control line by line ENDLOOP. LOOP ... update internal table from table control line by line ENDLOOP.
Table Control Principles Fields are transported from the module pool to the screen each time a loop is processed The remaining screen fields are transported at the end of PBO processing LOOP start LOOP end transport ABAP table control fields to screen fields transport remaining ABAP fields to screen fields PROCESS BEFORE OUTPUT
Table Control Principles All screen fields that do not belong to a table control and are not specified in a FIELD statement are transported to module pool fields Table control fields are transported row by row to module pool fields Fields specified in FIELD statements are transported immediately before the FIELD statement is executed LOOP start LOOP end transport screen table control fields to ABAP module pool fields transport all fields from the screen to ABAP fields excluding table control fields PROCESS AFTER INPUT
Updating Data in Table Controls Method 1:   Read the internal table into the Table Control in the screen's flow logic.  Used when the names of the Table Control fields are based on fields of the  internal  table. Method 2:  Read the internal table into the Table Control in the module pool code.  Used when the names of the Table Control fields are based on fields of the  database  table.
Table Controls in the Flow Logic Method 1 (table control fields = itab fields) PROCESS BEFORE OUTPUT. LOOP AT ITAB WITH CONTROL FLIGHTS CURSOR FLIGHTS-CURRENT_LINE. ENDLOOP. PROCESS AFTER INPUT. LOOP AT ITAB. MODULE MODIFY_ITAB.  ENDLOOP. MODULE MODIFY_ITAB INPUT. MODIFY ITAB INDEX FLIGHTS-CURRENT_LINE. ENDMODULE.
Table Controls in the Flow Logic Method 2 (table control fields = dict. fields) PROCESS BEFORE OUTPUT. LOOP WITH CONTROL FLIGHTS. MODULE READ_ITAB. ENDLOOP. PROCESS AFTER INPUT. LOOP WITH CONTROL FLIGHTS. MODULE MODIFY_ITAB.  ENDLOOP. MODULE READ_ITAB OUTPUT. READ TABLE ITAB INDEX  FLIGHTS-CURRENT_LINE. IF SY-SUBRC EQ 0. MOVE-CORRESPONDING ITAB TO SFLIGHT. ELSE. EXIT FROM STEP-LOOP. ENDIF. ENDMODULE. MODULE MODIFY_ITAB INPUT. MOVE-CORRESPONDING SFLIGHT TO ITAB. MODIFY ITAB INDEX  FLIGHTS-CURRENT_LINE. ENDMODULE.
Table Controls in the Flow Logic PROCESS BEFORE OUTPUT. LOOP WITH CONTROL FLIGHTS. MODULE READ_ITAB. ENDLOOP. PROCESS AFTER INPUT. LOOP WITH CONTROL FLIGHTS. CHAIN. FIELD: SFLIGHT-PRICE, SFLIGHT-FLDATE. MODULE MODIFY_ITAB  ON CHAIN-REQUEST. ENDCHAIN. ENDLOOP. MODULE READ_ITAB OUTPUT. READ TABLE ITAB INDEX  FLIGHTS-CURRENT_LINE. IF SY-SUBRC EQ 0. MOVE-CORRESPONDING ITAB TO SFLIGHT. ELSE. EXIT FROM STEP-LOOP. ENDIF. ENDMODULE. MODULE MODIFY_ITAB INPUT. MOVE-CORRESPONDING SFLIGHT TO ITAB. MODIFY ITAB INDEX  FLIGHTS-CURRENT_LINE. ENDMODULE. Method 2 (table control fields = dict. fields)
Table Control Attributes data: begin of cxtab_control, ... cols type  cxtab_column  occurs 10, end of cxtab_control. data: begin of cxtab_column, ... selected, screen like  screen , end of cxtab_column. SCREEN FIELDS: name length active ...
Sorting a Table Control by a Selected Field DATA: WA LIKE LINE OF FLIGHTS-COLS. ... MODULE USER_COMMAND_200. ... LOOP AT FLIGHTS-COLS INTO WA.   IF WA-SELECTED = ‘X’.   SORT ITAB BY (WA-SCREEN-NAME+5). ENDIF. ENDLOOP. ENDMODULE.
 
Sample Fields List  Output only fields Table Control
Handling Line Selection PROCESS AFTER INPUT. LOOP AT ITAB. FIELD ITAB-MARK   MODULE MODIFY_ITAB ON REQUEST. ENDLOOP. MODULE MODIFY_ITAB INPUT. MODIFY ITAB INDEX  FLIGHTS-CURRENT_LINE. ENDMODULE.
Updating the Internal Table PROCESS AFTER INPUT. LOOP WITH CONTROL FLIGHTS. CHAIN. FIELD: SFLIGHT-PRICE, SFLIGHT-FLDATE. MODULE MODIFY_ITAB  ON CHAIN-REQUEST. ENDCHAIN. ENDLOOP. Method 1 Method 2 PROCESS AFTER INPUT. LOOP AT ITAB. CHAIN. FIELD: SFLIGHT-PRICE, SFLIGHT-FLDATE. MODULE MODIFY_ITAB  ON CHAIN-REQUEST. ENDCHAIN. ENDLOOP. MODULE MODIFY_ITAB INPUT. ITAB-MARK = 'X'. MODIFY ITAB INDEX  FLIGHTS-CURRENT_LINE. ENDMODULE. MODULE MODIFY_ITAB INPUT. MOVE-CORRESPONDING SFLIGHT TO ITAB. ITAB-MARK = 'X'. MODIFY ITAB INDEX  FLIGHTS-CURRENT_LINE. ENDMODULE.
Updating the Database Saving the Updated Data (both methods) MODULE USER_COMMAND_200. CASE OK_CODE. WHEN ‘SAVE’. LOOP AT ITAB. CHECK ITAB-MARK = ‘X’. MOVE-CORRESPONDING ITAB TO SFLIGHT. UPDATE SFLIGHT. ENDLOOP. WHEN ... ... ENDCASE. ENDMODULE.
Updating the database Detecting changes to the screen fields SY-DATAR automatically set to ‘X’ when data is changed on a screen automatically reset every time the screen is updated means that SY-DATAR could be reset although changes have been made but not saved  "FLAG" field (declared in TOP INCLUDE) Create a module to set the flag whenever data is changed on the screen.
Updating the database Exit modules are processed before any data is transferred from screen to program (including updating SY-DATAR), so this is the only way to capture changed data if an exit is triggered. PROCESS AFTER INPUT. FIELD: < all screen fields > MODULE SET_FLAG ON REQUEST. MODULE SET_FLAG INPUT. FLAG = 'X'. ENDMODULE. MODULE EXIT INPUT. IF FLAG = 'X'. < save dialog > ENDIF. LEAVE TO SCREEN 0. ENDMODULE.
Conclusion This lectured examined concepts associated with the use of Table Controls in a screen definition creation maintenance filling modifying sorting saving
Related Reading Textbook Ch 3.3 - Dialog Applications On Line Help R/3 Library…BC..ABAP Workbench BC ABAP User’s Guide ABAP User Interface … Screens Processing User input on a Screen, Controlling the Screen Flow, Modifying the Screen, Using Tables in a Screen
Next Week Review of semester Please ask questions!

More Related Content

PPTX
Top 10 sap abap faqs-www.bigclasses.com
PDF
Table maintenance generator and its modifications
PPT
0105 abap programming_overview
PPT
Maximizing SAP ABAP Performance
PPTX
Balm-II
PDF
Exportinc
PPT
Internal tables
PPTX
Abap ppt
Top 10 sap abap faqs-www.bigclasses.com
Table maintenance generator and its modifications
0105 abap programming_overview
Maximizing SAP ABAP Performance
Balm-II
Exportinc
Internal tables
Abap ppt

Similar to 258lec11 (20)

PPT
Abap slide class3
PPT
Myth busters - performance tuning 101 2007
DOCX
Interview Preparation
PDF
Abap reports
DOC
Sql Queries
DOC
222066369 clad-study-guide
PPS
Excel Tips
DOC
Complete list of all sap abap keywords
PPTX
9 - Advanced Functions in MS Excel.pptx
PPT
Excel useful tips
PPS
Excel Useful Tips
PPS
Excel tips
PPS
35 Useful Excel Tips
PPS
Excel useful tips
PPT
Excel useful tips
PPS
Excel tips
PDF
Complete reference to_abap_basics
PPT
Lecture02 abap on line
PPTX
V.6 CSPro Tabulation Application_Creating Tables with PostCalc Application.pptx
PPT
0104 abap dictionary
Abap slide class3
Myth busters - performance tuning 101 2007
Interview Preparation
Abap reports
Sql Queries
222066369 clad-study-guide
Excel Tips
Complete list of all sap abap keywords
9 - Advanced Functions in MS Excel.pptx
Excel useful tips
Excel Useful Tips
Excel tips
35 Useful Excel Tips
Excel useful tips
Excel useful tips
Excel tips
Complete reference to_abap_basics
Lecture02 abap on line
V.6 CSPro Tabulation Application_Creating Tables with PostCalc Application.pptx
0104 abap dictionary
Ad

Recently uploaded (20)

PDF
English Textual Question & Ans (12th Class).pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
HVAC Specification 2024 according to central public works department
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
PPTX
Education and Perspectives of Education.pptx
PDF
My India Quiz Book_20210205121199924.pdf
PDF
Journal of Dental Science - UDMY (2022).pdf
PDF
Journal of Dental Science - UDMY (2020).pdf
PDF
CRP102_SAGALASSOS_Final_Projects_2025.pdf
PDF
Complications of Minimal Access-Surgery.pdf
PDF
Climate and Adaptation MCQs class 7 from chatgpt
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PPTX
Climate Change and Its Global Impact.pptx
PDF
Hazard Identification & Risk Assessment .pdf
English Textual Question & Ans (12th Class).pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
HVAC Specification 2024 according to central public works department
Cambridge-Practice-Tests-for-IELTS-12.docx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
Share_Module_2_Power_conflict_and_negotiation.pptx
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
Education and Perspectives of Education.pptx
My India Quiz Book_20210205121199924.pdf
Journal of Dental Science - UDMY (2022).pdf
Journal of Dental Science - UDMY (2020).pdf
CRP102_SAGALASSOS_Final_Projects_2025.pdf
Complications of Minimal Access-Surgery.pdf
Climate and Adaptation MCQs class 7 from chatgpt
AI-driven educational solutions for real-life interventions in the Philippine...
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
Climate Change and Its Global Impact.pptx
Hazard Identification & Risk Assessment .pdf
Ad

258lec11

  • 1. ITB258 ABAP Programming Lecture 11 Using Tables in Transactions
  • 2. Objectives This lecture aims to introduce the concepts associated with: Table controls: graphical screen elements used for displaying more than n rows of a table on a single screen screen flow logic for handling table controls
  • 3. Using Tables in a Screen ABAP offers the Table Control graphical element as a mechanism for displaying and modifying tabular data in a screen a Table Control is a screen ‘container’ or object that allows display of multiple rows of a table (database or internal) on a screen Good for displaying a one-to-many relationship on the one screen.
  • 5. Table Controls Table Control features allow horizontal & vertical scrolling column width resizing scrolling within a field (where contents are wider than the screen field width) reordering the sequence of columns saving the current display settings for future use selection of table rows & columns Formatting features include automatic table resizing on window resize separator lines between rows & columns column header fields for all columns
  • 6. Creating a Table Control In the TOP Include object: CONTROLS ctrl TYPE TABLEVIEW USING SCREEN scr . TABLEVIEW corresponds to a complex type (CXTAB_CONTROL defined in the ABAP dictionary) USING SCREEN determines the screen from which the table control will get its initial values
  • 8. Adding a Table Control to a Screen In the Graphical Fullscreen Editor choose the Table Control element button. Use the left mouse button to position and size the control on the screen.
  • 9. Adding a Table Control to a Screen Enter a Name for the Table Control
  • 10. Adding Fields to a Table Control Press Dict/program fields pushbutton
  • 11. Adding Fields to a Table Control Enter database table name Select Get From Dictionary
  • 12. Adding Fields to a Table Control Enter internal table name Select Get From program
  • 13. Adding Fields to a Table Control Mark the fields to be added to the table control Then click on Copy to select the fields
  • 14. Adding Fields to a Table Control Drag the selected fields into the table control, then release the mouse button.
  • 15. Adding Fields to a Table Control The label for each column is a text field, created by clicking on the text field icon and then dragging the new text field onto the header of the column before typing in the label Text field icon
  • 16. Table Control Principles Database Table Internal Table (Buffer) 1. Internal Table filled with selected data
  • 17. Table Control Principles Internal Table (Buffer) 2. Table Control contents filled from internal table Table Control
  • 18. Table Control Principles Internal Table (Buffer) Table Control 3. Changes to Table Control contents copied to internal table
  • 19. Table Control Principles Database Table Internal Table (Buffer) 4. When screen is closed, internal table contents copied back to database
  • 20. Table Control Principles PBO PAI Select rows from the database into an internal table Screen 1 PBO PAI Screen 2 ( with table control ) LOOP ... read internal table into table control line by line ENDLOOP. LOOP ... update internal table from table control line by line ENDLOOP.
  • 21. Table Control Principles Fields are transported from the module pool to the screen each time a loop is processed The remaining screen fields are transported at the end of PBO processing LOOP start LOOP end transport ABAP table control fields to screen fields transport remaining ABAP fields to screen fields PROCESS BEFORE OUTPUT
  • 22. Table Control Principles All screen fields that do not belong to a table control and are not specified in a FIELD statement are transported to module pool fields Table control fields are transported row by row to module pool fields Fields specified in FIELD statements are transported immediately before the FIELD statement is executed LOOP start LOOP end transport screen table control fields to ABAP module pool fields transport all fields from the screen to ABAP fields excluding table control fields PROCESS AFTER INPUT
  • 23. Updating Data in Table Controls Method 1: Read the internal table into the Table Control in the screen's flow logic. Used when the names of the Table Control fields are based on fields of the internal table. Method 2: Read the internal table into the Table Control in the module pool code. Used when the names of the Table Control fields are based on fields of the database table.
  • 24. Table Controls in the Flow Logic Method 1 (table control fields = itab fields) PROCESS BEFORE OUTPUT. LOOP AT ITAB WITH CONTROL FLIGHTS CURSOR FLIGHTS-CURRENT_LINE. ENDLOOP. PROCESS AFTER INPUT. LOOP AT ITAB. MODULE MODIFY_ITAB. ENDLOOP. MODULE MODIFY_ITAB INPUT. MODIFY ITAB INDEX FLIGHTS-CURRENT_LINE. ENDMODULE.
  • 25. Table Controls in the Flow Logic Method 2 (table control fields = dict. fields) PROCESS BEFORE OUTPUT. LOOP WITH CONTROL FLIGHTS. MODULE READ_ITAB. ENDLOOP. PROCESS AFTER INPUT. LOOP WITH CONTROL FLIGHTS. MODULE MODIFY_ITAB. ENDLOOP. MODULE READ_ITAB OUTPUT. READ TABLE ITAB INDEX FLIGHTS-CURRENT_LINE. IF SY-SUBRC EQ 0. MOVE-CORRESPONDING ITAB TO SFLIGHT. ELSE. EXIT FROM STEP-LOOP. ENDIF. ENDMODULE. MODULE MODIFY_ITAB INPUT. MOVE-CORRESPONDING SFLIGHT TO ITAB. MODIFY ITAB INDEX FLIGHTS-CURRENT_LINE. ENDMODULE.
  • 26. Table Controls in the Flow Logic PROCESS BEFORE OUTPUT. LOOP WITH CONTROL FLIGHTS. MODULE READ_ITAB. ENDLOOP. PROCESS AFTER INPUT. LOOP WITH CONTROL FLIGHTS. CHAIN. FIELD: SFLIGHT-PRICE, SFLIGHT-FLDATE. MODULE MODIFY_ITAB ON CHAIN-REQUEST. ENDCHAIN. ENDLOOP. MODULE READ_ITAB OUTPUT. READ TABLE ITAB INDEX FLIGHTS-CURRENT_LINE. IF SY-SUBRC EQ 0. MOVE-CORRESPONDING ITAB TO SFLIGHT. ELSE. EXIT FROM STEP-LOOP. ENDIF. ENDMODULE. MODULE MODIFY_ITAB INPUT. MOVE-CORRESPONDING SFLIGHT TO ITAB. MODIFY ITAB INDEX FLIGHTS-CURRENT_LINE. ENDMODULE. Method 2 (table control fields = dict. fields)
  • 27. Table Control Attributes data: begin of cxtab_control, ... cols type cxtab_column occurs 10, end of cxtab_control. data: begin of cxtab_column, ... selected, screen like screen , end of cxtab_column. SCREEN FIELDS: name length active ...
  • 28. Sorting a Table Control by a Selected Field DATA: WA LIKE LINE OF FLIGHTS-COLS. ... MODULE USER_COMMAND_200. ... LOOP AT FLIGHTS-COLS INTO WA. IF WA-SELECTED = ‘X’. SORT ITAB BY (WA-SCREEN-NAME+5). ENDIF. ENDLOOP. ENDMODULE.
  • 29.  
  • 30. Sample Fields List Output only fields Table Control
  • 31. Handling Line Selection PROCESS AFTER INPUT. LOOP AT ITAB. FIELD ITAB-MARK MODULE MODIFY_ITAB ON REQUEST. ENDLOOP. MODULE MODIFY_ITAB INPUT. MODIFY ITAB INDEX FLIGHTS-CURRENT_LINE. ENDMODULE.
  • 32. Updating the Internal Table PROCESS AFTER INPUT. LOOP WITH CONTROL FLIGHTS. CHAIN. FIELD: SFLIGHT-PRICE, SFLIGHT-FLDATE. MODULE MODIFY_ITAB ON CHAIN-REQUEST. ENDCHAIN. ENDLOOP. Method 1 Method 2 PROCESS AFTER INPUT. LOOP AT ITAB. CHAIN. FIELD: SFLIGHT-PRICE, SFLIGHT-FLDATE. MODULE MODIFY_ITAB ON CHAIN-REQUEST. ENDCHAIN. ENDLOOP. MODULE MODIFY_ITAB INPUT. ITAB-MARK = 'X'. MODIFY ITAB INDEX FLIGHTS-CURRENT_LINE. ENDMODULE. MODULE MODIFY_ITAB INPUT. MOVE-CORRESPONDING SFLIGHT TO ITAB. ITAB-MARK = 'X'. MODIFY ITAB INDEX FLIGHTS-CURRENT_LINE. ENDMODULE.
  • 33. Updating the Database Saving the Updated Data (both methods) MODULE USER_COMMAND_200. CASE OK_CODE. WHEN ‘SAVE’. LOOP AT ITAB. CHECK ITAB-MARK = ‘X’. MOVE-CORRESPONDING ITAB TO SFLIGHT. UPDATE SFLIGHT. ENDLOOP. WHEN ... ... ENDCASE. ENDMODULE.
  • 34. Updating the database Detecting changes to the screen fields SY-DATAR automatically set to ‘X’ when data is changed on a screen automatically reset every time the screen is updated means that SY-DATAR could be reset although changes have been made but not saved &quot;FLAG&quot; field (declared in TOP INCLUDE) Create a module to set the flag whenever data is changed on the screen.
  • 35. Updating the database Exit modules are processed before any data is transferred from screen to program (including updating SY-DATAR), so this is the only way to capture changed data if an exit is triggered. PROCESS AFTER INPUT. FIELD: < all screen fields > MODULE SET_FLAG ON REQUEST. MODULE SET_FLAG INPUT. FLAG = 'X'. ENDMODULE. MODULE EXIT INPUT. IF FLAG = 'X'. < save dialog > ENDIF. LEAVE TO SCREEN 0. ENDMODULE.
  • 36. Conclusion This lectured examined concepts associated with the use of Table Controls in a screen definition creation maintenance filling modifying sorting saving
  • 37. Related Reading Textbook Ch 3.3 - Dialog Applications On Line Help R/3 Library…BC..ABAP Workbench BC ABAP User’s Guide ABAP User Interface … Screens Processing User input on a Screen, Controlling the Screen Flow, Modifying the Screen, Using Tables in a Screen
  • 38. Next Week Review of semester Please ask questions!

Editor's Notes

  • #4: Very often it is desirable to be able to represent a one-to-many relationship on the screen. For instance, given an airline carrier and a flight code show all the scheduled flights. (Or given an order number show all the ordered products.) ABAP provides the ‘table control’ as a graphical element on a screen that is capable of holding and displaying multiple rows of a table in a ‘spreadsheet’ format.
  • #5: This slide illustrates a table control object in a screen.
  • #6: The table control object has many features built in to enhance screen display and usability. They include the ability to scroll through records (horizontally and vertically) and inside a field if the field width is greater than the table control’s column width. Table controls also allow the user to dynamically resize column widths, reorder columns, and select columns and rows for subsequent processing.
  • #7: As well as drawing the table control on the screen it is necessary to declare the table control as a data item (in the TOP include program for the transaction).
  • #8: To view the structure of the cxtab-control object use the Repository Browser and choose Dictionary Objects…Choose the Type Group radiobutton and enter CXTAB…Press the Display icon on the application toolbar. Note that a component of the object is an internal table, cols. Each displayed field of the table control will have a row in the cols internal table which describes various attributes of the field.
  • #17: There are a set of programming principles that should be adhered to when using table controls and step loops. Data from the database should be initially loaded into an internal table. (This means that the database is accessed for read purposes only once in the transaction.) Next the rows of the internal table are loaded into the table control Any changes that are made to the data are then saved back to the internal table. At the end of the transaction, the contents of the internal table can be written back to the database, again to minimise database I/O.
  • #18: There are a set of programming principles that should be adhered to when using table controls and step loops. Data from the database should be initially loaded into an internal table. (This means that the database is accessed for read purposes only once in the transaction.) Next the rows of the internal table are loaded into the table control Any changes that are made to the data are then saved back to the internal table. At the end of the transaction, the contents of the internal table can be written back to the database, again to minimise database I/O.
  • #19: There are a set of programming principles that should be adhered to when using table controls and step loops. Data from the database should be initially loaded into an internal table. (This means that the database is accessed for read purposes only once in the transaction.) Next the rows of the internal table are loaded into the table control Any changes that are made to the data are then saved back to the internal table. At the end of the transaction, the contents of the internal table can be written back to the database, again to minimise database I/O.
  • #20: There are a set of programming principles that should be adhered to when using table controls and step loops. Data from the database should be initially loaded into an internal table. (This means that the database is accessed for read purposes only once in the transaction.) Next the rows of the internal table are loaded into the table control Any changes that are made to the data are then saved back to the internal table. At the end of the transaction, the contents of the internal table can be written back to the database, again to minimise database I/O.
  • #21: PAI logic for screen 1 loads the internal table with data from the database according to the entries supplied by the user. PBO logic for screen 2 populates the table control from the internal table (buffer). User action in screen 2 triggers the PAI logic. PAI logic updates the internal table with new values entered (into the table control screen fields) by the user. PAI logic is triggered by actions such as scrolling down a single row as well as actions such as BACK, EXIT, etc. Unless the user action causes the transaction to leave the current screen, after the PAI modules have been executed, the PBO modules for the screen are executed again. Thus the table control fields are updated/refreshed after every user action.
  • #22: In PBO processing fields are transported from the module pool to the screen in a predefined order. 1. The table control step loop is processed row by row. Fields with corresponding names are transported from the module pool to the screen. 2. After the step loop has been processed all remaining module pool fields are transported to the screen.
  • #24: The ABAP language provides two mechanisms for loading the table control with data from the internal table and then storing the altered rows of the table control back to the internal table.
  • #25: In the flow logic you can read an internal table using the LOOP statement. You define the reference to the relevant able control by specifying WITH CONTROL &lt;ctrl&gt; You determine which table entry is to be read by specifying CURSOR &lt;ctrl&gt;-CURRENT_LINE. After the read operation the field contents are placed in the header line of the internal table. If the fields in the table control have the same name as the internal they will be filled automatically. (Otherwise you need to write a module to transfer the internal table fields to the screen fields.) You must reflect any changes the user makes to the fields of the table control in the internal table otherwise they will not appear when the screen is redisplayed after PBO processing, (eg, after the user presses Enter or scrolls) However, this processing should be performed only if changes have actually been made to the screen fields of the table control (hence the use of the ON REQUEST)
  • #26: If you use a LOOP statement without an internal table in the flow logic, you must read the data in a PBO module which is called each time the loop is processed. Since, in this case, the system cannot determine the number of internal table entries itself, you must use the EXIT FROM STEP-LOOP statement to ensure that no blank lines are displayed in the table control if there are no more corresponding entries in the internal table.
  • #27: If you use a LOOP statement without an internal table in the flow logic, you must read the data in a PBO module which is called each time the loop is processed. Since, in this case, the system cannot determine the number of internal table entries itself, you must use the EXIT FROM STEP-LOOP statement to ensure that no blank lines are displayed in the table control if there are no more corresponding entries in the internal table.
  • #29: Sorting the display by a selected column is very simple to implement using the table control attributes &lt;ctrl&gt;-SELECTED and &lt;ctrl&gt;-SCREEN-NAME. Here we assume that the table control displays the fields of an internal table (ITAB) as per Option 1 discussed previously. WA-SCREEN-NAME refers to the name of the selected column of the table control. The expression (WA-SCREEN-NAME+5) refers to the contents of the variable offset 5 characters from the left. In this example WA-SCREEN-NAME will have a value like ITAB-PRICE. The expression (WA-SCREEN-NAME+5) will have the value PRICE. SORT ITAB BY (WA-SCREEN-NAME+5) will resolve to SORT ITAB BY PRICE. To adjust this code for use in your own program substitute the name of the control used in your program and calculate the offset required to trim the structure name from the selected SCREEN-NAME.
  • #30: This slide illustrates a table control object in a screen.