<?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: Table control, itab not appending in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939274#M62806</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;use:&lt;/P&gt;&lt;P&gt;DATA: l type i, index TYPE i.&lt;/P&gt;&lt;P&gt;CLEAR: l, index.&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE itab LINES l.&lt;/P&gt;&lt;P&gt;IF l = 0.&lt;/P&gt;&lt;P&gt; index = 1.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt; index = l + 1.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then:&lt;/P&gt;&lt;P&gt;MODIFY itab INDEX index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 20 Aug 2005 16:48:45 GMT</pubDate>
    <dc:creator>former_member182371</dc:creator>
    <dc:date>2005-08-20T16:48:45Z</dc:date>
    <item>
      <title>Table control, itab not appending</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939270#M62802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all ,&lt;/P&gt;&lt;P&gt;   I have created a table control program , &lt;/P&gt;&lt;P&gt;the module modify which appends the itab is not working,&lt;/P&gt;&lt;P&gt;in change mode , when there is data already in the table control , if we make changes in the table control then it gets modified , but when we trying to add some data newly into the table control , the itab is not gettning updated,  &lt;/P&gt;&lt;P&gt;  Please help .. its urgent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Aug 2005 13:41:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939270#M62802</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-20T13:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Table control, itab not appending</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939271#M62803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;if you want to add a new record to the internal table do something like:&lt;/P&gt;&lt;P&gt;Check if the entry already exists with&lt;/P&gt;&lt;P&gt;READ TABLE itab WITH KEY field1 = wa-field.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;  MODIFY itab WITH INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;  itab-field = wa-field.&lt;/P&gt;&lt;P&gt;  APPEND itab.&lt;/P&gt;&lt;P&gt;  CLEAR itab.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Aug 2005 14:18:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939271#M62803</guid>
      <dc:creator>former_member182371</dc:creator>
      <dc:date>2005-08-20T14:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Table control, itab not appending</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939272#M62804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;instead of &lt;/P&gt;&lt;P&gt;MODIFY itab WITH INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;use&lt;/P&gt;&lt;P&gt;MODIFY itab INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Aug 2005 14:30:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939272#M62804</guid>
      <dc:creator>former_member182371</dc:creator>
      <dc:date>2005-08-20T14:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Table control, itab not appending</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939273#M62805</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;the modify command is not working if i m addi&lt;/P&gt;&lt;P&gt;ng a record newly , its only working if i have a old record in the table control .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Aug 2005 15:09:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939273#M62805</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-20T15:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: Table control, itab not appending</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939274#M62806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;use:&lt;/P&gt;&lt;P&gt;DATA: l type i, index TYPE i.&lt;/P&gt;&lt;P&gt;CLEAR: l, index.&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE itab LINES l.&lt;/P&gt;&lt;P&gt;IF l = 0.&lt;/P&gt;&lt;P&gt; index = 1.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt; index = l + 1.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then:&lt;/P&gt;&lt;P&gt;MODIFY itab INDEX index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Aug 2005 16:48:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939274#M62806</guid>
      <dc:creator>former_member182371</dc:creator>
      <dc:date>2005-08-20T16:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Table control, itab not appending</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939275#M62807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, something I want to remind you.&lt;/P&gt;&lt;P&gt;If you use a tab control, please check the PBO of your application.&lt;/P&gt;&lt;P&gt;normally, the code in PBI should like following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PROCESS BEFORE OUTPUT.
* PBO FLOW LOGIC FOR TABLECONTROL 'XXXX'
  MODULE XXXXX.

* please aware that the newly date should be added into
* internal table before the following LOOP
* otherwise, it won't reflect on the screen
  MODULE ADD_DATA.

  LOOP AT   IT_TAB
       INTO LC_TAB
       WITH CONTROL XXXX
       CURSOR XXXX-CURRENT_LINE.
  ENDLOOP.

MODULE ADD_DATA OUTPUT.
  lc_tab-field1 = '1'.
  lc_tab-field2 = '2'.
  lc_tab-field3 = '3'.
  append lc_tab to IT_TAB.
ENDMODULE.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it will be helpful&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Aug 2005 18:03:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939275#M62807</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-20T18:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Table control, itab not appending</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939276#M62808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please do have a look at this link:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap-code-samples/table" target="test_blank"&gt;https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap-code-samples/table&lt;/A&gt; control in abap.pdf&lt;/P&gt;&lt;P&gt;Here you´ll find an example that can be quite helpful.&lt;/P&gt;&lt;P&gt;Best Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Aug 2005 21:18:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939276#M62808</guid>
      <dc:creator>former_member182371</dc:creator>
      <dc:date>2005-08-20T21:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Table control, itab not appending</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939277#M62809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please post your relevant code here so that we can help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Aug 2005 03:19:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939277#M62809</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-21T03:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Table control, itab not appending</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939278#M62810</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;Here is the sample code.Kindly reward points by clicking the star on the left of reply,if you find it as useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PROCESS BEFORE OUTPUT.

  MODULE set_status.

  MODULE get_t_ctrl_lines.
  LOOP AT i_makt WITH CONTROL t_ctrl CURSOR t_ctrl-current_line.
* Dynamic screen modifications
    MODULE set_screen_fields.
  ENDLOOP.

*
PROCESS AFTER INPUT.

  LOOP AT i_makt.
    FIELD i_makt-pick MODULE check.
    FIELD i_makt-zmatnr MODULE zmatnr .
  ENDLOOP.

  MODULE user_command_9000.


