Skip to Content

BAPI_ALM_ORDER_MAINTAIN IT_SRULE ending with errors

Hello everyone

I am trying to update the Production order settlement rules using 'BAPI_ALM_ORDER_MAINTAIN'.

I need to change the quantity of the settlement rule but the BAPI always returns errors.

IWO_BAPI 402 Error when reading the settlement rule using the external number
IWO_BAPI2 113 Error during processing of BAPI methods

Here is a sample code use to test the BAPI.

  DATA: lt_srule    TYPE TABLE OF bapi_alm_order_srule,
        ls_srules   LIKE LINE OF lt_srule,
        lt_srule_up TYPE TABLE OF bapi_alm_order_srule_up,
        ls_srule_up LIKE LINE OF lt_srule_up,
        lt_methods  TYPE TABLE OF bapi_alm_order_method,
        ls_methods  LIKE LINE OF lt_methods,
        lt_return   TYPE STANDARD TABLE OF bapiret2,
        ls_return   TYPE bapiret2,
        ls_cobrb    TYPE cobrb.

  DATA: lv_aufnr  TYPE aufnr VALUE '000000501576'.

  SELECT * INTO ls_cobrb FROM cobrb
                        WHERE aufnr = lv_aufnr
                          AND lfdnr = '001'.    
    CLEAR ls_srules.
    ls_srules-objnr          = ls_cobrb-objnr.
    ls_srules-lfdnr          = ls_cobrb-lfdnr.
    ls_srules-equiv_number  = 0.     
    ls_srules-orderid        = ls_cobrb-aufnr.
    APPEND ls_srules TO lt_srule.

    ls_srule_up-equiv_number = 'X'.
    APPEND ls_srule_up TO lt_srule_up.
  ENDSELECT.

  CLEAR ls_methods.
  ls_methods-refnumber  = 1.
  ls_methods-objecttype = 'SRULE'.
  ls_methods-method     = 'CHANGE'.
  ls_methods-objectkey  = lv_aufnr.
  APPEND ls_methods TO lt_methods.

  CLEAR ls_methods.
  ls_methods-refnumber  = 1.
  ls_methods-objecttype = space.
  ls_methods-method     = 'SAVE'.
  ls_methods-objectkey  = lv_aufnr.
  APPEND ls_methods TO lt_methods.

  CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
    TABLES
      it_methods  = lt_methods
      it_srule    = lt_srule
      it_srule_up = lt_srule_up
      return      = lt_return
    .

  READ TABLE lt_return INTO ls_return WITH KEY type = 'A'.
  CHECK sy-subrc <> 0.
  READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
  CHECK sy-subrc <> 0.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'
    .
Add comment
10|10000 characters needed characters exceeded

  • Former Member

    Hi Danie

    Were you able to find the cause and solution for your problem.

    Can you please share your findings here.

    Thanks
    Navin

  • Get RSS Feed

3 Answers

  • Best Answer
    May 02 at 01:52 PM

    Until SAP will provide an OSS note to correct the issue, we have taken a direct action and updating the table.

    We are not recommending this solution but we had no choice at the moment.

    * uv_order_number type aufnr
     UPDATE COBRB SET AQZIF = 0 WHERE aufnr = uv_order_number                                                                                      AND lfdnr = '001'.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 15, 2017 at 08:00 PM

    I just saw you posted this already here ...

    And you already saw the Error was raised in "IBAPI_ALM_ORDERSRULE_CHANGE" ....

    I have little experience on the Order Settlement in combination with this BAPI, but you might want to check :

    • Are there Active BAdI's / Exits that are used to Influence the same Object => UserExit "EXIT_SAPLCOI1_027" ("ZXWOCU14") ...
    • When Adding a Step in the Methods 'DIALOG', does that help? (Based on SAP-KBA 1496760 and 1494862 : link / link)


    If you can't get it to work, you might want to look into some older SAP-KBA's on Correction-Reports for Settlement Rules, to see how CRUD-operations are executed there ...

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 16, 2017 at 10:20 PM

    Hello Nic

    Thank you for your answer. I effectively posted twice by mistake and I don't know how to delete a post.

    At the same time, I have been told to not directly use the function IBAPI_ALM_ORDERSRULE_CHANGE. I should used the function BAPI_ALM_ORDER_MAINTENANCE. Where this post has been created.

    But when using this function, the return table contains the following error records:

    IWO_BAPI 402 Error when reading the settlement rule using the external number
    IWO_BAPI2 113 Error during processing of BAPI methods

    I am still at the same point. I cannot update the settlement value and I don't understand the error.

    I can change the value directly from the tcode CO02 but not from the BAPI.

    As you proposed, I added a step with the method dialog. It end with the same errors in the return table.

    The user exit you have proposed is not active.

    Both SAP notes are related to components EA-APPL where the component doesn't seems to be in the component list provided in SPAM. We are under S4/HANA.

    All suggestions will be highly appreciated.


    Regards

    Daniel

    Add comment
    10|10000 characters needed characters exceeded

    • I'm sorry to say I have no Experience with you case, and I could only find some old(er) SAP-KBA's mentioning something that 'might' have to do with the External Number and the Characteristic value ...

      • SAP-KBA 2447493 : link ("BAPI BAPI_ALM_ORDER_MAINTAIN does not provide an option for PSG as settlement receiver. You may have to use customer code program to meet your requirement")
      • SAP-KBA 1270258 : link
      • SAP-KBA 1660309 : link (... mentioning UExit "EXIT_SAPLCOI1_027")
      • SAP-KBA 579461 : link
      • SAP-KBA 733135 : link
      • SAP-KBA 853144 : link
      • SAP-KBA 480280 : link (Updated 2016)
      • SAP-KBA 1709315 : link (... mentioning the use of FM "COPA_PROFITABILITY_SEGMENT" before Execution of Update BAPI's)


      (Only some of those KBA's actually refer to HANA-Systems)

      To be honest, I get the feeling that you're not going to be able to make the required changes without resorting to Additional Development (UserExit or BAdI "WORKORDER_UPDATE" or something)? If your issue persists, you could always raise your Question to SAP Support, hoping for a clear Explanation what Can and Can Not be done via this or other BAPI ...


      I'm interested in what you or SAP Support come up with.

      Nic T.