<?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: modifying few fields in the database table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370153#M525076</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;1. i hope u have a checkbox to select the fields

2. declare one more itab1 same as ur internal table

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
I_CALLBACK_USERCOMMAND = 'USER_COMMAND'.
I_GRID_TITLE = 'GRID DISPLAY'
IS_LAYOUT_LVC = WA_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCAT
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.

FORM USER_COMMAND  using ucomm like p_uconn 
                                                  p_selfield TYPE SLIS_SELFIELD.

Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1-&amp;gt;check_changed_data

case ucomm.

   when 'SAVE'.
       loop at itab where check eq 'X'.
          move-corresponding itab to itab1.
          append itab1.
       endloop.
    update ztable from table itab1.

endcase.

ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jun 2007 07:56:15 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-01T07:56:15Z</dc:date>
    <item>
      <title>modifying few fields in the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370150#M525073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all. I have an internal table, displayed in alv-grid. It has column named LBSTF. Database table MARD has the same field. I need to modify the data in this field in table MARD from the internal table, but only in rows, which are selected in the alv-grid. The internal table also has fields named as key fields of the table MARD. &lt;/P&gt;&lt;P&gt;Thanks all in advance.&lt;/P&gt;&lt;P&gt;Regards, Nikolai.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 07:49:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370150#M525073</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T07:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: modifying few fields in the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370151#M525074</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;U need to implement a routine for the USER-COMMAND event:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FORM USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                        RS_SELFIELD TYPE SLIS_SELFIELD.

  IF R_UCOMM = 'UPDT'.
    LOOP AT OUTTAB WHERE MARK = 'X'.
* Check MARD
      SELECT SINGLE * FROM MARD WHERE MATNR = OUTTAB-MATNR 
                                  AND WERKS = OUTTAB-WERKS
                                  AND LGORT = OUTTAB-WERKS.
      IF SY-SUBRC = 0.
        IF MARD-FIELD &amp;lt;&amp;gt; OUTTAB-FIELD.
          BAPIMATHEAD-MATERIAL     = OUTTAB-MATNR.
          BAPIMATHEAD-STORAGE_VIEW = 'X'.
          BAPI_MARDX-PLANT = BAPI_MARD-PLANT       = OUTTAB-WERKS.
          BAPI_MARDX-STGE_LOC = BAPI_MARD-STGE_LOC = OUTTAB-LGORT.
          BAPI_MARD-&amp;lt;FIELD&amp;gt;  = OUTTAB-FIELD.
          BAPI_MARDX-&amp;lt;FIELD&amp;gt; = 'X'.

          CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
              EXPORTING
               HEADDATA            = BAPIMATHEAD
               STORAGELOCATIONDATA = BAPI_MARD
              IMPORTING
               RETURN              = BAPIRET2.
         ENDIF. 
      ENDIF.        
    ENDLOOP.
  ENDIF. 
ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 07:52:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370151#M525074</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T07:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: modifying few fields in the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370152#M525075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;you need to use the SET keyword .......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET MARD-LBSTF = 'xxxx'.&lt;/P&gt;&lt;P&gt;MODIFY MARD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 07:52:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370152#M525075</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T07:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: modifying few fields in the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370153#M525076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;1. i hope u have a checkbox to select the fields

2. declare one more itab1 same as ur internal table

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
I_CALLBACK_USERCOMMAND = 'USER_COMMAND'.
I_GRID_TITLE = 'GRID DISPLAY'
IS_LAYOUT_LVC = WA_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCAT
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.

FORM USER_COMMAND  using ucomm like p_uconn 
                                                  p_selfield TYPE SLIS_SELFIELD.

Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1-&amp;gt;check_changed_data

case ucomm.

   when 'SAVE'.
       loop at itab where check eq 'X'.
          move-corresponding itab to itab1.
          append itab1.
       endloop.
    update ztable from table itab1.

