2013 May 02 6:58 PM
I have seen similar posts for this topic but none of them provide a resolution.
I am using BAPI_ALM_ORDER_MAINTAIN to update existing service orders with a related
PO number. I need to update the field Unloading Point with the relevant PO number.I am able to update the first component but not any subsequent ones.
Here is the code...
"Prior to this I used BAPI_ALM_ORDER_GET_DETAIL to retrieve the relevant data for the service order.
loop at at_socomponents assigning <component> .
clear wa_methods.
clear wa_component.
clear wa_component_up.
"do not include deleted components from the service order.
check <component>-delete_ind <> c_delete_ind.
wa_methods-refnumber = c_refnumber.
wa_methods-objecttype = 'COMPONENT'.
wa_methods-method = 'CHANGE'.
wa_methods-objectkey(12) = a_aufnr.
wa_methods-objectkey+12(4) = <component>-activity.
wa_methods-objectkey+16(4) = <component>-item_number .
append wa_methods to it_methods.
wa_component-reserv_no = <component>-reserv_no.
wa_component-res_item = <component>-res_item.
wa_component-res_type = <component>-res_type.
wa_component-item_number = <component>-item_number.
wa_component-activity = <component>-activity.
wa_component-unload_pt = a_po_number.
wa_component_up-activity = c_update.
wa_component_up-unload_pt = c_update.
append wa_component to it_component.
append wa_component_up to it_component_up.
endloop.
clear wa_methods.
wa_methods-refnumber = c_refnumber.
wa_methods-method = 'SAVE'.
append wa_methods to it_methods.
Then I call the BAPI.
The BAPI return table verifies that the execution completed successfully. However, only the first component is updated, when I am trying to update all of them in the relevant service order.
I have searched for this solution at length, without success.
Any assistance is appreciated.
Thank you,
Justin
2013 May 06 7:00 PM
I have finally figured this out.
In order to update (change) multiple lines I had to use the sy-tabix value for the refnumber for each of the lines.
See code below.
LOOP AT at_socomponents ASSIGNING <component> .
CLEAR wa_methods.
CLEAR wa_component.
CLEAR wa_component_up.
"do not include deleted components from the service order.
CHECK <component>-delete_ind <> c_delete_ind.
wa_methods-refnumber = sy-tabix.
wa_methods-objecttype = c_obj_typ.
wa_methods-method = c_meth_chng.
wa_methods-objectkey(12) = a_aufnr.
wa_methods-objectkey+12(4) = <component>-res_item .
APPEND wa_methods TO it_methods.
wa_component-reserv_no = <component>-reserv_no.
wa_component-res_item = <component>-res_item.
wa_component-res_type = <component>-res_type.
wa_component-material = <component>-material.
wa_component-item_cat = <component>-item_cat.
wa_component-item_number = <component>-item_number.
wa_component-activity = <component>-activity.
wa_component-unload_pt = a_po_number.
wa_component_up-material = c_update.
wa_component_up-item_cat = c_update.
wa_component_up-item_number = c_update.
wa_component_up-activity = c_update.
wa_component_up-unload_pt = c_update.
APPEND wa_component TO it_component.
APPEND wa_component_up TO it_component_up.
ENDLOOP.
CLEAR wa_methods.
"wa_methods-refnumber = c_refnumber.
wa_methods-method = c_meth_save.
APPEND wa_methods TO it_methods.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = it_methods
.....
.....
.....
This was a real head scratcher for me. This was not readily apparent in the documentation or in any post I was able to find.
Hope this will help someone else.
Justin
2013 May 06 7:00 PM
I have finally figured this out.
In order to update (change) multiple lines I had to use the sy-tabix value for the refnumber for each of the lines.
See code below.
LOOP AT at_socomponents ASSIGNING <component> .
CLEAR wa_methods.
CLEAR wa_component.
CLEAR wa_component_up.
"do not include deleted components from the service order.
CHECK <component>-delete_ind <> c_delete_ind.
wa_methods-refnumber = sy-tabix.
wa_methods-objecttype = c_obj_typ.
wa_methods-method = c_meth_chng.
wa_methods-objectkey(12) = a_aufnr.
wa_methods-objectkey+12(4) = <component>-res_item .
APPEND wa_methods TO it_methods.
wa_component-reserv_no = <component>-reserv_no.
wa_component-res_item = <component>-res_item.
wa_component-res_type = <component>-res_type.
wa_component-material = <component>-material.
wa_component-item_cat = <component>-item_cat.
wa_component-item_number = <component>-item_number.
wa_component-activity = <component>-activity.
wa_component-unload_pt = a_po_number.
wa_component_up-material = c_update.
wa_component_up-item_cat = c_update.
wa_component_up-item_number = c_update.
wa_component_up-activity = c_update.
wa_component_up-unload_pt = c_update.
APPEND wa_component TO it_component.
APPEND wa_component_up TO it_component_up.
ENDLOOP.
CLEAR wa_methods.
"wa_methods-refnumber = c_refnumber.
wa_methods-method = c_meth_save.
APPEND wa_methods TO it_methods.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = it_methods
.....
.....
.....
This was a real head scratcher for me. This was not readily apparent in the documentation or in any post I was able to find.
Hope this will help someone else.
Justin
2015 Jul 31 6:05 PM
Thank youFormer Member for sharing your solution.
I had the same problem and it was very useful for me.
Diego Santin.
2023 Dec 19 6:26 AM