Skip to Content
avatar image
Former Member

Problem in user exit: USEREXIT_SAVE_DOCUMENT_PREPARE

Hi All,

I have included some code in USEREXIT_SAVE_DOCUMENT_PREPARE .

LOOP AT XVBAP.
      clear v_vkorg.

      select single vkorg from vbak
        into v_vkorg
        where vbeln = xvbap-vbeln.

      IF sy-subrc = 0.
        IF ( xvbap-matnr CS '_ET' and  xvbap-spart = 'P1' )
                                  OR
          ( xvbap-matnr CS '_ET' and  xvbap-spart = 'M1' and v_vkorg = 'GB01' ).

          xvbap-kztlf = 'A'.
          MODIFY xvbap.
        ENDIF.
      ENDIF.
    ENDLOOP.

The table xvbap is properly modified.

but the problem is, the kztlf(partial delivery field) in "VA02" is not populated with 'A'.

I debug the code, from xvbap, the db table vbap is properly updated with the value.

Strange thing is, in one of the enhancement points, the entire tables have been getting refreshed(enhancement point is of standard)

If this is the case, then what is the use of USER-EXIT.

Pls help me how to resolve the above issue.

Thank you,

Priya

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jun 23, 2010 at 05:47 AM

    Hi ,

    Very first thing is , if that standard enhancement points is getting called after your user exit then , the exit you are using will not work for you. Find any other exit which would get called after that enhancement points execution.

    See if enhancement points is really a standard one and really needed otherwise you can modufy it and make it deactivated. Then your user exit will work as that table will hold all of its value and will show that fields with A populated.

    Whatever is happening currently is absolutely correct.,

    The corresponding table gets populated as because table updates are happening after your exit but before enhancement point execution and when you finally have look to transaction , it does not show 'A' as because the table (XVBAP) from which this value will be provided to SAP transaction is getting refreshed by enhancement point.

    I hope you understood it.

    Regards,

    Uma Dave

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 23, 2010 at 05:53 AM

    Hi Priya,

    Replace Your code with the below code. The below code will take care of the every circumstance (VA01 / VA02 / VA03). Also, it is not required to select the sales organization from VBAK for the sales order (as it is already there in program structure field VBAK-VKORG).

    if sy-tcode eq 'VA01' or sy-tcode eq 'VA02'.

    if not xvbap[] is initial.

    LOOP AT XVBAP.

    IF ( xvbap-matnr CS '_ET' and xvbap-spart = 'P1' )

    OR

    ( xvbap-matnr CS '_ET' and xvbap-spart = 'M1' and vbak-vkorg = 'GB01' ).

    xvbap-kztlf = 'A'.

    MODIFY xvbap.

    vbap-kztlf = 'A'.

    ENDIF.

    ENDLOOP.

    else.

    IF ( vbap-matnr CS '_ET' and vbap-spart = 'P1' )

    OR

    ( vbap-matnr CS '_ET' and vbap-spart = 'M1' and vbak-vkorg = 'GB01' ).

    vbap-kztlf = 'A'.

    ENDIF.

    endif.

    endif.

    Regards,

    Birendra

    Add comment
    10|10000 characters needed characters exceeded

    • Brad Bohn Birendra Chatterjee

      Don't modify standard fields in USEREXIT_SAVE_DOCUMENT and don't use SY-TCODE if you intend the changes to work when a BAPI is called. Use the T180 fields instead. Why not use USEREXIT_MOVE_FIELD_TO_VBAP at the time the material is added to the document?

  • avatar image
    Former Member
    Jun 23, 2010 at 01:37 PM

    are you sure it's XVBAP at this point in the code? I think SAP has reverted to internal table VBAP at this point, but I can't check...my client doesn't run SAP logistics modules.... If it's still using XVBAP, set the UPDKZ field correctly for Insert, Update or Delete.

    There's no need for enhancement points, badis, etc. This include is always active and intended to contain user code...it's the original user-exit method utilized by SAP. Insert your code (you may need activation key if this is first time the include has been changed).

    Add comment
    10|10000 characters needed characters exceeded