cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem with BAPI_ALM_ORDER_MAINTAIN

Former Member
0 Kudos
1,463

Hi,

I need to change the Functional location in an order according to the corresponding updation of the equipment's functional location.

I am using BAPI_ALM_ORDER_MAINTAIN to do this but it is not working. It works some time and doesnt work sometimes.

I have used commit work and Buffer_refresh_all to clear the buffers before the BAPI . But still the order is not getting updated.

Following is my code snippet.


****Update the equipment 

    CALL FUNCTION 'BAPI_EQUI_INSTALL'
      EXPORTING
        equipment    = gs_relocate_mem-equnr
        data_install = ls_install
      IMPORTING
        return       = gs_return3.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait   = gc_x


****Update the order

    ls_methods-objecttype = gc_header .
    ls_methods-method = gc_change .
    ls_methods-objectkey = gs_relocate_mem-aufnr.
    APPEND ls_methods TO lt_methods.
    CLEAR ls_methods.
    ls_methods-refnumber = 1.
    ls_methods-objecttype = ''.
    ls_methods-method = gc_save.
    ls_methods-objectkey = ''.
    APPEND ls_methods TO lt_methods.
    CLEAR ls_methods.
    ls_header1-orderid = gs_relocate_mem-aufnr.
    ls_header1-order_type = gc_zpt2.
    ls_header1-funct_loc = lv_tplnr.
    ls_header1-equipment =gs_relocate_mem-equnr
    APPEND ls_header1 TO lt_header1.
    CLEAR ls_header1.
    ls_header_update1-orderid = gs_relocate_mem-aufnr.
    ls_header_update1-funct_loc = gc_x.
    ls_header_update1-equipment = gc_x.
    APPEND ls_header_update1 TO lt_header_update1.
    CLEAR ls_header_update1.
    CALL FUNCTION 'BUFFER_REFRESH_ALL'.
    CALL FUNCTION 'CO_ZF_DATA_RESET_COMPLETE'
      EXPORTING
        i_no_ocm_reset = ' '
        i_status_reset = 'X'.
    REFRESH gt_return4.
    CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
      TABLES
        it_methods   = lt_methods
        it_header    = lt_header1
        it_header_up = lt_header_update1
        return       = gt_return4.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait   = gc_x

Edited by: Deepti Vohra on Jan 5, 2011 9:25 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

There is no problem with your code. I've used before and tested again in order to be sure.

As you said, sometimes it's working and sometimes not. As you didn't explained, we have two possible scenarios for this:

1 - Sometimes work and sometimes not with the same Order:

It's probably because a lock or delay while updating the equipment (not sure why, but sometimes the wait in bapi_transaction_commit does not work as expected). Anyway, test the scenario inserting a manual wait after the commit and execute the code several times to be sure. If the problem disappear, you will have to look for the lock delay.

2 - Always work with one type of order but not with other type, or a specific order does not work:

Try to do this change manually on IW32 with this order or check the log. (Probably you already did this).

The code CALL FUNCTION 'BUFFER_REFRESH_ALL' is unnecessary, since it's called inside the BAPI_TRANSACTION_COMMIT.

Best Regards,

Diego Viotto.

Former Member
0 Kudos

Hi.. Thank you for your replies.

@ Diego - I checked running the BAPI test run (gave commit in test sequence). Even then it was not working.

There were few user exits written in the BAPI. Not sure whether they are the cause for the issue. Is there any other way of updating the order ? other than BDC ..

former_member778253
Active Participant
0 Kudos

Hi

Once check the BAPI documentation... and also check whether you are passing all the required data to the BAPI function module or not...