I'm writing a programm to correct the Equipment and functional Location data in a work order after Equipments where moved from on Fuloc to another.
Therefore I use BAPI_ALM_ORDER_MAINTAIN.
When I update the workorder I pass the new Equipment and new functional Location in the BAPI. However when I save and commit the old functional Location of the Equipment is saved in the work order (instead of the new functional Location which I passed). I fear it is because of the reference date of the order (which is in the past and cannot be updated).
EQUI1 moved from FuLoc AAA to FuLoc BBB at 01.09.2018.
When I update the Order 123456 (with reference date 01.01.2018) I pass Equipment EQUI1 and FuLoc BBB in the BAPI. However after saving and commit the Order has EQUI1 and FuLoc AAA (still the old one).
CLEAR: ls_methods. ls_methods-refnumber = '000001'. ls_methods-objecttype = 'HEADER'. ls_methods-method = 'CHANGE'. ls_methods-objectkey = iv_orderid. APPEND ls_methods TO lt_methods. " Save ls_methods-refnumber = '000001'. ls_methods-method = 'SAVE'. ls_methods-objecttype = ''. ls_methods-objectkey = iv_orderid.
APPEND ls_methods TO lt_methods. " Set Equi and Functional location ls_header-orderid = iv_orderid. ls_header-equipment = iv_equi. " EQUI1 ls_header-funct_loc = iv_tplnr. " BBB
APPEND ls_header TO lt_header. " Change Flags ls_header_x-orderid = iv_orderid. ls_header_x-equipment = abap_true. ls_header_x-funct_loc = abap_true.
APPEND ls_header_x TO lt_header_x. " Change and Save OrderCALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'TABLES it_methods = lt_methods it_header = lt_header it_header_up = lt_header_x return = lt_return.
When I set the Equipment in IW32 Dialog the Message IW501 pops up but the new functional Location will be saved.
Did somebody had the same issue? Are there other BAPIs or FMs for changing Equipment and Functional Location in the work order?
Thank you for your help.