Skip to Content
1
Sep 08, 2020 at 10:30 AM

Include MV45AFZB USEREXIT_MOVE_FIELD_TO_COBL default cost center value CH_COBL-COBL

372 Views

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.