You are on page 1of 9

USEREXIT_MOVE_FIELD_TO_VBAK

This user exit is used to assign values to new fields at sales document header level. This user exit is called up at the end of the FORM routine VBAK_FUELLEN. Tables Used KNA1 - General Data in Customer Master KNVV- Customer Master Sales Data VBAK- Sales Document: Header Data VBKD- Sales Document: Business Data VBAP- Sales Document: Item Data Basics on Copying Data The following communication structures are relevant for using customer master record fields in SD documents: KUAGV (Sold-to party view of customer master record)

KUWEV (Ship-to party view of customer master record)

KUREV (Bill-to party view of customer master record)

KURGV (Payer view of customer master record)

Additional fields from the customer master (KNA1 and KNVV) are defined in the following INCLUDES: Sold-to party data: KUAGVZ (in KUAGV)

The INCLUDE KUAGVZ contains the reserve fields from the customer master KVGR, KVGR2, KVGR3, KVGR4 and KVGR5 which are described in the step "Reserve fields in the customer master". If the fields are to be used, they no longer need to be included in the view

. Ship-to party data: KUWEVZ (in KUWEV)

Payer data: KURGVZ (in KURGV)

Bill-to party data: KUREVZ (in KUREV)

Transport fields to customer view

Field transport from master record to customer view can be found in the following user exits:

Sold-to party data: V05EA1AG (user exit for sold-to party when reading KNA1) Go to SE38, input V05EA1AG

V05EZZAG (user exit for sold-to party when reading KNVV) Go to SE38, input V05EZZAG

Ship-to party data: V05EA1WE (user exit for ship-to party when reading KNA1)

V05EZZWE (user exit for ship-to party when reading KNVV)

Payer data: V05EA1RG (user exit for payer when reading KNA1)

V05EZZRG (user exit for payer when reading KNVV)

Bill-to party data: V05EA1RE (user exit for bill-to party when reading KNA1)

New fields defined with the same name are automatically transported there by MOVE CORRESPONDING. Otherwise they must be transported manually. Transport from customer view to the sales document table The routines for assigning values to the fields in the sales document can be found in the program MV45AFZZ. Enter the new field names here (beginning with "ZZ". USEREXIT_MOVE_FIELD_TO_VBAK USEREXIT_MOVE_FIELD_TO_VBAP USEREXIT_MOVE_FIELD_TO_VBKD

Transfer of the customer master fields into the sales document" . Copying customer master fields to a sales document is carried out in two steps:

1. A field in the customer master table (KNA1 or KNVV) is first copied by INCLUDE (KUAGVZ, KUWEVZ, KURGVZ and KUREVZ) to the sold-to party, ship-to party or payer view (KUAGV, KUWEV, KURGV or KUREV). A value is assigned to the field via the user exit V05EA1AG. 2. The field is copied to the sales order table (VBAK, VBKD or VBAP) from the respective customer view (KUAGV, KUWEV, KURGV or KUREVZ). A value is assigned to the field via a user exit in program MV45AFZZ (USEREXIT_MOVE_FIELD_TO_VBAK).

Example
Requirement - Copy sold-to party field (KNA1) in the sales document header (VBAK). There are two possible cases for copying fields. They are distinguished by the way in which values are assigned to fields. Case 1 The field exists in KNA1 and can be copied to the sold-to party view KUAGV and to VBAK. The name of the field in this case would be same.

Case 2 The field does not exist in KNA1 or VBAK. In this case the field is to be created. The new data elements and new field names must begin with the letters "ZZ". The names in this case are not the same.

Proceed as follows: 1. Make sure that the field exists in the sold-to party view KUAGV. If necessary, enter it in KUAGVZ (= INCLUDE in KUAGV). Let us take field KDKG1 - Customer condition group 1 which exists in communication structure KUAGV.

2. Activate the structure. 3. The way in which a value is assigned to the new fields in the sold-to party view (KUAGV) depends on whether the names are the same. If the names are the same, a value is automatically assigned to the field in user exit V05EA1AG via MOVE CORRESPONDING.

If the names are not the same, a value is assigned to the field manually.

4. Hence, you must assign a value to the field in the sales document header. Its done in the program MV45AFZZ in user exit USEREXIT_MOVE_FIELD_TO_VBAK.

The Statement in our case would be FORM USEREXIT_MOVE_FIELD_TO_VBAK.

VBAK-ZZFELD3 = KUAGV- KDKG1. ENDFORM.

Case 2: Copy sold-to party field KNVV -> sales document header VBAK There are two possible cases for copying fields. They are distinguished by the way in which values are assigned to fields. Case 1 The field exists in KNVV and can be copied to the sold-to party view KUAGV and to VBAK. The name of the field in this case would be same.

Case 2 The field does not exist in KNVV or VBAK. In this case the field is to be created. The new data elements and new field names must begin with the letters "ZZ". The names in this case are not the same.