Entering content frame

Function documentation Programming Create() BAPIs Locate the document in its SAP Library structure

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, Structure link Test Run Parameters.

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

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 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 Structure link 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: The parameters for external keys should not have the same names as the object type keys in the BOR. If they do, the BAPI will be mistakenly identified as the instance method. The key generated in the BAPI should also be defined as an export parameter.

Note

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

 

 

Leaving content frame