Programming Create() BAPIs 

Use

The BAPI Create() creates one instance of an SAP business object type. Likewise, the BAPI CreateMultiple() creates several instances of a business object type simultaneously.

If a workflow method called Create() already exists for the business object type in question, you can use the name CreateFromData() for your BAPI. Create() is the preferred name for this BAPI.

The BAPIs Create() and CreateMultiple() are class methods (instance-independent).

For each Create() BAPI, a method must be provided with which the created business object instance can be deleted or canceled. To do this, depending on the business application practice, you should implement one of the BAPIs below:

For more information, see Programming Delete() BAPIs.

For more information, see Programming Cancel() BAPIs.

Features

BAPI Interface

Import Parameters

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

For further information see, Test Run Parameters.

For information about extension parameters and recommendations on how the customer enhancement concept should be implemented in a Create()-BAPI, see Customer Enhancements to BAPIs.

Export Parameters

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

You should keep the following points in mind:

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.

The sole contrast to successful execution is that the fields MESSAGE_V2 and MESSAGE_V3 must be passed blank. The external key is returned in MESSAGE_V4 to facilitate identification.

For more information about this parameter, see Return Parameters (Error Handling).

BAPI Coding

Several Instances in one LUW

A Create() BAPI must be implemented in such a way as to enable several calls of the same Create() method to be initiated within one LUW and, consequently, to create several instances of the same object type in one LUW.

Using Temporary Storage

Both to enable several instances of the same object type to be created within one LUW and to achieve high performance, the results of a Create() BAPI should be bundled in the update task until they are actually written to the database.
This is achieved by the BAPI calling the update module "IN UPDATE TASK" after the application logic has executed successfully. These update modules do not initiate individual database accesses. Instead, each operation to be performed is stored temporarily in the function group memory, and is then called indirectly in the FORM routine "ON COMMIT". This FORM routine, therefore, runs once only and, using techniques such as ARRAY insert, performs the update in only one database access.

For more information about bundling calls, see Details.

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 Create() BAPI.

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

External Key Assignment

For Create() BAPIs with an external key assignment, the caller transfers the key (ID) to the object instance to be created, for example, to a document number.

Important: These parameters for the external keys must not have the same name as the keys of the object type in the BOR. If they were to, the BAPI would be incorrectly identified as an instance method. Moreover, the keys created in the BAPI must be defined as export parameters

Keep in mind that you have to convert the specified keys explicitly in upper case letters in the source code of this type of Create() BAPIs. Otherwise keys are created that cannot be used in dialog applications. This is because with dialog applications external keys are always converted implicitly in upper case letters.

See also:

Example of a Create() BAPI