ERPClimb logoERPClimb
User Exits
ABAP Developmentintermediate 7 min read

User Exits Part 4: MV45AFZZ — Sales Order Exits and Save Logic

Preview · a free account unlocks the full lesson

Key takeaway

Use the main sales order exits correctly: USEREXIT MOVE FIELD TO VBAK/VBAP/VBKD for defaults, USEREXIT SAVE DOCUMENT PREPARE for checks and final changes, USEREXIT SAVE DOCUMENT for own tables, custom fields via VBAK/VBAP appends, and working with XVBAP/YVBAP and UPDKZ.

In this lessonShow sections

Visual overview

User Exits Part 4: MV45AFZZ — Sales Order Exits and Save Logic — learning sheetFlow: Add a ZZ field via VBAK append (sandbox) and default it in MOVE_FIELD_TO_VBAK → Implement a PO number check in SAVE_DOCUMENT_PREPARE → Write a log table entry in SAVE_DOCUMENT using an update FM. Key ideas: DEFAULTS DURING ENTRY; CUSTOM FIELDS; CHECKS BEFORE SAVE; FINAL CHANGES BEFORE SAVE. Watch out: Changing XVBAP in SAVE_DOCUMENT_PREPARE requires setting UPDKZ = 'U' for existing items, otherwise the change is not saved.ERPClimb.com / ABAP / LESSON 4/8 / LEARNING SHEETUser Exits Part 4: MV45AFZZ — Sales Order Exits and SaveLogic1 · HOW IT FLOWS1Add a ZZ field via VBAKappend (sandbox) anddefault it in…2Implement a PO numbercheck inSAVE_DOCUMENT_PREPARE3Write a log table entryin SAVE_DOCUMENT using anupdate FM2 · KEY IDEAS EXPLAINEDDefaults During EntryUSEREXIT_MOVE_FIELD_TO_VBAK — header: set customfield ZZ… or defaults based on customer data.USEREXIT_MOVE_FIELD_TO_VBAP — item: runs when anitem is created/changed; VBAP is the current item.Custom FieldsAppend structure to VBAK/VBAP with ZZ fields(SE11).Screen: customer subscreens (tabs "Additionaldata B") in SAPMV45A screens 8309 (header) /8459 (item) — code in MV45AFZZ/MV45AFZB or the…Checks Before SaveLoop at XVBAP WHERE updkz <> 'D' to checkitems.MESSAGE type E stops saving and returns to theorder (dialog). In BAPI calls, the error comesback in RETURN.Final Changes Before SaveChanging header: modify VBAK and, if needed,VBAK-UPDKZ handling is done by SAP for the header.Changing items: modify XVBAP; for existing itemsset updkz = 'U' if it is initial, then MODIFYxvbap.3 · REMEMBER · WATCH OUTRememberUSEREXIT_MOVE_FIELD_TO_VBAK / _VBAP / _VBKD: fill (custom) fieldswhile the user enters data.USEREXIT_SAVE_DOCUMENT_PREPARE: last point to check and change thedocument before saving; error messages here stop the save.USEREXIT_SAVE_DOCUMENT: SAP is saving; use it to write own tables (inupdate task) — no more changes to the order here.!Watch outChanging XVBAP inSAVE_DOCUMENT_PREPARE requiressetting UPDKZ = 'U' for existingitems, otherwise the change is notsaved.4 · IN A REAL PROJECTAn approval flag set on high-value items in SAVE_DOCUMENT_PREPARE worked for new orders but not for changedorders. The developer had modified XVBAP without setting UPDKZ = 'U' for existing items, so SAP did not updatethem. After the fix, the team also noticed that the check message appeared as a hard error in the e-commerce…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 3 of this series showed how to find the exits available in a transaction; MV45AFZZ is the most used user-exit include in SD, and this lesson covers its key FORMs.

During entry, defaults are set in three places: USEREXIT_MOVE_FIELD_TO_VBAK handles the header, setting a custom ZZ field or a default derived from customer data; USEREXIT_MOVE_FIELD_TO_VBAP handles the item level and runs whenever an item is created or changed, with VBAP holding the current item; and USEREXIT_MOVE_FIELD_TO_VBKD handles business data such as payment terms and incoterms. In all three, only set a field if it's still initial or clearly derived, so that user input never gets overwritten.

Custom fields are added by appending a structure with ZZ fields to VBAK or VBAP in SE11. On the screen side, they're placed on customer subscreens — the "Additional data B" tabs — inside SAPMV45A screens 8309 (header) and 8459 (item), with code living in MV45AFZZ, MV45AFZB, or the screen's own PBO/PAI logic. For copy control, data transfer routines are used when values need to be copied from a quotation to an order.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.