<?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: Roll back on Custom table Update in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333096#M1638381</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was checki ng if there is a better way of doing it and also making sure that it is good.&lt;/P&gt;&lt;P&gt;So far no issues and will also look at your suggestion. Appreciate your feedback.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Nov 2011 19:18:37 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-11-29T19:18:37Z</dc:date>
    <item>
      <title>Roll back on Custom table Update</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333090#M1638375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please suggest if the below update and Rollback on the custom table is accurate. We ran into some issues with missing data &lt;/P&gt;&lt;P&gt;when the earier codewas deleting all the sales orders in custom table and then updating sales order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Background of the program:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a custom report in which i capture changes done to a sales order based on standard change log tables CDHDR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Changes can be of 2 types:&lt;/P&gt;&lt;P&gt;1) Change to the existing Sales order item&lt;/P&gt;&lt;P&gt;2) Creation of new line items within a sales order&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Program flow&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Capture the Sales Orders changes in an internal table  and from step 2 process one sales order at a time.&lt;/P&gt;&lt;P&gt;2) Delete a Sales order from custom table for which new changes are found &lt;/P&gt;&lt;P&gt;3) Check the Lock on this Sales Order. (This has 3 scenarios)&lt;/P&gt;&lt;P&gt;    a)If no Lock exists on the sales order, then update the buffer table. Result: Buffer table is updated successfully.&lt;/P&gt;&lt;P&gt;    b)If no Lock exists on the sales order, then update the buffer table. Result: If for some reason the update fails,&lt;/P&gt;&lt;P&gt;        Rollback  the Deletion. &lt;/P&gt;&lt;P&gt;    c)If Lock exists on the sales order, then Roll back the deletion. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CHECK  s_vbeln[] IS NOT INITIAL.   " All the Sales orders are captured in S_VBELN.

  LOOP AT s_vbeln.

    LOOP AT pt_input ASSIGNING &amp;lt;lfs_input&amp;gt; WHERE vbeln = s_vbeln-low.

      AT END OF vbeln.

        DELETE FROM z_data_buffer WHERE vbeln = s_vbeln-low.

*************************This Section of Code gathers all the data for the sales order ito internal table [lt_log] *********
*************************The custom table z_data_buffer is updated from this internal table [lt_log]**********************

         READ TABLE lt_log_details INTO lx_log_details
               WITH KEY vbeln = &amp;lt;lfs_input&amp;gt;-vbeln TRANSPORTING NO FIELDS.
        IF sy-subrc = 0.
            LOOP AT lt_log_details INTO lx_log_details
                                FROM sy-tabix.
            IF lx_log_details-vbeln = &amp;lt;lfs_input&amp;gt;-vbeln.
              APPEND lx_log_details TO lt_log.
            ELSE.
              EXIT.
            ENDIF.
          ENDLOOP.
*********************************************************************************************************************************************


*** Locks the Sales order in custom table z_data_buffer
        CALL FUNCTION 'ENQUEUE_EZ_VBELN3'
          EXPORTING
            mode_z_data_buffer = 'E'
            mandt                 = sy-mandt
            vbeln                 = &amp;lt;lfs_input&amp;gt;-vbeln
          EXCEPTIONS
            foreign_lock          = 1
            system_failure        = 2
            OTHERS                = 3.

        IF sy-subrc &amp;lt;&amp;gt; 0.
*--Roll back the Deletion Done.
             ROLLBACK WORK.
         ELSE.
                 MODIFY z_data_buffer FROM TABLE lt_backlog.      
                    IF sy-subrc &amp;lt;&amp;gt;  0.
                         ROLLBACK WORK.
                    ENDIF.
        ENDIF.

        CALL FUNCTION 'DEQUEUE_EZ_VBELN3'
          EXPORTING
            mode_ztps_data_buffer = 'E'
            mandt                 = sy-mandt
            vbeln                 = &amp;lt;lfs_input&amp;gt;-vbeln.

        REFRESH lt_log.
      ENDAT.
    ENDLOOP.

  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;lt;Added Code tags&amp;gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Suhas Saha on Nov 23, 2011 12:03 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 05:42:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333090#M1638375</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-23T05:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Roll back on Custom table Update</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333091#M1638376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CHECK s_vbeln[] IS NOT INITIAL.
DELETE pt_input WHERE vbeln NOT IN s_vbeln.
SORT pt_input BY vbeln.
LOOP AT pt_input ASSIGNING &amp;lt;lfs_input&amp;gt;.
  AT END OF vbeln.
    READ TABLE lt_log_details INTO lx_log_details
    WITH KEY vbeln = &amp;lt;lfs_input&amp;gt;-vbeln TRANSPORTING NO FIELDS.
    IF sy-subrc = 0.
      LOOP AT lt_log_details INTO lx_log_details FROM sy-tabix.
        IF lx_log_details-vbeln = &amp;lt;lfs_input&amp;gt;-vbeln.
          APPEND lx_log_details TO lt_log.
        ELSE.
          EXIT.
        ENDIF.
      ENDLOOP.
      "perform enqueue
      IF sy-subrc EQ 0.
        DELETE FROM z_data_buffer WHERE vbeln = &amp;lt;lfs_input&amp;gt;-vbeln.
        IF sy-subrc NE 0.
          ROLLBACK WORK.
         " perform dequeue
        ELSE.
          MODIFY z_data_buffer FROM TABLE lt_backlog.
          IF sy-subrc NE 0.
            ROLLBACK WORK.
             " perform dequeue
          ELSE.
            COMMIT WORK.
             " perform dequeue
          ENDIF.
        ENDIF.
       REFRESH lt_log.
      ENDIF.
    ENDIF.
  ENDAT.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 06:07:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333091#M1638376</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-11-23T06:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Roll back on Custom table Update</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333092#M1638377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;CODE&gt;LOOP AT s_vbeln.
  LOOP AT pt_input ASSIGNING &amp;lt;lfs_input&amp;gt; WHERE vbeln = s_vbeln-low. 
    AT END OF vbeln.&lt;/CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;In addition to Keshav's points, LOOP AT ...WHERE./AT END OF is problematic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 15:11:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333092#M1638377</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-23T15:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Roll back on Custom table Update</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333093#M1638378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its currently working fine with the current code and didn't see any issues so far.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2011 19:01:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333093#M1638378</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-29T19:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Roll back on Custom table Update</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333094#M1638379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I said it's problematic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may work for a while and then stop working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2011 19:03:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333094#M1638379</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-29T19:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Roll back on Custom table Update</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333095#M1638380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And I thought you were asking the question because the code is &lt;U&gt;not&lt;/U&gt; working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2011 19:05:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333095#M1638380</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-29T19:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Roll back on Custom table Update</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333096#M1638381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was checki ng if there is a better way of doing it and also making sure that it is good.&lt;/P&gt;&lt;P&gt;So far no issues and will also look at your suggestion. Appreciate your feedback.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2011 19:18:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333096#M1638381</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-29T19:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Roll back on Custom table Update</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333097#M1638382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the extended syntax check message for "using control breaks in a loop with where". Also there is no need of a control break in your code as you are only using vbeln in your code. Just delete the adjacent duplicates and loop it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kesav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 05:21:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/roll-back-on-custom-table-update/m-p/8333097#M1638382</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-11-30T05:21:52Z</dc:date>
    </item>
  </channel>
</rss>