endcase.

ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 07:56:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370153#M525076</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T07:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: modifying few fields in the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370154#M525077</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;      First of all Check whether you have the Authorization to do this. If you have as per you told (you have the key-fields of MARA in your internal table) simply you can update with UPDATE command..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the code below.Change the fields accordingly...&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;Update MARD st LBSTF = itab-lbstf&lt;/P&gt;&lt;P&gt; where matnr = itab-matnr and &lt;/P&gt;&lt;P&gt;          werks = itab-werks and&lt;/P&gt;&lt;P&gt;          lgort = itab-lgort.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also you can use UPDATE outside of the loop but before filter the internal table accordingly.Otherwise use the above mothod.&lt;/P&gt;&lt;P&gt;Thats all you have to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward All The Helpfull Answers............&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 07:57:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370154#M525077</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T07:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: modifying few fields in the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370155#M525078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, max, I have a routine for the USER-COMMAND event. There is a button at the toolbar with the function 'SAVE', the code is the following &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  METHOD handle_user_command.
    CASE e_ucomm.
      WHEN 'SAVE'. 

"-----------------------???????????????

    ENDCASE.
  ENDMETHOD.                    "handle_user_command
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 07:59:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370155#M525078</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T07:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: modifying few fields in the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370156#M525079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Biju, but what about updating only those rows, which are selected in the alv-grid. e.g. there are 10 rows in the internal table, they all are displayed in alv-grid. User selects only 3 of them (already in alv-grid) and by pushing 'SAVE' wants to update these 3 recordings in the field LBSTF of the table MARD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 08:07:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370156#M525079</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T08:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: modifying few fields in the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370157#M525080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nikolai,&lt;/P&gt;&lt;P&gt;You can code this in the event USER_COMMAND of CL_GUI_ALV_GRID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: x_lt_rows TYPE lvc_t_row .
DATA: x_ls_rows LIKE LINE OF x_lt_rows.

CALL METHOD grid_req-&amp;gt;get_selected_rows
  IMPORTING
    et_index_rows = x_lt_rows.

LOOP AT x_lt_rows INTO x_ls_rows.
  READ TABLE ITAB INDEX x_ls_rows-index INTO WA.
  APPEND WA TO IT_MARD.
ENDLOOP.
MODIFY MARD FROM IT_MARD.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 08:07:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370157#M525080</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T08:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: modifying few fields in the database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370158#M525081</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;Just as I explain in my prevoius answer you have to add in your output table a field for the mark and run the BAPI ( &amp;lt;b&amp;gt;don't update that table directly&amp;lt;/b&amp;gt;) for the item selected:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FORM USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                        RS_SELFIELD TYPE SLIS_SELFIELD.
 
  IF R_UCOMM = 'UPDT'.
    LOOP AT OUTTAB WHERE MARK = 'X'.
* Check MARD
      SELECT SINGLE * FROM MARD WHERE MATNR = OUTTAB-MATNR 
                                  AND WERKS = OUTTAB-WERKS
                                  AND LGORT = OUTTAB-WERKS.
      IF SY-SUBRC = 0.
        IF MARD-LBSTF &amp;lt;&amp;gt; OUTTAB-LBSTF.
          BAPIMATHEAD-MATERIAL     = OUTTAB-MATNR.
          BAPIMATHEAD-STORAGE_VIEW = 'X'.
          BAPI_MARDX-PLANT = BAPI_MARD-PLANT       = OUTTAB-WERKS.
          BAPI_MARDX-STGE_LOC = BAPI_MARD-STGE_LOC = OUTTAB-LGORT.
          BAPI_MARD-LBSTF  = OUTTAB-LBSTF.
          BAPI_MARDX-LBSTF = 'X'.
 
          CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
              EXPORTING
               HEADDATA            = BAPIMATHEAD
               STORAGELOCATIONDATA = BAPI_MARD
              IMPORTING
               RETURN              = BAPIRET2.
         ENDIF. 
      ENDIF.        
    ENDLOOP.
  ENDIF. 
ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't rember if this BAPI wants the BAPI for the commit after calling it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can indicate which field has to be used for the mark in layout structure:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lt_layout-box_fieldname = 'MARK'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2007 08:19:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modifying-few-fields-in-the-database-table/m-p/2370158#M525081</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-01T08:19:42Z</dc:date>
    </item>
  </channel>
</rss>

