<?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 modify dbtab from table transporting in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618775#M25754</link>
    <description>&lt;P&gt;There seems to be no way to MODIFY a DB table from an internal table TRANSPORTING only certain fields.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;It seems a pity to loop through the internal table and do thousands of MODIFY commands. Or, as show below, loop through the itab and load from the DB the data (e.g. field "hash") we want to retain.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;Is there a more elegant solution?&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;" Load parts from external system
DATA(lt_part) = ycl_hybris_api=&amp;gt;part_list(
  attributes = 'galleryImages,code,creationtime,modifiedtime'
  sort       = 'code'
).
CHECK lt_part IS NOT INITIAL.

" Set all timestamps to now
DATA ls_part TYPE y00_hyb_parts.
ls_part-loaded = ycl_date=&amp;gt;timestamp( ).
MODIFY lt_part FROM ls_part TRANSPORTING loaded WHERE loaded IS INITIAL.

" We need to retain the old HASH value
LOOP AT lt_part ASSIGNING FIELD-SYMBOL(&amp;lt;ls_part&amp;gt;).
  SELECT SINGLE hash FROM y00_hyb_parts INTO CORRESPONDING FIELDS OF &amp;lt;ls_part&amp;gt; WHERE matnr = ls_part-matnr.
ENDLOOP.

" Cache the result
MODIFY y00_hyb_parts FROM TABLE lt_part transporting.
COMMIT WORK AND WAIT.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/132500-s.png" /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Apr 2018 08:10:01 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2018-04-30T08:10:01Z</dc:date>
    <item>
      <title>modify dbtab from table transporting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618775#M25754</link>
      <description>&lt;P&gt;There seems to be no way to MODIFY a DB table from an internal table TRANSPORTING only certain fields.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;It seems a pity to loop through the internal table and do thousands of MODIFY commands. Or, as show below, loop through the itab and load from the DB the data (e.g. field "hash") we want to retain.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;Is there a more elegant solution?&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;" Load parts from external system
DATA(lt_part) = ycl_hybris_api=&amp;gt;part_list(
  attributes = 'galleryImages,code,creationtime,modifiedtime'
  sort       = 'code'
).
CHECK lt_part IS NOT INITIAL.

" Set all timestamps to now
DATA ls_part TYPE y00_hyb_parts.
ls_part-loaded = ycl_date=&amp;gt;timestamp( ).
MODIFY lt_part FROM ls_part TRANSPORTING loaded WHERE loaded IS INITIAL.

" We need to retain the old HASH value
LOOP AT lt_part ASSIGNING FIELD-SYMBOL(&amp;lt;ls_part&amp;gt;).
  SELECT SINGLE hash FROM y00_hyb_parts INTO CORRESPONDING FIELDS OF &amp;lt;ls_part&amp;gt; WHERE matnr = ls_part-matnr.
ENDLOOP.

" Cache the result
MODIFY y00_hyb_parts FROM TABLE lt_part transporting.
COMMIT WORK AND WAIT.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/132500-s.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 08:10:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618775#M25754</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-04-30T08:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: modify dbtab from table transporting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618776#M25755</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;UPDATE y00_hyb_parts SET loaded = whatever WHERE ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Apr 2018 08:33:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618776#M25755</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2018-04-30T08:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: modify dbtab from table transporting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618777#M25756</link>
      <description>&lt;P&gt;The real question is how I update the DB Table from the internal table lt_part. There are various fields there that need to be updated FROM the external system.&lt;/P&gt;
  &lt;P&gt;The field loaded should only be set in the DB for those parts in lt_part which were currently loaded.&lt;/P&gt;
  &lt;P&gt;The field hash should not be changed in the DB table at all.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 09:05:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618777#M25756</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-04-30T09:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: modify dbtab from table transporting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618778#M25757</link>
      <description>&lt;P&gt;Since MODIFY can work as INSERT, it makes no sense to transport only part of the fields &lt;/P&gt;
  &lt;P&gt;Mike's answer is correct.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 09:37:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618778#M25757</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2018-04-30T09:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: modify dbtab from table transporting</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618779#M25758</link>
      <description>&lt;P&gt;The only way I know is to pull the existing data into an itab, update the needed info and then do an update. You could probably do something really fancy with UPDATE ... FROM TABLE VALUE #( ... )..., but at it's simplest: &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;SELECT * FROM y00_hyb_parts INTO TABLE @data(staging_table) WHERE ... .
   ... "merge updates onto staging_table
UPDATE y00_hyb_parts FROM TABLE staging_table.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 10:20:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-dbtab-from-table-transporting/m-p/618779#M25758</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2018-04-30T10:20:45Z</dc:date>
    </item>
  </channel>
</rss>

