Skip to Content
0
Jul 29, 2019 at 09:19 AM

User exit to add cost center for auto created PR in SAP PM Order IW31 or IW32

391 Views Last edit Jul 29, 2019 at 10:18 AM 2 rev

After creating PR in Operations and also in Non stock items of Component cost center have to change when save the order. I search it in forum and found only before creating PR. In user exit IWO10025 cost center add to PR after update the order again. The coding I add in the user exit is as below. I want to update cost center at the moment it save or update the auto generated PR in order IW31 or IW32

DATA : it_ebkn LIKE TABLE OF ebkn WITH HEADER LINE.

SELECT *
FROM ebkn
INTO TABLE it_ebkn
WHERE aufnr = caufvd_imp-aufnr.

LOOP AT it_ebkn WHERE kostl IS INITIAL.
UPDATE ebkn
SET kostl = caufvd_imp-kostv
WHERE banfn = it_ebkn-banfn AND
bnfpo = it_ebkn-bnfpo.

IF sy-subrc = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDLOOP.