Entering content frame

Function documentationProgramming Change() BAPIs Locate the document in its SAP Library structure

Use

The BAPI Change() changes an existing instance of an SAP business object type, for example, a sales order.

The BAPI Change() is an instance method, whereas the BAPI ChangeMultiple() is a class method (instance-independent).

Features

BAPI Interface

Import Parameters

You should keep the following points in mind when defining the import parameters:

Note

For the associated method definition in the BOR, the key fields must not also be specified as parameters. For this reason, the BOR/BAPI Wizard does not include the function module parameters for the key fields in the method definition, when it creates a BAPI.

By contrast, if the Change by comparison concept is implemented, you must create an additional equivalent parameter for every parameter with fields containing modified values. For more information, see Structure link Change Parameters.

Export Parameters

You should keep the following points in mind when defining the export parameters:

This graphic is explained in the accompanying text

You should keep the following points in mind:

Note

If the complete key exceeds the maximum capacity of MESSAGE_V2 (that is, 50 characters), it is divided up between the fields MESSAGE_V2 and MESSAGE_V3. The first 50 characters are stored in MESSAGE_V2 and the remaining characters in MESSAGE_V3.

This graphic is explained in the accompanying text

The meaning of the various fields is the same as for successful execution.

BAPI Coding

Possible Strategies for Implementing a Change() BAPI

In BAPIs that cause database changes (for example, Change() and Create() BAPIs), you must be able to distinguish between parameter fields that are to be modified (change-relevant fields) and parameter fields that are to remain unmodified.

Using an initial value is no solution because an initial value could also represent a valid new value. Also, in the ABAP programming language as well as on other development platforms, the value "NULL" should not be assigned to a data type to indicate an empty field.

The change-relevant fields must therefore be identified using a help construct. There are two possible ways of doing this:

  1. Flagging Fields to Identify Fields Containing Modified Values

In this approach, including a flag in an additional "change parameter" identifies parameter fields containing modified values.

This way the BAPI can identify both modified and unmodified fields in the parameter.

Follow the conventions below when you create change parameters to identify modified fields:

   

‘X’:
This value means that the corresponding parameter field contains a modified value.

   

‘ ‘ (no value):
This means that the corresponding parameter field does not have to be updated.

For more information about this concept, see Structure link Change Parameters.

  1. Comparing Fields to Identify Fields Containing Modified Values

In this approach, comparing two parameters, one containing the current valid data and the other the new, modified data, identifies fields containing modified values.

When the Change() BAPI is called, the current data in the database and the new, modified data must be entered in the corresponding parameters. The current data set can be transferred, for instance, from a GetDetail() BAPI that has been called.

The following comparisons can be made:

Note the following when you are comparing fields containing modified data.

This graphic is explained in the accompanying text

For example, if the parameter with the current valid data is called EquiSales, the parameter with the modified data is called EquiSalesNew.

Avoiding Incompatibilities with Customizing Settings

It could be possible that certain values set by Customizing appear differently in the BAPI interface. These values cannot be overwritten by a Change() BAPI.

To avoid incompatibility with Customizing settings, you should implement a Change() BAPI in the following way:

See also:

Example of a Change () BAPI

 

 

Leaving content frame