Skip to Content
0
Former Member
Jun 17, 2016 at 12:34 AM

Problem with BAPI_ALM_ORDER_MAINTAIN (change components)

2197 Views

Hi Guru's,


Scenario:

Change the storage location of a particular production order component. The components are given by the upload file.


I am trying to change components using bapi BAPI_ALM_ORDER_MAINTAIN but i end up with error msg: IWO_BAPI2 108 Order is changed, but not created




I check all the relevant forums and found no solution to this error.



Could you please help me.


Below is the code:

ls_objects-components = abap_true.

LOOP AT gt_upload INTO ls_upload.

lv_number = ls_upload-number.

CALL FUNCTION 'BAPI_PRODORD_GET_DETAIL'

EXPORTING

number = lv_number

order_objects = ls_objects

IMPORTING

return = ls_return

TABLES

component = lt_comp.

LOOP AT lt_comp INTO ls_comp WHERE material = ls_upload-matnr

AND operation = ls_upload-vornr.

ls_order_component-reserv_no = ls_comp-reservation_number.

ls_order_component-res_item = ls_comp-reservation_item.

ls_order_component-material = ls_comp-material.

ls_order_component-stge_loc = ls_upload-lgort.

ls_order_component-activity = ls_comp-operation.

APPEND ls_order_component TO lt_order_component.

ls_order_component_up-stge_loc = abap_true.

ls_order_component_up-material = abap_true.

ls_order_component_up-activity = abap_true.

APPEND ls_order_component_up TO lt_order_component_up.

CLEAR: ls_order_component, ls_order_component_up.

ENDLOOP.

CLEAR: ls_order_method.

ls_order_method-refnumber = '000001'.

ls_order_method-objecttype = 'COMPONENT'.

ls_order_method-method = 'CHANGE'.

CONCATENATE '%' lv_number ls_upload-vornr into

ls_order_method-objectkey

in CHARACTER MODE.

APPEND ls_order_method TO lt_order_method.

CLEAR: ls_order_method.

ls_order_method-refnumber = '000001'.

ls_order_method-objecttype = space.

ls_order_method-method = 'SAVE'.

CONCATENATE '%' lv_number ls_upload-vornr into

ls_order_method-objectkey

in CHARACTER MODE.

APPEND ls_order_method TO lt_order_method.

CLEAR ls_numbers.

ls_numbers-aufnr_in = lv_number.

APPEND ls_numbers TO lt_numbers.

CLEAR ls_order_header.

ls_order_header-ORDERID = lv_number.

APPEND ls_order_header to lt_order_header.

CLEAR ls_order_header_up.

ls_order_header_up-ORDERID = lv_number.

APPEND ls_order_header_up to lt_order_header_up.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

TABLES

it_methods = lt_order_method

IT_HEADER = lt_order_header

IT_HEADER_UP = lt_order_header_up

it_component = lt_order_component

it_component_up = lt_order_component_up

return = lt_return

et_numbers = lt_numbers.

READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.

IF sy-subrc NE 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'

LOOP at lt_return INTO ls_return WHERE type = 'E'.

ls_alv-aufnr = lv_number.

ls_alv-matnr = ls_upload-matnr.

ls_alv-type = ls_return-type.

ls_alv-msg = ls_return-message.

APPEND ls_alv TO lt_alv.

ENDLOOP.

ENDIF.

ENDLOOP.


Thanks,

Sri.