<?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 Access fields in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953937#M65809</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;PROCESS AFTER INPUT.  &lt;/P&gt;&lt;P&gt;LOOP AT i_makt.  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;This will take care of updating the internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  FIELD i_makt-pick MODULE check.  &lt;/P&gt;&lt;P&gt;  FIELD i_makt-zmatnr MODULE zmatnr .  &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE check INPUT. &lt;/P&gt;&lt;P&gt; MODIFY i_makt INDEX t_ctrl-current_line.&lt;/P&gt;&lt;P&gt;ENDMODULE.                 " CHECK  INPUT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE zmatnr INPUT.&lt;/P&gt;&lt;P&gt;  MODIFY i_makt INDEX t_ctrl-current_line.&lt;/P&gt;&lt;P&gt;  IF t_ctrl-current_line GT ln.&lt;/P&gt;&lt;P&gt;    READ TABLE i_makt WITH KEY zmatnr = i_makt-zmatnr.&lt;/P&gt;&lt;P&gt;    IF sy-subrc NE 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Inserting record if it does not exist in database&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      APPEND i_makt.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;     MESSAGE i005 WITH 'Material Number' i_makt-zmatnr 'already exists'.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDMODULE.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in PAI,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHEN 'SAVE'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Inserting new record or updating existing record in database table from the internal table   &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   MODIFY zzz_makt FROM TABLE i_makt. &lt;/P&gt;&lt;P&gt;   MESSAGE s005 WITH 'Saved Successfully'.&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Aug 2005 06:16:01 GMT</pubDate>
    <dc:creator>jayanthi_jayaraman</dc:creator>
    <dc:date>2005-08-02T06:16:01Z</dc:date>
    <item>
      <title>Table control Access fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953930#M65802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;         I have 2 queries regarding table control.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;1.&amp;lt;/b&amp;gt; Is it possible to access the table control changed text from screen? How? &lt;/P&gt;&lt;P&gt;Here I have to display the data in table control &amp;amp; when user selects change the changed text is to be saved in data base table when user selects save after making the changes.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;2.&amp;lt;/b&amp;gt;How to enable only one selected row for updation.&lt;/P&gt;&lt;P&gt;Here if I say change all the rows are enabled for change mode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Dilip&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 07:11:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953930#M65802</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T07:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Table control Access fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953931#M65803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;  1, To access the changed fields in the table control, declare an internal table with the same name as table control and the fields (inside the internal table) same as the table control fields(probably, u could have used such an internal table for poping up the data to the table control).&lt;/P&gt;&lt;P&gt;   Now, Use the Loop at &amp;lt;internal table&amp;gt; statement in the PAI, which gets the data from the table control row by row and places in the header of the internal table. Then use the modify statement to update the internal table.&lt;/P&gt;&lt;P&gt;  2, Check the SCREEN structure for the particular columnname and make the INPUT field as 1 for enabling updation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 07:48:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953931#M65803</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T07:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Table control Access fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953932#M65804</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;To make selected rows for editable mode,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE set_screen_fields OUTPUT.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; LOOP AT SCREEN.
       IF ( ( screen-name = 'I_MAKT-ZMAKTX'
             OR screen-name = 'I_MAKT-CHECK1' )
            AND &amp;lt;b&amp;gt;t_ctrl-current_line&amp;lt;/b&amp;gt; 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.
    MODIFY SCREEN.
  ENDLOOP.
ENDMODULE.                 " set_screen_fields  OUTPUT
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the sample code for table control.&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

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

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

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

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

MODULE set_status OUTPUT.
  SET PF-STATUS 'ZSTATUS'.
  SET TITLEBAR  'ZTITLE'.
ENDMODULE.                 " set_status  OUTPUT

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;P&gt;Hope it helps.If so,kindly reward points.Otherwise get back.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 08:20:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953932#M65804</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2005-08-01T08:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Table control Access fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953933#M65805</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;1. It is possible to access the data from the table   &lt;/P&gt;&lt;P&gt;   control. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Declare a same internal table like Table control, so that data will be automatically available in that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. In order to make the field editable,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Loop at screen.&lt;/P&gt;&lt;P&gt;    Check for the table control field with field name and make it editable using "Screen_input = 1".&lt;/P&gt;&lt;P&gt;   endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Venkat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 09:10:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953933#M65805</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T09:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Table control Access fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953934#M65806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jayanti,&lt;/P&gt;&lt;P&gt;    When I click on modify button it enables the columnn editable instead of making editable for the particular row editable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dilip&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 11:00:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953934#M65806</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T11:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Table control Access fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953935#M65807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Diliip,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AS I already mentioned in my reply,t_ctrl-current_line is compared to check the rows and screen-name is compared to check columns in that rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF ( ( screen-name = 'I_MAKT-ZMAKTX' &lt;/P&gt;&lt;P&gt;       OR screen-name = 'I_MAKT-CHECK1' ) &lt;/P&gt;&lt;P&gt;       AND t_ctrl-current_line EQ 1) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code refers to First row and 2 columns mentioned by screen-name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 11:03:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953935#M65807</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2005-08-01T11:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Table control Access fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953936#M65808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jayanthi,&lt;/P&gt;&lt;P&gt;            Still I am not able to get the changed values on screen by the user. How to access the table control changed values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dilip&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 05:36:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953936#M65808</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-02T05:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Table control Access fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953937#M65809</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;PROCESS AFTER INPUT.  &lt;/P&gt;&lt;P&gt;LOOP AT i_makt.  &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;This will take care of updating the internal table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  FIELD i_makt-pick MODULE check.  &lt;/P&gt;&lt;P&gt;  FIELD i_makt-zmatnr MODULE zmatnr .  &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE check INPUT. &lt;/P&gt;&lt;P&gt; MODIFY i_makt INDEX t_ctrl-current_line.&lt;/P&gt;&lt;P&gt;ENDMODULE.                 " CHECK  INPUT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODULE zmatnr INPUT.&lt;/P&gt;&lt;P&gt;  MODIFY i_makt INDEX t_ctrl-current_line.&lt;/P&gt;&lt;P&gt;  IF t_ctrl-current_line GT ln.&lt;/P&gt;&lt;P&gt;    READ TABLE i_makt WITH KEY zmatnr = i_makt-zmatnr.&lt;/P&gt;&lt;P&gt;    IF sy-subrc NE 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Inserting record if it does not exist in database&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      APPEND i_makt.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;     MESSAGE i005 WITH 'Material Number' i_makt-zmatnr 'already exists'.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDMODULE.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in PAI,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHEN 'SAVE'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Inserting new record or updating existing record in database table from the internal table   &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   MODIFY zzz_makt FROM TABLE i_makt. &lt;/P&gt;&lt;P&gt;   MESSAGE s005 WITH 'Saved Successfully'.&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 06:16:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953937#M65809</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2005-08-02T06:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Table control Access fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953938#M65810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jayanthi, &lt;/P&gt;&lt;P&gt;               My problem is solved ! Thanks for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dilip&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 07:04:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/table-control-access-fields/m-p/953938#M65810</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-02T07:04:02Z</dc:date>
    </item>
  </channel>
</rss>

