Programming Delete()/Undelete() BAPIs 


The BAPI Delete() deletes an instance of an SAP business object type from the database. Likewise, the BAPI DeleteMultiple() deletes several instances of a business object type. Delete() BAPIs must always delete entire instances, for example, a whole material master.

In contrast, the BAPI Cancel() cancels an instance of a business object, that is the instance to be canceled remains in the database and an additional instance is created that is canceled. For more information, see Programming Cancel() BAPIs.

A Delete() BAPI can delete immediately or at a later time by setting the deletion flag. The type of deletion you use in your BAPI is irrelevant to the caller, so you do not have to include these details in the BAPI interface.

The BAPI Undelete() is used to reset a deletion flag that has been set for a specific object.

The BAPIs Delete() and Undelete() are instance methods, whereas the BAPIs DeleteMutliple() and UndeleteMutliple() are class methods (instance-independent).


The interfaces of the Delete() and Undelete() BAPIs should be identical.

BAPI Interface

Import Parameters

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

If several instances are to be deleted, you must create a table for the key fields of the business object type. You can do this using a range table.

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.

For further information see Test Run Parameters.

For more information about these parameters, see Selection Parameters.

Implement the interface of a Delete() BAPI so that it is not possible to delete all the instances simply by parameterizing the interface, for example by specifying default settings.

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.

When an Undelete() BAPI executes successfully, the following standardized T100 message is used:

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

If an error occurs during the execution of an Undelete() BAPI, the following standardized T100 message is used:

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

See also:

Example of a Delete() BAPI