09-08-2020 11:30 AM
Hi all,
I have a requirement which needed to default the cost center value when loading in 3 priority: Anyone have any idea regarding how to default the cost center value before?
1. If the cost center field is blank retrieve from VBAK table kostl field
2. If VBAK dont have kostl value then default to a Z custom table kostl value
3. if user manually change the cost center in VA02 then stick the user changed value
below is the code:
IF CH_COBL-kostl IS INITIAL.
CLEAR ls_vbak.
SELECT SINGLE * FROM vbak INTO ls_vbak
WHERE vbeln = vbak-vbeln
AND spart = VBAK-SPART
AND vkorg = VBAK-VKORG.
IF sy-subrc = 0.
move ls_vbak-kostl to CH_COBL-kostl.
ELSE.
move ztbsd001-kostl to CH_COBL-kostl.
ENDIF.
ELSE.
IF vbak-kostl IS NOT INITIAL. ""user manual changed value
MOVE vbak-kostl TO CH_COBL-kostl.
ELSE.
move ztbsd001-kostl to CH_COBL-kostl.
ENDIF.
ENDIF.
Problem: It is still not working as described:
In create mode (VA01), if I double click into the item level (e.g. Conditions tab) and then exit back to the overview screen.
The cost centre revert back to the default (i.e. X00003).
If SO created (e.g.2021231646), in display mode C/C is shown correctly as X00090.
But when I go in as change mode, the C/C auto change back to X00003.
09-09-2020 8:19 AM
Did you also implement USEREXIT_COBL_RECEIVE_VBAK ?
Hint: debug the program and add watchpoint of fields such as VBAK-KOSTL or COBL-KOSTL.
09-09-2020 5:52 AM
Hi,
maybe this post can give you some hints
https://answers.sap.com/questions/5812674/cost-centre-field-in-sales-order-account-assignmen.html
09-09-2020 8:19 AM
Did you also implement USEREXIT_COBL_RECEIVE_VBAK ?
Hint: debug the program and add watchpoint of fields such as VBAK-KOSTL or COBL-KOSTL.