In the program, write the following code.

PROGRAM SAPMZTC MESSAGE-ID zz.

***********************************************************************
* Tables Declaration
***********************************************************************
TABLES: zzz_makt.

***********************************************************************
* Internal table Declaration
***********************************************************************
DATA : i_makt TYPE STANDARD TABLE OF zzz_makt WITH HEADER LINE.

***********************************************************************
* Table control Declaration
***********************************************************************
CONTROLS: t_ctrl TYPE TABLEVIEW USING SCREEN '9000'.

***********************************************************************
* Variable Declaration
***********************************************************************
DATA : flg,           "Flag to set the change mode
       ln TYPE i.     "No. of records

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  get_T_CTRL_lines  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*  Populating data
*----------------------------------------------------------------------*
MODULE get_t_ctrl_lines OUTPUT.
  SELECT zmatnr zmaktx
         INTO CORRESPONDING FIELDS OF TABLE i_makt
         FROM zzz_makt.
  DESCRIBE TABLE i_makt LINES ln.
* To make the vertical scroll bar to come on runtime
  t_ctrl-lines = ln + 100.
ENDMODULE.                 " get_T_CTRL_lines  OUTPUT

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  USER_COMMAND_9000  INPUT
*&amp;amp;---------------------------------------------------------------------*
* Triggering event according to the user command
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
  DATA :lv_fcode LIKE sy-ucomm,    "Function Code
        lv_answer(1) type c.       "Storing the answer
  lv_fcode = sy-ucomm.
  CASE lv_fcode.
    WHEN 'CHANGE'.
* Setting the flag to make the table control in editable mode[excluding
* primary key].
      flg = 'Y'.
    WHEN 'DELETE'.
* Setting the flag to make the table control in editable mode after
* deleting the selected line
      flg = 'Y'.
* Confirmation of delete
      CALL FUNCTION 'POPUP_TO_CONFIRM'
        EXPORTING
         TITLEBAR       = 'Confirm'
         text_question  = 'Are you sure to delete from database?'
         TEXT_BUTTON_1  = 'Yes'(001)
         TEXT_BUTTON_2  = 'No'(002)
        IMPORTING
         ANSWER         =  lv_answer.
      if lv_answer eq '1'.
* Updating the database table from the internal table
        UPDATE zzz_makt FROM TABLE i_makt.
* Deleting the selected row from the internal table
        DELETE i_makt WHERE pick = 'X'.
* Deleting the selected row from the database table
        DELETE FROM zzz_makt WHERE pick = 'X'.
        MESSAGE s005 WITH 'Deleted Successfully'.
      ENDIF.
    WHEN 'SAVE'.
* Inserting new record or updating existing record in database table
* from the internal table
      MODIFY zzz_makt FROM TABLE i_makt.
      MESSAGE s005 WITH 'Saved Successfully'.
    WHEN 'BACK'.
      SET SCREEN '0'.
    WHEN 'EXIT' OR 'CANCEL'.
* Leaving the program
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_9000  INPUT

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  set_screen_fields  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
* Setting the screen fields
*----------------------------------------------------------------------*
MODULE set_screen_fields OUTPUT.
  LOOP AT SCREEN.
    IF flg IS INITIAL.
      screen-input = 0.
    ELSEIF ( flg EQ 'Y' ).
      IF ( ( screen-name = 'I_MAKT-ZMAKTX'
             OR screen-name = 'I_MAKT-CHECK1' )
            AND t_ctrl-current_line LE ln ) .
* Making the screen fields as editable
        screen-input = 1.
      ELSEIF ( ( screen-name = 'I_MAKT-ZMATNR' )
                 AND t_ctrl-current_line LE ln ).
* Making the screen field as uneditable
        screen-input = 0.
      ENDIF.
    ENDIF.
* Modifying the screen after making changes
    MODIFY SCREEN.
  ENDLOOP.
ENDMODULE.                 " set_screen_fields  OUTPUT

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  zmatnr  INPUT
*&amp;amp;---------------------------------------------------------------------*
* Appending records to the internal table
*----------------------------------------------------------------------*
MODULE zmatnr INPUT.
  MODIFY i_makt INDEX t_ctrl-current_line.
  IF t_ctrl-current_line GT ln.
    READ TABLE i_makt WITH KEY zmatnr = i_makt-zmatnr.
    IF sy-subrc NE 0.
* Inserting record if it does not exist in database
      APPEND i_makt.
    ELSE.
     MESSAGE i005 WITH 'Material Number' i_makt-zmatnr 'already exists'.
    ENDIF.
  ENDIF.
ENDMODULE.                 " zmatnr  INPUT

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  set_status  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
* Setting the GUI status
*----------------------------------------------------------------------*
MODULE set_status OUTPUT.
  SET PF-STATUS 'ZSTATUS'.
  SET TITLEBAR  'ZTITLE'.
ENDMODULE.                 " set_status  OUTPUT

*&amp;amp;---------------------------------------------------------------------
*&amp;amp;      Module  CHECK  INPUT
*&amp;amp;---------------------------------------------------------------------
* Modify the internal table using the current line in table control
*----------------------------------------------------------------------

MODULE check INPUT.
  MODIFY i_makt INDEX t_ctrl-current_line.
ENDMODULE.                 " CHECK  INPUT&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2005 03:54:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-itab-not-appending/m-p/939278#M62810</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2005-08-22T03:54:45Z</dc:date>
    </item>
  </channel>
</rss>

