<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: bdc for XK02 getting problem in table control????? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-for-xk02-getting-problem-in-table-control/m-p/4017594#M959966</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ashu loya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls&lt;/P&gt;&lt;P&gt;ABAP offers two mechanisms for displaying and using table data in a screen. These mechanisms are table controls and step &lt;/P&gt;&lt;P&gt;loops. Table controls and step loops are types of screen tables you can add to a screen in the Screen Painter. For example, &lt;/P&gt;&lt;P&gt;the following screen contains a table control at the bottom:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This chapter describes how to program the screen flow logic and ABAP code that let you use screen tables. For information &lt;/P&gt;&lt;P&gt;on using screen tables, see:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls in the Flow Logic&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looping Through an Internal Table&lt;/P&gt;&lt;P&gt;Systemfelder&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Datentransports&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following statement loops through an internal table and a screen table in parallel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;internal table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In particular, LOOP AT loops through the portion of the internal table that is currently visible in the screen. You can use this form of &lt;/P&gt;&lt;P&gt;the LOOP statement for both table controls and step loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The complete syntax for this form of the LOOP statement is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;internal table&amp;gt; CURSOR &amp;lt;scroll-var&amp;gt;&lt;/P&gt;&lt;P&gt;                     [WITH CONTROL &amp;lt;table-control&amp;gt; ]&lt;/P&gt;&lt;P&gt;                     [FROM &amp;lt;line1&amp;gt; ]  [TO &amp;lt;line2&amp;gt; ].&lt;/P&gt;&lt;P&gt;...&amp;lt;actions&amp;gt;...&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This form of LOOP loops through the internal table, performing &amp;lt;actions&amp;gt; for each row. For each internal table row, the system &lt;/P&gt;&lt;P&gt;transfers the relevant program fields to or from the corresponding screen table row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using step loops, omit the CURSOR parameter in the PAI event. The FROM and TO parameters are only possible with step loops. &lt;/P&gt;&lt;P&gt;(For further information, refer to Using Step Loops.) The WITH CONTROL parameter is only for use with table controls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For further information, refer to the following sections:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How the System Transfers Data Values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scrolling and the Scroll Variables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls: Example with Browser&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls: Examples with Scrolling&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following example processes a table control with LOOP without parallel loop using an internal table. In addition to the scroll bar, &lt;/P&gt;&lt;P&gt;the user can also carry out program-controlled scrolling with function codes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_dynpro_tabcont_loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: ok_code TYPE sy-ucomm,&lt;/P&gt;&lt;P&gt;save_ok TYPE sy-ucomm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itab TYPE TABLE OF demo_conn,&lt;/P&gt;&lt;P&gt;fill TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES demo_conn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lines TYPE i,&lt;/P&gt;&lt;P&gt;limit TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL SCREEN 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE status_0100 OUTPUT.&lt;/P&gt;&lt;P&gt;SET PF-STATUS 'SCREEN_100'.&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE itab LINES fill.&lt;/P&gt;&lt;P&gt;flights-lines = fill.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE fill_table_control OUTPUT.&lt;/P&gt;&lt;P&gt;READ TABLE itab INTO demo_conn INDEX flights-current_line.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE cancel INPUT.&lt;/P&gt;&lt;P&gt;LEAVE PROGRAM.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE read_table_control INPUT.&lt;/P&gt;&lt;P&gt;lines = sy-loopc.&lt;/P&gt;&lt;P&gt;MODIFY itab FROM demo_conn INDEX flights-current_line.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE user_command_0100 INPUT.&lt;/P&gt;&lt;P&gt;save_ok = ok_code.&lt;/P&gt;&lt;P&gt;CLEAR ok_code.&lt;/P&gt;&lt;P&gt;CASE save_ok.&lt;/P&gt;&lt;P&gt;WHEN 'NEXT_LINE'.&lt;/P&gt;&lt;P&gt;flights-top_line = flights-top_line + 1.&lt;/P&gt;&lt;P&gt;limit = fill - lines + 1.&lt;/P&gt;&lt;P&gt;IF flights-top_line &amp;gt; limit.&lt;/P&gt;&lt;P&gt; flights-top_line = limit.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'PREV_LINE'.&lt;/P&gt;&lt;P&gt;flights-top_line = flights-top_line - 1.&lt;/P&gt;&lt;P&gt;IF flights-top_line &amp;lt; 0.&lt;/P&gt;&lt;P&gt; flights-top_line = 0.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'NEXT_PAGE'.&lt;/P&gt;&lt;P&gt;flights-top_line = flights-top_line + lines.&lt;/P&gt;&lt;P&gt;limit = fill - lines + 1.&lt;/P&gt;&lt;P&gt;IF flights-top_line &amp;gt; limit.&lt;/P&gt;&lt;P&gt; flights-top_line = limit.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'PREV_PAGE'.&lt;/P&gt;&lt;P&gt;flights-top_line = flights-top_line - lines.&lt;/P&gt;&lt;P&gt;IF flights-top_line &amp;lt; 0.&lt;/P&gt;&lt;P&gt; flights-top_line = 0.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'LAST_PAGE'.&lt;/P&gt;&lt;P&gt;flights-top_line =  fill - lines + 1.&lt;/P&gt;&lt;P&gt;WHEN 'FIRST_PAGE'.&lt;/P&gt;&lt;P&gt;flights-top_line = 0.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls: Example with Modifications&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls: Examples with Modifications&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following example processes a table control with LOOP with parallel loop using an internal table. By using function codes you can &lt;/P&gt;&lt;P&gt;sort columns and delete rows from the internal table. The ready for input status of the table control fields is controlled using a &lt;/P&gt;&lt;P&gt;function code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_dynpro_tabcont_loop_at.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.&lt;/P&gt;&lt;P&gt;DATA: cols LIKE LINE OF flights-cols,&lt;/P&gt;&lt;P&gt;lines TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: ok_code TYPE sy-ucomm,&lt;/P&gt;&lt;P&gt;save_ok TYPE sy-ucomm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itab TYPE TABLE OF demo_conn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES demo_conn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT flights-cols INTO cols WHERE index GT 2.&lt;/P&gt;&lt;P&gt;cols-screen-input = '0'.&lt;/P&gt;&lt;P&gt;MODIFY flights-cols FROM cols INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL SCREEN 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE status_0100 OUTPUT.&lt;/P&gt;&lt;P&gt;SET PF-STATUS 'SCREEN_100'.&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE itab LINES lines.&lt;/P&gt;&lt;P&gt;flights-lines = lines.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE cancel INPUT.&lt;/P&gt;&lt;P&gt;LEAVE PROGRAM.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE read_table_control INPUT.&lt;/P&gt;&lt;P&gt;MODIFY itab FROM demo_conn INDEX flights-current_line.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE user_command_0100 INPUT.&lt;/P&gt;&lt;P&gt;save_ok = ok_code.&lt;/P&gt;&lt;P&gt;CLEAR ok_code.&lt;/P&gt;&lt;P&gt;CASE save_ok.&lt;/P&gt;&lt;P&gt;WHEN 'TOGGLE'.&lt;/P&gt;&lt;P&gt;LOOP AT flights-cols INTO cols WHERE index GT 2.&lt;/P&gt;&lt;P&gt; IF  cols-screen-input = '0'.&lt;/P&gt;&lt;P&gt;   cols-screen-input = '1'.&lt;/P&gt;&lt;P&gt; ELSEIF  cols-screen-input = '1'.&lt;/P&gt;&lt;P&gt;   cols-screen-input = '0'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;MODIFY flights-cols FROM cols INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;WHEN 'SORT_UP'.&lt;/P&gt;&lt;P&gt;READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt; SORT itab STABLE BY (cols-screen-name+10) ASCENDING.&lt;/P&gt;&lt;P&gt; cols-selected = ' '.&lt;/P&gt;&lt;P&gt;MODIFY flights-cols FROM cols INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'SORT_DOWN'.&lt;/P&gt;&lt;P&gt;READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt; SORT itab STABLE BY (cols-screen-name+10) DESCENDING.&lt;/P&gt;&lt;P&gt; cols-selected = ' '.&lt;/P&gt;&lt;P&gt;MODIFY flights-cols FROM cols INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'DELETE'.&lt;/P&gt;&lt;P&gt;READ TABLE flights-cols INTO cols&lt;/P&gt;&lt;P&gt;                       WITH KEY screen-input = '1'.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt; LOOP AT itab INTO demo_conn WHERE mark = 'X'.&lt;/P&gt;&lt;P&gt;   DELETE itab.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A resizable table control called FLIGHTS is defined. The fields of the table control are transferred from the structure DEMO_CONN in &lt;/P&gt;&lt;P&gt;the ABAP Dictionary. The first two columns are lead columns. The corresponding fields are output fields. A title bar, columns headers, &lt;/P&gt;&lt;P&gt;and a selection column are created. The component MARK of type character with length 1 from structure DEMO_CONN is assigned to &lt;/P&gt;&lt;P&gt;the selection column. You can select one column and several lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It has the following flow logic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROCESS BEFORE OUTPUT.&lt;/P&gt;&lt;P&gt;MODULE status_0100.&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO demo_conn WITH CONTROL flights.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROCESS AFTER INPUT.&lt;/P&gt;&lt;P&gt;MODULE cancel AT EXIT-COMMAND.&lt;/P&gt;&lt;P&gt;LOOP AT itab.&lt;/P&gt;&lt;P&gt;MODULE read_table_control.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;MODULE user_command_0100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A loop is executed at PBO and PAI using the table control FLIGHTS and is also executed using the internal table ITAB of the ABAP &lt;/P&gt;&lt;P&gt;program. During the PBO loop, no module is called to fill the table control from table ITAB of the ABAP program. However, during the &lt;/P&gt;&lt;P&gt;PAI loop, a module is called to modify table ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At PBO the component LINES of control structure FLIGHTS is filled explicitly with the current number of rows of the internal table &lt;/P&gt;&lt;P&gt;before the PBO loop to install the scroll bar of the table control.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;During the PBO loop, in the module FILL_TABLE_CONTROL the work area DEMO_CONN is filled with values from the internal table, &lt;/P&gt;&lt;P&gt;where the row index corresponds to the current row of the table control.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;During the PAI loop, the rows of the internal table, whose row index corresponds to the current row of the table control, are &lt;/P&gt;&lt;P&gt;overwritten with the contents of the work area DEMO_CONN. User input is transferred from the input fields of the control to the &lt;/P&gt;&lt;P&gt;internal table. In particular, the internal table also contains a flag in the column MARK to indicate whether the row of the table control &lt;/P&gt;&lt;P&gt;is selected or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After the PAI loop, user input is processed in the module USER_COMMAND. The GUI status SCREEN_100 provides the appropriate &lt;/P&gt;&lt;P&gt;function codes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the program is called not all of the fields in the table control are ready for input. The static specifications of the table control in &lt;/P&gt;&lt;P&gt;the Screen Painter are modified before CALL SCREEN in the program. The system uses the table COLS in control structure FLIGHTS. &lt;/P&gt;&lt;P&gt;All columns with a column position larger than two are set to not ready for input status in a loop using the table FLIGHT-COLS. By &lt;/P&gt;&lt;P&gt;choosing the function code TOGGLE, you can change the ready for input status of the columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function codes SORT_UP and SORT_DOWN allow you to sort selected columns of the internal table ITAB ascending or &lt;/P&gt;&lt;P&gt;descending. The static settings of the table control allow you to select only a single column. The selected column is derived from the &lt;/P&gt;&lt;P&gt;internal table FLIGHT-COLS. The name of the sort criteria in the SORT statement is determined dynamically from the component &lt;/P&gt;&lt;P&gt;COLS-SCREEN-NAME. The prefix DEMO_CONN- must be removed using an offset specification. After sort the selection is undone, and &lt;/P&gt;&lt;P&gt;the component SELECTED in table FLIGHT-COLS is assigned a blank character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can delete selected rows from the internal table ITAB using the function code DELETE. First the system checks whether the fields &lt;/P&gt;&lt;P&gt;of the table control are ready for input. Then all selected rows are deleted in a loop using the internal table ITAB. Since the table &lt;/P&gt;&lt;P&gt;control is read again from the internal table in the PBO loop, the rows on the screen are deleted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks abdul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Jun 2008 12:59:41 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-12T12:59:41Z</dc:date>
    <item>
      <title>bdc for XK02 getting problem in table control?????</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-for-xk02-getting-problem-in-table-control/m-p/4017593#M959965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello i want to migrate data for vendor.i want to update VAT date and VAT number. but i m not getting how to handle index of table control? coz when we scroll down index get changed......&lt;/P&gt;&lt;P&gt;pls guide me......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2008 06:37:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-for-xk02-getting-problem-in-table-control/m-p/4017593#M959965</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-12T06:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: bdc for XK02 getting problem in table control?????</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-for-xk02-getting-problem-in-table-control/m-p/4017594#M959966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ashu loya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls&lt;/P&gt;&lt;P&gt;ABAP offers two mechanisms for displaying and using table data in a screen. These mechanisms are table controls and step &lt;/P&gt;&lt;P&gt;loops. Table controls and step loops are types of screen tables you can add to a screen in the Screen Painter. For example, &lt;/P&gt;&lt;P&gt;the following screen contains a table control at the bottom:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This chapter describes how to program the screen flow logic and ABAP code that let you use screen tables. For information &lt;/P&gt;&lt;P&gt;on using screen tables, see:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls in the Flow Logic&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looping Through an Internal Table&lt;/P&gt;&lt;P&gt;Systemfelder&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Datentransports&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following statement loops through an internal table and a screen table in parallel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;internal table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In particular, LOOP AT loops through the portion of the internal table that is currently visible in the screen. You can use this form of &lt;/P&gt;&lt;P&gt;the LOOP statement for both table controls and step loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The complete syntax for this form of the LOOP statement is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;internal table&amp;gt; CURSOR &amp;lt;scroll-var&amp;gt;&lt;/P&gt;&lt;P&gt;                     [WITH CONTROL &amp;lt;table-control&amp;gt; ]&lt;/P&gt;&lt;P&gt;                     [FROM &amp;lt;line1&amp;gt; ]  [TO &amp;lt;line2&amp;gt; ].&lt;/P&gt;&lt;P&gt;...&amp;lt;actions&amp;gt;...&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This form of LOOP loops through the internal table, performing &amp;lt;actions&amp;gt; for each row. For each internal table row, the system &lt;/P&gt;&lt;P&gt;transfers the relevant program fields to or from the corresponding screen table row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using step loops, omit the CURSOR parameter in the PAI event. The FROM and TO parameters are only possible with step loops. &lt;/P&gt;&lt;P&gt;(For further information, refer to Using Step Loops.) The WITH CONTROL parameter is only for use with table controls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For further information, refer to the following sections:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How the System Transfers Data Values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scrolling and the Scroll Variables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls: Example with Browser&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls: Examples with Scrolling&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following example processes a table control with LOOP without parallel loop using an internal table. In addition to the scroll bar, &lt;/P&gt;&lt;P&gt;the user can also carry out program-controlled scrolling with function codes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_dynpro_tabcont_loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: ok_code TYPE sy-ucomm,&lt;/P&gt;&lt;P&gt;save_ok TYPE sy-ucomm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itab TYPE TABLE OF demo_conn,&lt;/P&gt;&lt;P&gt;fill TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES demo_conn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lines TYPE i,&lt;/P&gt;&lt;P&gt;limit TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL SCREEN 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE status_0100 OUTPUT.&lt;/P&gt;&lt;P&gt;SET PF-STATUS 'SCREEN_100'.&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE itab LINES fill.&lt;/P&gt;&lt;P&gt;flights-lines = fill.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE fill_table_control OUTPUT.&lt;/P&gt;&lt;P&gt;READ TABLE itab INTO demo_conn INDEX flights-current_line.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE cancel INPUT.&lt;/P&gt;&lt;P&gt;LEAVE PROGRAM.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE read_table_control INPUT.&lt;/P&gt;&lt;P&gt;lines = sy-loopc.&lt;/P&gt;&lt;P&gt;MODIFY itab FROM demo_conn INDEX flights-current_line.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE user_command_0100 INPUT.&lt;/P&gt;&lt;P&gt;save_ok = ok_code.&lt;/P&gt;&lt;P&gt;CLEAR ok_code.&lt;/P&gt;&lt;P&gt;CASE save_ok.&lt;/P&gt;&lt;P&gt;WHEN 'NEXT_LINE'.&lt;/P&gt;&lt;P&gt;flights-top_line = flights-top_line + 1.&lt;/P&gt;&lt;P&gt;limit = fill - lines + 1.&lt;/P&gt;&lt;P&gt;IF flights-top_line &amp;gt; limit.&lt;/P&gt;&lt;P&gt; flights-top_line = limit.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'PREV_LINE'.&lt;/P&gt;&lt;P&gt;flights-top_line = flights-top_line - 1.&lt;/P&gt;&lt;P&gt;IF flights-top_line &amp;lt; 0.&lt;/P&gt;&lt;P&gt; flights-top_line = 0.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'NEXT_PAGE'.&lt;/P&gt;&lt;P&gt;flights-top_line = flights-top_line + lines.&lt;/P&gt;&lt;P&gt;limit = fill - lines + 1.&lt;/P&gt;&lt;P&gt;IF flights-top_line &amp;gt; limit.&lt;/P&gt;&lt;P&gt; flights-top_line = limit.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'PREV_PAGE'.&lt;/P&gt;&lt;P&gt;flights-top_line = flights-top_line - lines.&lt;/P&gt;&lt;P&gt;IF flights-top_line &amp;lt; 0.&lt;/P&gt;&lt;P&gt; flights-top_line = 0.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'LAST_PAGE'.&lt;/P&gt;&lt;P&gt;flights-top_line =  fill - lines + 1.&lt;/P&gt;&lt;P&gt;WHEN 'FIRST_PAGE'.&lt;/P&gt;&lt;P&gt;flights-top_line = 0.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls: Example with Modifications&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Controls: Examples with Modifications&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following example processes a table control with LOOP with parallel loop using an internal table. By using function codes you can &lt;/P&gt;&lt;P&gt;sort columns and delete rows from the internal table. The ready for input status of the table control fields is controlled using a &lt;/P&gt;&lt;P&gt;function code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_dynpro_tabcont_loop_at.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.&lt;/P&gt;&lt;P&gt;DATA: cols LIKE LINE OF flights-cols,&lt;/P&gt;&lt;P&gt;lines TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: ok_code TYPE sy-ucomm,&lt;/P&gt;&lt;P&gt;save_ok TYPE sy-ucomm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itab TYPE TABLE OF demo_conn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES demo_conn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT flights-cols INTO cols WHERE index GT 2.&lt;/P&gt;&lt;P&gt;cols-screen-input = '0'.&lt;/P&gt;&lt;P&gt;MODIFY flights-cols FROM cols INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL SCREEN 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE status_0100 OUTPUT.&lt;/P&gt;&lt;P&gt;SET PF-STATUS 'SCREEN_100'.&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE itab LINES lines.&lt;/P&gt;&lt;P&gt;flights-lines = lines.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE cancel INPUT.&lt;/P&gt;&lt;P&gt;LEAVE PROGRAM.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE read_table_control INPUT.&lt;/P&gt;&lt;P&gt;MODIFY itab FROM demo_conn INDEX flights-current_line.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE user_command_0100 INPUT.&lt;/P&gt;&lt;P&gt;save_ok = ok_code.&lt;/P&gt;&lt;P&gt;CLEAR ok_code.&lt;/P&gt;&lt;P&gt;CASE save_ok.&lt;/P&gt;&lt;P&gt;WHEN 'TOGGLE'.&lt;/P&gt;&lt;P&gt;LOOP AT flights-cols INTO cols WHERE index GT 2.&lt;/P&gt;&lt;P&gt; IF  cols-screen-input = '0'.&lt;/P&gt;&lt;P&gt;   cols-screen-input = '1'.&lt;/P&gt;&lt;P&gt; ELSEIF  cols-screen-input = '1'.&lt;/P&gt;&lt;P&gt;   cols-screen-input = '0'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;MODIFY flights-cols FROM cols INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;WHEN 'SORT_UP'.&lt;/P&gt;&lt;P&gt;READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt; SORT itab STABLE BY (cols-screen-name+10) ASCENDING.&lt;/P&gt;&lt;P&gt; cols-selected = ' '.&lt;/P&gt;&lt;P&gt;MODIFY flights-cols FROM cols INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'SORT_DOWN'.&lt;/P&gt;&lt;P&gt;READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt; SORT itab STABLE BY (cols-screen-name+10) DESCENDING.&lt;/P&gt;&lt;P&gt; cols-selected = ' '.&lt;/P&gt;&lt;P&gt;MODIFY flights-cols FROM cols INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WHEN 'DELETE'.&lt;/P&gt;&lt;P&gt;READ TABLE flights-cols INTO cols&lt;/P&gt;&lt;P&gt;                       WITH KEY screen-input = '1'.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt; LOOP AT itab INTO demo_conn WHERE mark = 'X'.&lt;/P&gt;&lt;P&gt;   DELETE itab.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;ENDMODULE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A resizable table control called FLIGHTS is defined. The fields of the table control are transferred from the structure DEMO_CONN in &lt;/P&gt;&lt;P&gt;the ABAP Dictionary. The first two columns are lead columns. The corresponding fields are output fields. A title bar, columns headers, &lt;/P&gt;&lt;P&gt;and a selection column are created. The component MARK of type character with length 1 from structure DEMO_CONN is assigned to &lt;/P&gt;&lt;P&gt;the selection column. You can select one column and several lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It has the following flow logic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROCESS BEFORE OUTPUT.&lt;/P&gt;&lt;P&gt;MODULE status_0100.&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO demo_conn WITH CONTROL flights.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROCESS AFTER INPUT.&lt;/P&gt;&lt;P&gt;MODULE cancel AT EXIT-COMMAND.&lt;/P&gt;&lt;P&gt;LOOP AT itab.&lt;/P&gt;&lt;P&gt;MODULE read_table_control.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;MODULE user_command_0100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A loop is executed at PBO and PAI using the table control FLIGHTS and is also executed using the internal table ITAB of the ABAP &lt;/P&gt;&lt;P&gt;program. During the PBO loop, no module is called to fill the table control from table ITAB of the ABAP program. However, during the &lt;/P&gt;&lt;P&gt;PAI loop, a module is called to modify table ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At PBO the component LINES of control structure FLIGHTS is filled explicitly with the current number of rows of the internal table &lt;/P&gt;&lt;P&gt;before the PBO loop to install the scroll bar of the table control.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;During the PBO loop, in the module FILL_TABLE_CONTROL the work area DEMO_CONN is filled with values from the internal table, &lt;/P&gt;&lt;P&gt;where the row index corresponds to the current row of the table control.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;During the PAI loop, the rows of the internal table, whose row index corresponds to the current row of the table control, are &lt;/P&gt;&lt;P&gt;overwritten with the contents of the work area DEMO_CONN. User input is transferred from the input fields of the control to the &lt;/P&gt;&lt;P&gt;internal table. In particular, the internal table also contains a flag in the column MARK to indicate whether the row of the table control &lt;/P&gt;&lt;P&gt;is selected or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After the PAI loop, user input is processed in the module USER_COMMAND. The GUI status SCREEN_100 provides the appropriate &lt;/P&gt;&lt;P&gt;function codes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the program is called not all of the fields in the table control are ready for input. The static specifications of the table control in &lt;/P&gt;&lt;P&gt;the Screen Painter are modified before CALL SCREEN in the program. The system uses the table COLS in control structure FLIGHTS. &lt;/P&gt;&lt;P&gt;All columns with a column position larger than two are set to not ready for input status in a loop using the table FLIGHT-COLS. By &lt;/P&gt;&lt;P&gt;choosing the function code TOGGLE, you can change the ready for input status of the columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function codes SORT_UP and SORT_DOWN allow you to sort selected columns of the internal table ITAB ascending or &lt;/P&gt;&lt;P&gt;descending. The static settings of the table control allow you to select only a single column. The selected column is derived from the &lt;/P&gt;&lt;P&gt;internal table FLIGHT-COLS. The name of the sort criteria in the SORT statement is determined dynamically from the component &lt;/P&gt;&lt;P&gt;COLS-SCREEN-NAME. The prefix DEMO_CONN- must be removed using an offset specification. After sort the selection is undone, and &lt;/P&gt;&lt;P&gt;the component SELECTED in table FLIGHT-COLS is assigned a blank character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can delete selected rows from the internal table ITAB using the function code DELETE. First the system checks whether the fields &lt;/P&gt;&lt;P&gt;of the table control are ready for input. Then all selected rows are deleted in a loop using the internal table ITAB. Since the table &lt;/P&gt;&lt;P&gt;control is read again from the internal table in the PBO loop, the rows on the screen are deleted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks abdul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2008 12:59:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-for-xk02-getting-problem-in-table-control/m-p/4017594#M959966</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-12T12:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: bdc for XK02 getting problem in table control?????</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-for-xk02-getting-problem-in-table-control/m-p/4017595#M959967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Control in BDC, Go through following Links :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm" target="test_blank"&gt;http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rewards Points if useful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ranjith.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2008 22:15:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-for-xk02-getting-problem-in-table-control/m-p/4017595#M959967</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-12T22:15:36Z</dc:date>
    </item>
  </channel>
</rss>

