<?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: batch insert - update tables (related by foreign keys) simultaneously in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888630#M1479701</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By LUW, I meant to create an update function module to implement the required logic. Once you go through the LUW topic, you will be familiar with how it can be implemented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you create any workbench object, it will ask for a transport order &amp;amp; you donu2019t have any issue in transporting the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Selva K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 May 2010 13:27:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-05-19T13:27:19Z</dc:date>
    <item>
      <title>batch insert - update tables (related by foreign keys) simultaneously</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888626#M1479697</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;I have two tables that are connected by a foreign key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using two batch transaction like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  PERFORM bdc_transaction USING 'SM30'
                          CHANGING p_subrc.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With this I first update one table and then i do a refresh to the &lt;STRONG&gt;bdcdata&lt;/STRONG&gt; restart the filling process of the &lt;STRONG&gt;bdcdata&lt;/STRONG&gt; and then perform a new transaction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue is that i want to prevent that if the second table is somehow being used by someone how do I assure that there is rollback and that no data is inserted in both the tables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Remember that the &lt;STRONG&gt;bdc_transaction&lt;/STRONG&gt; allways performs a commit work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there is a better way to do this than recorring to transactions please mention it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Luis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 11:23:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888626#M1479697</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-19T11:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: batch insert - update tables (related by foreign keys) simultaneously</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888627#M1479698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope, you want to update either u2018both the tableu2019 or nothing. Not like if the second table is updated, then only update the first one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, you can use the LUW u2013 Logical unit of work concept.&lt;/P&gt;&lt;P&gt;Hope, you are familiar with the Update function module. Create a new one &amp;amp; update the table directly using the ABAP SQL statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So that, you can update u2018both the tableu2019 or rollback if any issues.&lt;/P&gt;&lt;P&gt;Please let me know if any issue in implementing LUW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Selva K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 12:38:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888627#M1479698</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-19T12:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: batch insert - update tables (related by foreign keys) simultaneously</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888628#M1479699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes I want to update both tables or nothing that was what I meant to say tks &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok I think that will do the trick.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not familiar with the LUW concept but I'll do some research, if I have any troubles I'll tell you about it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I forgot to mention my first idea to solve the problem it was by recorring to block using queue and unqueue functions but there still was a minor chance for an error to occur, so I thought it wasn't a nice work arround...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tks allot for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cumpliments,&lt;/P&gt;&lt;P&gt;Luis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 13:01:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888628#M1479699</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-19T13:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: batch insert - update tables (related by foreign keys) simultaneously</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888629#M1479700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another thing I forgot to mention.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need the &lt;STRONG&gt;transport order&lt;/STRONG&gt; code because the tables must be manually transported from development to production prior to its aproval by a manager.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That was why I used the batch transaction, to associate the tables update to the same transport order, so this way I think it won't work with LUW... &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another hint for this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 13:14:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888629#M1479700</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-19T13:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: batch insert - update tables (related by foreign keys) simultaneously</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888630#M1479701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By LUW, I meant to create an update function module to implement the required logic. Once you go through the LUW topic, you will be familiar with how it can be implemented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you create any workbench object, it will ask for a transport order &amp;amp; you donu2019t have any issue in transporting the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Selva K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 13:27:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888630#M1479701</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-19T13:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: batch insert - update tables (related by foreign keys) simultaneously</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888631#M1479702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you use Batch Input then I cannot see anyway to rollback updates to the first table. As you say you get a commit work after the first batch input call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you mean "if the second table is somehow being used by someone"? You can control access to tables using the SAP lock mechanism. Using this you will be able to see if anyone is locking the first or second table before you start any updates.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 14:40:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888631#M1479702</guid>
      <dc:creator>che_eky</dc:creator>
      <dc:date>2010-05-19T14:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: batch insert - update tables (related by foreign keys) simultaneously</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888632#M1479703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is how i am processing this:&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;p /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;pre class="jive-pre"&amp;gt;&amp;lt;code class="jive-code jive-java"&amp;gt;* lock second table&lt;/P&gt;&lt;P&gt;  PERFORM lock_table USING     &amp;lt;font color="navy"&amp;gt;'E'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;                               &amp;lt;font color="navy"&amp;gt;'table2'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;                     CHANGING  ls_subrc.&lt;/P&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;P&gt;  PERFORM batch_insert_first_table USING    ...&lt;/P&gt;&lt;P&gt;                                     CHANGING ls_subrc.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;unlock second table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  PERFORM lock_table USING     &amp;lt;font color="navy"&amp;gt;'D'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;                               &amp;lt;font color="navy"&amp;gt;'table2'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;                     CHANGING  ls_subrc.&lt;/P&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;lock first table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  PERFORM lock_table USING     &amp;lt;font color="navy"&amp;gt;'E'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;                               &amp;lt;font color="navy"&amp;gt;'table1'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;                     CHANGING  ls_subrc.&lt;/P&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;BATCH ZHRGT_T705V&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  PERFORM batch_insert_second_table USING    ...&lt;/P&gt;&lt;P&gt;                                    CHANGING ls_subrc.&lt;/P&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;unlock first table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  PERFORM lock_table USING   &amp;lt;font color="navy"&amp;gt;'D'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;                             &amp;lt;font color="navy"&amp;gt;'Vtable1'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;                   CHANGING  ls_subrc.&lt;/P&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;now the lock table is like this:&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;pre class="jive-pre"&amp;gt;&amp;lt;code class="jive-code jive-java"&amp;gt;FORM lock_table  USING    p_action&lt;/P&gt;&lt;P&gt;                          p_table&lt;/P&gt;&lt;P&gt;                 CHANGING p_subrc.&lt;/P&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION &amp;lt;font color="navy"&amp;gt;'VIEW_ENQUEUE'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;P&gt;   action                     = p_action&lt;/P&gt;&lt;P&gt;   enqueue_mode               = &amp;lt;font color="navy"&amp;gt;'E'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;    view_name                 = p_table&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    ENQUEUE_RANGE              = &amp;lt;font color="navy"&amp;gt;' '&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  TABLES&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    SELLIST                    =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; EXCEPTIONS&lt;/P&gt;&lt;P&gt;   client_reference           = 1&lt;/P&gt;&lt;P&gt;   foreign_lock               = 2&lt;/P&gt;&lt;P&gt;   invalid_action             = 3&lt;/P&gt;&lt;P&gt;   invalid_enqueue_mode       = 4&lt;/P&gt;&lt;P&gt;   system_failure             = 5&lt;/P&gt;&lt;P&gt;   table_not_found            = 6&lt;/P&gt;&lt;P&gt;   OTHERS                     = 7.&lt;/P&gt;&lt;P&gt;  IF sy-subrc  0.&lt;/P&gt;&lt;P&gt;  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;P&gt;         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;P&gt;ENDFORM.                    &amp;lt;font color="red"&amp;gt;&amp;amp;quot; LOCK_TABLE&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;each of those * PERFORM batch* as this structure&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;br /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;pre class="jive-pre"&amp;gt;&amp;lt;code class="jive-code jive-java"&amp;gt;&lt;/P&gt;&lt;P&gt;PERFORM bdc_dynpro      USING arg arg.&lt;/P&gt;&lt;P&gt;PERFORM bdc_field       USING arg arg.&lt;/P&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;         ...&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;         ...&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;         ...&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;amp;nbsp;&lt;/P&gt;&lt;P&gt;PERFORM bdc_dynpro      USING arg arg.&lt;/P&gt;&lt;P&gt;PERFORM bdc_field       USING arg arg.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;PERFORM bdc_transaction USING &amp;lt;font color="navy"&amp;gt;'SM30'&amp;lt;/font&amp;gt;&lt;/P&gt;&lt;P&gt;                          CHANGING p_subrc.&lt;/P&gt;&lt;P&gt;&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the only problem that can happen, it is if someone locks the second table, while the first one is being updated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now the main porpuse of the batch it is because one of the table it's SAP standard, and i has been told to dont use direct SQL over them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the other as a said it was because I need to associate a transport order to the tables updates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I realize it is possible using LUW to do this, but as there is a standard table I can't use direct inserts  so I implemented it this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cumpliments and tks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: LuisMesquita on May 19, 2010 6:39 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 16:38:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/batch-insert-update-tables-related-by-foreign-keys-simultaneously/m-p/6888632#M1479703</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-19T16:38:20Z</dc:date>
    </item>
  </channel>
</rss>

