<?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: issue with BAPI_PS_PRECOMMIT in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791393#M2024344</link>
    <description>&lt;P&gt;Please mark the best answer, I guess it should be yours.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Nov 2023 20:17:26 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2023-11-03T20:17:26Z</dc:date>
    <item>
      <title>issue with BAPI_PS_PRECOMMIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791386#M2024337</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;I'm calling BAPI_PS_PRECOMMIT after updating the profit center field of a project. It's done within the BADI PROJECTDEF_UPDATE (method AT_SAVE).&lt;/P&gt;
  &lt;P&gt;For some reason, when I call the PRECOMMIT BAPI it goes back to the beginning of the method and gets into an endless loop..&lt;/P&gt;
  &lt;P&gt;Any idea how it can be resolved?&lt;/P&gt;
  &lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 06:33:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791386#M2024337</guid>
      <dc:creator>shmilo66661</dc:creator>
      <dc:date>2023-10-31T06:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: issue with BAPI_PS_PRECOMMIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791387#M2024338</link>
      <description>&lt;P&gt;Hello Shmilovitz,&lt;/P&gt;&lt;P&gt;Without more information about your specific implementation and the code you're using, it's difficult to provide a precise solution. However, here are a few general suggestions to help you troubleshoot the issue:&lt;/P&gt;&lt;P&gt;1. Check the logic within the PROJECTDEF_UPDATE BAdI: Review the code within the AT_SAVE method of the BAdI implementation and ensure there are no recursive calls or loops that might be causing the endless loop.&lt;/P&gt;&lt;P&gt;2. Verify the parameters passed to BAPI_PS_PRECOMMIT: Double-check the parameters you are passing to the BAPI_PS_PRECOMMIT function module. Ensure that you are providing the correct input values and that the function module is being called with the appropriate parameters.&lt;/P&gt;&lt;P&gt;3. Debug the code: Use a debugger to step through the code and identify the point at which the endless loop occurs. This will help you pinpoint the exact cause of the issue and find a solution.&lt;/P&gt;&lt;P&gt;4. Review the BAPI_PS_PRECOMMIT function module: Examine the code within the BAPI_PS_PRECOMMIT function module and check if there are any potential recursive calls or loops that could lead to an endless loop. &lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 07:02:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791387#M2024338</guid>
      <dc:creator>JoeyLi</dc:creator>
      <dc:date>2023-10-31T07:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: issue with BAPI_PS_PRECOMMIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791388#M2024339</link>
      <description>&lt;P&gt;Basically you are breaking the current transction logic when calling this FM (as a COMMIT WORK) during this BAdI AT-SAVE execution?&lt;/P&gt;&lt;P&gt;Why do you call this FM in the BAdI, did you call some BAPI before?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 09:06:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791388#M2024339</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2023-10-31T09:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: issue with BAPI_PS_PRECOMMIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791389#M2024340</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;There's no other code implemented in this BADI, only my code. Also there's no parameters passed to the PRE_COMMIT BAPI but the return table.&lt;/P&gt;&lt;P&gt;Here is the entire code I'm using. The intention is to update profit center value within a project and its related WBS's: &lt;/P&gt;&lt;P&gt;  method IF_EX_PROJECTDEF_UPDATE~AT_SAVE.&lt;BR /&gt;*--&amp;gt; Local data - start&lt;BR /&gt;    DATA: lv_prctr        type PRCTR,&lt;BR /&gt;          ls_proj_def     TYPE bapi_bus2001_chg,&lt;BR /&gt;          ls_bapi_updt    TYPE bapi_bus2001_upd,&lt;BR /&gt;          lt_bapi_return  TYPE bapirettab,&lt;BR /&gt;          ls_return       TYPE BAPIRET2,&lt;BR /&gt;          lt_return       like TABLE OF ls_return,&lt;BR /&gt;          ls_bapi_return  like line OF lt_bapi_return.&lt;BR /&gt;    DATA: BEGIN OF lwa_posid,&lt;BR /&gt;            POSID TYPE PS_POSID,&lt;BR /&gt;          END   OF lwa_posid,&lt;BR /&gt;          lt_posid like TABLE OF lwa_POSID.&lt;BR /&gt;    DATA: lt_wbs      TYPE bapi_bus2054_chg_tab,&lt;BR /&gt;          lwa_wbs     like LINE OF lt_wbs,&lt;BR /&gt;          lt_wbs_upd  TYPE bapi_bus2054_upd_tab,&lt;BR /&gt;          lwa_wbs_upd like LINE OF lt_wbs_upd,&lt;BR /&gt;          lt_ret_wbs  TYPE bapirettab,&lt;BR /&gt;          ls_ret_wbs  like LINE OF lt_ret_wbs.&lt;BR /&gt;*--&amp;gt; Local data - end&lt;BR /&gt;    &lt;BR /&gt;*--&amp;gt; Get profict center from PCA Substitution&lt;BR /&gt;    select SINGLE prctr&lt;BR /&gt;      FROM ZCOT_PCA_SUBS&lt;BR /&gt;      into lv_prctr&lt;BR /&gt;      WHERE vtweg = IM_PROJECTDEFINITION-vtweg AND&lt;BR /&gt;            vkbur = IM_PROJECTDEFINITION-zz_vkbur.&lt;BR /&gt;    if sy-subrc eq 0 AND lv_prctr IS NOT INITIAL.&lt;BR /&gt;*--&amp;gt; Update profit center in table PROJ&lt;BR /&gt;      clear: ls_proj_def, ls_bapi_updt, lt_bapi_return[].&lt;BR /&gt;      MOVE-CORRESPONDING IM_PROJECTDEFINITION to ls_proj_def.&lt;BR /&gt;      ls_proj_def-PROJECT_DEFINITION   = IM_PROJECTDEFINITION-pspid.&lt;BR /&gt;      ls_proj_def-PROFIT_CTR           = lv_prctr.&lt;BR /&gt;      ls_bapi_updt-PROFIT_CTR          = 'X'.&lt;BR /&gt;      CALL FUNCTION 'BAPI_PS_INITIALIZATION'.&lt;BR /&gt;      CALL FUNCTION 'BAPI_BUS2001_CHANGE'&lt;BR /&gt;        EXPORTING&lt;BR /&gt;          I_PROJECT_DEFINITION           = ls_proj_def&lt;BR /&gt;          I_PROJECT_DEFINITION_UPD       = ls_bapi_updt&lt;BR /&gt;        TABLES&lt;BR /&gt;          ET_RETURN                      = lt_bapi_return.&lt;BR /&gt;      if sy-subrc eq 0.&lt;BR /&gt;        READ TABLE lt_bapi_return INTO ls_bapi_return with KEY type = 'E'.&lt;BR /&gt;        if sy-subrc ne 0.&lt;BR /&gt;          refresh lt_bapi_return.&lt;BR /&gt;*--&amp;gt; Find all WBS relevant to project&lt;BR /&gt;          CLEAR lt_wbs[].&lt;BR /&gt;          SELECT posid FROM prps INTO CORRESPONDING FIELDS OF TABLE lt_posid WHERE PSPHI = IM_PROJECTDEFINITION-PSPNR.&lt;BR /&gt;*--&amp;gt; Update profit center in all WBS table PRPS&lt;BR /&gt;          CLEAR: lt_wbs[], lt_wbs_upd[], lt_ret_wbs[].&lt;BR /&gt;          LOOP AT lt_posid INTO lwa_posid.&lt;BR /&gt;            lwa_wbs-WBS_ELEMENT     = lwa_posid-POSID.&lt;BR /&gt;            lwa_wbs-PROFIT_CTR      = lv_prctr.&lt;BR /&gt;            APPEND lwa_wbs to lt_wbs.&lt;BR /&gt;            lwa_wbs_upd-WBS_ELEMENT = lwa_posid-POSID.&lt;BR /&gt;            lwa_wbs_upd-PROFIT_CTR  = 'X'.&lt;BR /&gt;            APPEND lwa_wbs_upd to lt_wbs_upd.&lt;BR /&gt;          ENDLOOP.&lt;BR /&gt;          CALL FUNCTION 'BAPI_BUS2054_CHANGE_MULTI'&lt;BR /&gt;            EXPORTING&lt;BR /&gt;              I_PROJECT_DEFINITION        = IM_PROJECTDEFINITION-PSPID&lt;BR /&gt;            TABLES&lt;BR /&gt;              IT_WBS_ELEMENT              = lt_wbs&lt;BR /&gt;              IT_UPDATE_WBS_ELEMENT       = lt_wbs_upd&lt;BR /&gt;              ET_RETURN                   = lt_ret_wbs.&lt;BR /&gt;          if sy-subrc eq 0.&lt;BR /&gt;            READ TABLE lt_ret_wbs INTO ls_ret_wbs with KEY type = 'E'.&lt;BR /&gt;            if sy-subrc ne 0.&lt;BR /&gt;              CALL FUNCTION 'BAPI_PS_PRECOMMIT'&lt;BR /&gt;                TABLES&lt;BR /&gt;                  ET_RETURN       = lt_return.&lt;BR /&gt;              CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.&lt;BR /&gt;            ENDIF.&lt;BR /&gt;          ENDIF.&lt;BR /&gt;        ENDIF.&lt;BR /&gt;      ENDIF.&lt;BR /&gt;    ENDIF.&lt;BR /&gt;  endmethod.&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 05:13:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791389#M2024340</guid>
      <dc:creator>shmilo66661</dc:creator>
      <dc:date>2023-11-01T05:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: issue with BAPI_PS_PRECOMMIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791390#M2024341</link>
      <description>&lt;P&gt;Let me guess,&lt;/P&gt;&lt;P&gt;When you call `BAPI_PS_PRECOMMIT`, it triggers the save process again, which calls the `AT_SAVE` method of the BADI, thus creating an infinite loop.&lt;/P&gt;&lt;P&gt;You may set a break point and find the buffer details.&lt;/P&gt;&lt;P&gt;A common practice to avoid such a loop is to use a static flag to check whether the BADI has been called already. If it has been called, you can skip the BAPI_PS_PRECOMMIT call to avoid the recursive call.&lt;/P&gt;method IF_EX_PROJECTDEF_UPDATE~AT_SAVE.*Local definations..........*--&amp;gt; Static data (to control recursion)CLASS-DATA: lv_already_called TYPE abap_bool.*--&amp;gt; If this is a recursive call, exitIF lv_already_called EQ abap_true.  RETURN.ENDIF.".... (rest of your code) ....CALL FUNCTION 'BAPI_PS_PRECOMMIT'TABLESET_RETURN = lt_return.*--&amp;gt; Set the flag to true before commitlv_already_called = abap_true.CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'."Reset the flag after commitlv_already_called = abap_false.endmethod.</description>
      <pubDate>Wed, 01 Nov 2023 08:28:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791390#M2024341</guid>
      <dc:creator>JoeyLi</dc:creator>
      <dc:date>2023-11-01T08:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: issue with BAPI_PS_PRECOMMIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791391#M2024342</link>
      <description>&lt;P&gt;Thanks all!&lt;/P&gt;&lt;P&gt;It seems like I can't do the submit within the BADI's implementation therefore I put the entire code in an RFC FM and called it in a background task as a separate unit and it works..&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 18:09:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791391#M2024342</guid>
      <dc:creator>shmilo66661</dc:creator>
      <dc:date>2023-11-01T18:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: issue with BAPI_PS_PRECOMMIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791392#M2024343</link>
      <description>&lt;P&gt;Read the documentation of PROJECTDEF_UPDATE BAdI, method AT_SAVE&lt;/P&gt;&lt;P&gt;(...) Also note that the command 'commit work' cannot be carried out in the methods as this would lead to data inconsistencies in the database (...)&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 13:35:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791392#M2024343</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2023-11-03T13:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: issue with BAPI_PS_PRECOMMIT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791393#M2024344</link>
      <description>&lt;P&gt;Please mark the best answer, I guess it should be yours.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 20:17:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/issue-with-bapi-ps-precommit/m-p/12791393#M2024344</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-11-03T20:17:26Z</dc:date>
    </item>
  </channel>
</rss>

