11-15-2017 4:00 PM
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'
.
05-02-2018 2: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'.
11-15-2017 8: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 :
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 ...
11-16-2017 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
11-17-2017 12:46 AM
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 ...
(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.
03-27-2018 12:23 PM
Hi Danie
Were you able to find the cause and solution for your problem.
Can you please share your findings here.
Thanks
Navin
05-02-2018 2: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'.