Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with BAPI_ALM_ORDER_MAINTAIN (change components)

Former Member
0 Kudos

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.

2 REPLIES 2

Ashg1402
Contributor
0 Kudos

Hi,

This BAPI_ALM_ORDER_MAINTAIN is used for maintenance order and service order, and you are saying that you want to make a change in production order. 

I don't think that it will work. I can be wrong but as far as I know this can be the reason for your error.

Can you have a look again regarding working of this BAPI.

Regards

Ashish

ajay_mukundan2
Explorer
0 Kudos

If your order type is 10, BAPI_ALM_ORDER_MAINTAIN cannot be used to update production orders.

Suggest you to

A) Use BDC recording on CO02 and submit via report. OR


B) Use FM CO_SE_PRODORD_CHANGE that is released by the customer to change the order header, sequences, operations, and production resource/tool of production orders. See the detailed documentation for the function module. Check OSS NOTE 1694267