User Exits
ABAP Developmentintermediate

Classic User Exits in SD/MM

Where they live and how to use them safely.

Explanation

Classic user exits live in SAP includes like MV45AFZZ (SD) or MV50AFZZ (delivery). They are activated by adding code inside the FORM stubs. They share the standard program's global data โ€” powerful but easy to break. Every change requires a modification key (unless registered) and appears in SPAU on upgrade.

Code example

ABAP Code
FORM userexit_save_document_prepare.  IF vbak-vkorg = '1000' AND vbap-matnr IS INITIAL.    MESSAGE 'Material required' TYPE 'E'.  ENDIF.ENDFORM.

Real project scenario

A pharma client used USEREXIT_SAVE_DOCUMENT_PREPARE to block orders missing regulatory data before saving.

Common mistakes

Reading uninitialised globals; changing sales-doc structures mid-save; adding SELECTs inside the exit slowing save times.

Best practices

Delegate to a global class immediately; keep the exit body a two-liner; document every exit with change reason and TR.

Interview angle

Difference between USEREXIT_SAVE_DOCUMENT_PREPARE and USEREXIT_SAVE_DOCUMENT.