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: 

Include MV45AFZB USEREXIT_MOVE_FIELD_TO_COBL default cost center value CH_COBL-COBL

siongchao_ng
Contributor

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.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

Did you also implement USEREXIT_COBL_RECEIVE_VBAK ?

Hint: debug the program and add watchpoint of fields such as VBAK-KOSTL or COBL-KOSTL.

2 REPLIES 2

RAF
Active Contributor

raymond_giuseppi
Active Contributor

Did you also implement USEREXIT_COBL_RECEIVE_VBAK ?

Hint: debug the program and add watchpoint of fields such as VBAK-KOSTL or COBL-KOSTL.