Step by Step Guide How to Add custom field to Sales Order in SAP


This post is a detailled tutorial how to Add custom field to Sales Order.

It will explain how to extend Sales Order with custom fields at SAP Order Header or at Items level.

Add custom field to SAP Sales Order

First you need to append the new custom field by Adding custom fields to VBAK and VBAP.

  1. Choose the table VBAP or VBAK ( depending on header or item)
  2. click on button “append Structures” and it will propose you the standard name for the table ZAVBAP or ZAVBAK
  3. Add fields with prefix ZZ
  4. Go to TCode SE51 maintain user exit screens in program SAPMV45A
    1. 8459 user exit item level
    2. 8309 user exit header level

Add Custom Field Logic and Layout

Here you can then design your own layout. and define your flow logic

  • PBO modules MV45AOZZ
  • PAI modules MV45AIZZ
  • Data definitions MV45ATZZ
  • Subroutines in MV45AFZZ

Custom Field in SAP Sales Order Data


Everytime you want to manipulate the date for the custom field, make attention to following elements:

  • XVBAK: New data if any change/else it will be same as old
  • YVBAK : Old data if any change/else it is blank
  • VBAK : would be the work area for header

When you deal with Items it will be some thing like this..

XVBAP <– New data if any change/else it will be same as old
YVBAP <—old data if any change/else it will be same as old

UPDKZ Sales Order Update Indicator

The update indicators of the individual table entries in the X and Y tables (field name UPDKZ) control whether an entry is added.

This indicator can have the following value:

  • update indicator (I)
  • changed (U)
  • or deleted (D)
  • or whether it is not influenced at all (update indicator is initial).

SAP Sales Order Extension logic

In action,

When you create a document,

only the update indicator ‘I’ can exist in the X tables (or sometimes the update indicator remains initial). No records exist in the Y tables.o When you change a document, the following cases may occur:

You add a table entry. There is only one entry in the X table that has the update indicator I. There is no entry in the Y table

You change a table entry. The X table contains the changed entry with the update indicator ‘U’.

The Y table contains the original table entry and has the same status as before the change; the update indicator usually is initial. The Y table can only contain one entry with the same key in each case

You delete a table entry. In this case, the X table contains this entry with the update indicator ‘D’; the entry may also be directly deleted from this table (for example, for table XVBUP).

The original entry (status before the deletion) is contained in the Y table and has also the update indicator ‘D’.

The X tables can contain any number of entries with the same key and the update indicator ‘D’, but only one entry with the update indicator ‘I’ or ‘U’.

If you want to access a specific table entry in a user exit, the update indicator must be queried at the same time so that only active entries are taken into account.

When you display documents

update indicators and Y tables are irrelevant.

Go further on how to add custom field on Sales Order in SAP

If you want to go further check the following links: