Start of Content Area

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

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 Parameter

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

      The BAPI’s import parameters in the function module only contain the key fields of the associated business object type. The names of these parameters must be identical to the names of the object keys in the BOR and must have the same data elements.

Note

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. 

      If you want to check the existence of sub-objects at the same time, create additional, optional parameters.
Examples:

- 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.

      If customers are to be enabled to enhance the import parameters of the BAPI without modifications being necessary, you must create the parameter ExtensionIn.
For information about extension parameters and recommendations on how the customer enhancement concept should be implemented in a ExistenceCheck() BAPI, see Customer Enhancements and Modification to BAPIs.

Export Parameter

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

·         To report messages from the method call back to the calling program, you should create only the export parameter Return. It is of particular importance when errors occur that messages describing the errors in detail are returned. You should, therefore, use all of the fields of the structure BAPIRET2. You should, in particular, fill the fields Parameter, Row, and Field.

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 cannot 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.

      Enter the function module that implements the ExistenceCheck() BAPI.

      Create the method parameter Return (the key fields of the business object type are not included in the method definition in the BOR).   

 

End of Content Area