Programming ExistenceCheck() BAPIs 

Use

The BAPI ExistenceCheck() checks whether an entry exists in the database for an SAP business object type, for example, whether the customer master has been created.

It can be useful to check the existence of sub-objects at the same time. This could involve checking whether information exists within a particular company code for a customer.

The ExistenceCheck() BAPI is an instance method.

Features

You can implement this method as a BAPI and/or as a method of SAP Business Workflow. If you implement this method as a BAPI, it only has to be implemented once, because an ExistenceCheck() BAPI can also be used by SAP Business Workflow.

To get the highest possible performance from the BAPI ExistenceCheck(), you should reduce the number of columns to as few as possible before selecting the table rows.

select single bukrs from bkpf into lv_bukrs

where bukrs = bkpf-bukrs

and belnr = bkpf-belnr

and gjahr = bkpf-gjahr.

instead of

select single * from bkpf

where bukrs = bkpf-bukrs

and belnr = bkpf-belnr

and gjahr = bkpf-gjahr.

Import Parameters

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

For the associated method definition in the BOR, the key fields must not also be specified as method 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.

- The parameter CompanyCode in the Customer.ExistenceCheck() BAPI enables the existence of a particular company code view of the customer to be checked too.

- The parameter Items in the SalesOrder.ExistenceCheck() BAPI enables you to check whether at least one item exists for this sales order.

Export Parameters

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

Activities

When a business object type is created, as the default, it inherits a definition of the method ExistenceCheck() through the interface IFSAP. For this reason, you can create an ExistenceCheck() BAPI using the BOR/BAPI Wizard, as the method name ExistenceCheck() already exists for the business object type.

We recommend, therefore, that you redefine the existing method ExistenceCheck() manually in the BOR, via the menu path Edit ® Redefine.

See also:

Example of an ExistenceCheck() BAPI