This action might not be possible to undo. Are you sure you want to continue?
Business Application Programming Interface (BAPI)
Compiled by Sudhanshu Singh
A Tutorial on Business Application Programming Interface_____________________________
Business Application Programming Interface (BAPI) Business Object Repository (BOR) Transaction Model for Developing BAPIs Defining and Implementing the BAPI Frequently Used BAPIs Defining a BAPI Scenario Defining a BAPI and Its Interface Determining the SAP Business Object and Its Key Fields Defining the Interface Structure of the BAPI Naming Parameters in the Function Module Specifying the Required Objects in ABAP Dictionary Naming the Method in the BOR Naming Parameters in the BOR Creating Individual Programming Objects Conversion Between Internal and External Data Formats Converting Between Internal and External Data Formats Application Example Defining Methods in the BOR Using the BOR/BAPI Wizard Example of a Function Module Testing the BAPI Releasing and Freezing the BAPI Programming BAPIs Programming Change BAPIs Programming Replicate/Clone BAPIs Programming Value Ranges Internal and External Data Formats Reporting Errors Providing Input Help (F4 Help) Improving the Performance of your BAPI Enhancements to Existing BAPIs Customer Modifications of BAPIs Implementing BAPIs in ALE Scenarios BAPI Implementation Checklist 3 4 5 8 9 11 13 14 15 16 17 18 18 20 21 22 23 25 27 28 29 30 31 34 36 37 39 42 44 45 48 50 52
_________ __________________________________________________________________ 2
A Tutorial on Business Application Programming Interface_____________________________
Business Application Programming Interface
A Business Application Programming Interface (BAPI) is a precisely defined interface providing access to processes and data in business application systems such as R/3. BAPIs are defined as API methods of SAP Objects. These objects and their BAPIs are described and stored in the Business Object Repository (BOR).
BAPIs can be called within the R/3 System from external application systems and other programs. A BAPI call can either be made as an object oriented method call or as a remote function call (RFC). BAPIs are a global communication standard for business applications. Examples of what BAPIs can be used for include: R/3 satellite systems Distributed R/3 scenarios using Application Link Enabling (ALE) Connecting R/3 Systems to the Internet using Internet application components (IACs) Visual Basic programs as front ends to R/3 Systems Work flow applications that extend beyond system boundaries Customers' and partners' own developments Connections to non-SAP software Connections to legacy systems
_________ __________________________________________________________________ 3
A Tutorial on Business Application Programming Interface_____________________________
Business Object Repository (BOR)
The Business Object Repository (BOR) is the object oriented repository in the R/3 System. It contains, among other objects, SAP Business Objects and their methods. In the BOR a Business Application Programming Interface (BAPI) is defined as an API method of an SAP Business Object. Thus defined, the BAPIs become standard with full stability guarantees as regards their content and interface.
With regard to SAP Business Objects and their BAPIs, the BOR has the following functions: • provides an object oriented view of R/3 System data and processes. R/3 application functions are accessed using methods (BAPIs) of SAP Business Objects. Implementation information is encapsulated; only the interface functionality of the method is visible to the user. • • arranges the various interfaces in accordance with the component hierarchy, enabling functions to be searched and retrieved quickly and simply. Manages BAPIs in release updates. BAPI interface enhancements made by adding parameters are recorded in the BOR. Previous interface versions can thus be reconstructed at any time. When a BAPI is created the release version of the new BAPI is recorded in the BOR. The same applies when any interface parameter is created. The version control of the function module that a BAPI is based on is managed in the Function Builder. • Ensures interface stability. Any interface changes that are carried out in the BOR, are automatically checked for syntax compatibility against the associated development objects in the ABAP Dictionary.
You should only define a BAPI as a SAP Business Object method in the BOR if the function module that the BAPI is based on has been fully implemented. Full access to the BOR is restricted to the persons responsible for the objects involved and for quality control. BOR-BAPI Wizard The BOR-BAPI Wizard assists with creating new BAPI methods in the BOR. It takes you through the creation process step by step.
_________ __________________________________________________________________ 4
A Tutorial on Business Application Programming Interface_____________________________
Transaction Model for Developing BAPIs
The transaction model in which BAPIs are used determines how you have to program BAPIs. The transaction model described here has been used to develop BAPIs for R/3 Releases 3.1 and 4.0A. Logical Unit of Work (LUW) and Statelessness Within the context of this transaction model a transaction represents one processing step or one logical unit of work (LUW). When a transaction is called, database operations are either fully executed or not at all. The whole transaction must be programmed to be stateless. This transaction model requires that: • no data is imported that may indirectly affect the result. If a transaction is called more than once, each call must have the same result. For BAPIs this means, for example, that Set or Get parameters cannot be used. However, you can keep Customizing data in a global memory as this data remains unchanged even if transaction calls are repeated. • • there must be no functional dependencies between two transactions. either all relevant data has to be changed in the database or none at all.
The following sections describe how the transaction model effects BAPI development: • • Using the Transaction Model in Release 3.1 Using the Transaction Model in Release 4.0A
Using the Transaction Model in Release 3.1
The example below of an external program calling a BAPI to change data in an R/3 System, illustrates how the transaction model affects BAPI development in Release 3.1. Assume the transaction was written in, for instance, Visual Basic and that data is to be changed in the R/3 System only. The RFC connection is live the whole time the external program is logged on to the R/3 System to avoid having to connect and disconnect repeatedly. When the RFC connection is already established, an RFC call does not essentially take up any more CPU time than a direct call to the function module from within the R/3 System. There is one BAPI call for each transaction in the transaction model supported in 3.1. BAPIs can only be called synchronously. A BAPI call is essentially the call of the underlying RFC capable function module.
The process flow of the program consists of the steps below (see graphic): Log on _________ __________________________________________________________________ 5
must be carried out completely or not at all (LUW).. for example..1 are created with integrated commit control... (Visual Basic source code) Log off Prerequisites What do the terms "LUW" and "statelessness" mean to BAPIs that are implemented in the framework of this transaction model? If a transaction represents one Logical Unit of Work and in addition is supposed to be stateless.. This is why BAPIs to be implemented in 3. (Visual Basic source code) Call BAPI to read and/or change data . The "Commit Work" command is always invoked at the end of the function module of a BAPI that modifies data. _________ __________________________________________________________________ 6 . BAPIs are affected as follows: • Initial state each time a BAPI is called A repeated call of one BAPI must produce the same result. customizing data. can be buffered...A Tutorial on Business Application Programming Interface_____________________________ . for example. • No functional dependency between two BAPIs A BAPI call must not be negatively affected by an earlier call of another BAPI. • All or nothing principle A database change.. creating a new sales order. (Visual Basic source code) Call BAPI to read and/or change data ..... Only data that is not affected by the execution of the BAPI. A follow up call must not presuppose an earlier call.
the existing transaction model used in Release 3. This is achieved by using the RFC capable function module BAPI_TRANSACTION_COMMIT which executes the command "Commit Work".. for separating individual R/3 components.A Tutorial on Business Application Programming Interface_____________________________ Using the Transaction Model in Release 4.... (Visual Basic source code) Call BAPI to read and/or change data Call BAPI_TRANSACTION_COMMIT . those BAPIs that cause database changes. Features A program based on this transaction model could consist of the following steps (see graphic): Log on .1 should not be changed.. that is. (Visual Basic source code) Log off _________ __________________________________________________________________ 7 .0A Purpose In Release 4....0A the Commit control must be taken out of write BAPIs. (Visual Basic source code) Call BAPI to read and/or change data Call BAPI_TRANSACTION_COMMIT ... BAPIs must support the transaction model used in the R/3 System.. If this is the case. However. for example. This procedure is required because BAPIs are used for continued development of the R/3 System..
This section describes how to define a BAPI and which particular guidelines to comply with. When implementing BAPIs follow the requirements below to ensure you achieve consistent behavior and representation of BAPIs as object oriented methods of SAP Business Objects. a BAPI is implemented as an RFC capable function module which is maintained in the Function Builder. However. Check if the BAPI you want to implement is in one of these general categories. Process Flow The process of defining and implementing a BAPI consists of the following steps: • • • • • • Describing the Scenario in which the BAPI is used Reviewing the BAPI Concept and BAPI Scenario Defining a BAPI and Its Interface Creating Individual Programming Objects Testing the BAPI Releasing and Freezing the BAPI _________ __________________________________________________________________ 8 . For function modules that implement BAPIs certain standards and rules must be adhered to over and above the standard programming rules for function modules. For information on these BAPIs see the section Frequently Used BAPIs.A Tutorial on Business Application Programming Interface_____________________________ Defining and Implementing the BAPI Purpose A BAPI is an API method of a business object and is defined as such in the Business Object Repository (BOR). There is a range of BAPIs that provide basic functions and these can be implemented for most of the SAP Business Objects.
for example. for example. for example. • GetStatus The BAPI GetStatus is used to query the status of an SAP Business Object. a sales order. The key values selected by the BAPI GetList are returned to the calling program in a table. for example. to determine the processing status of a sales order. • Delete The BAPI Delete deletes an instance of a SAP Business Object.A Tutorial on Business Application Programming Interface_____________________________ Frequently Used BAPIs Definition Some BAPIs and methods provide basic functions and can be used for most SAP Business Objects. for example. The method CompanyCode. for example. This workflow method is indirectly invoked when the calling program instantiates an object. • Change The BAPI Change changes an existing instance of a SAP Business Object. together with other useful information. a sales order. whether the customer master has been created. • GetDetail The BAPI GetDetail uses a key to retrieve details about a specific instance of an object and returns this data to the calling program. the BAPI GetDetail. a sales order. The key values can then be passed on to another BAPI for further processing. These BAPIs are: BAPIs for Reading Data The following BAPIs provide you with read-only access to data in the associated Business Object: • GetList With this BAPI you can select a range of object key values.ExistenceCheck of the business object CompanyCode (BUS0002) is an example of this. as listed below. for example. company codes and material numbers. for example. short texts. To specify appropriate selection requirements the calling program must pass the relevant parameters to the interface. by using GetSAPObject("CompanyCode") from within Visual Basic. for example. • ExistenceCheck The BAPI ExistenceCheck checks whether an entry exists for an SAP Business Object. change or delete instances of a business object: • Create or CreateFromData The BAPI Create or CreateFromData creates an instance of an object. For further information on programming GetList BAPIs see Programming Value Ranges. You should implement this method as a workflow method and not as a BAPI (RFC capable function module). This BAPI is used only for displaying the status of an object and does not retrieve full details like the BAPI GetDetail. _________ __________________________________________________________________ 9 . BAPIs for Creating or Changing Data The following BAPIs can create. For more information about the BAPI Change see Programming Replicate/Clone BAPIs.
A Tutorial on Business Application Programming Interface_____________________________ BAPIs for Replicating Business Object Instances The BAPIs below can be implemented as methods of business objects that can be replicated. This method must be implemented for each business object to be cloned. _________ __________________________________________________________________ 10 . the BAPI CloneMultiple can replicate or modify several business object instances at the same time. • CloneMultiple The BAPI CloneMultiple is used by a system to replicate several business objects on another system or to modify several business objects that have already been cloned. For further information about these BAPIs see Programming Replicate/Clone BAPIs: • Replicate The BAPI Replicate is used by a client system to request clones of business objects in a server system. Unlike the BAPI Clone. At least one of the following BAPIs must be implemented for each business object to be cloned: • Clone The BAPI Clone is used by a system to replicate one business object on another system or to modify one business object that has already been cloned.
two BAPIs are required: Display list of creditors Display details of a specific creditor The interdependency between these two BAPIs is evident because first the creditor list is displayed to obtain the ID of the specific creditor sought. If the data of a different SAP Business Object is to be read or updated then the appropriate interface for this object must be used.A Tutorial on Business Application Programming Interface_____________________________ Defining a BAPI Scenario Purpose Before you program a BAPI you should clearly define the processes and situations the BAPI will be used for. First of all. a list of creditors is to be displayed from which a specific creditor can be selected. From this ID. However. details of this creditor can then be displayed. Example To read a creditor's details as described in the above scenario. Process Flow To define the scenario the BAPI is to be used for. Then. specific details about this creditor are to be displayed. consider the following issues: • Which scenario is to be implemented? Every BAPI should be based on a model of a scenario in which it can be usefully employed. • What functionality should the BAPI provide and how does it affect related BAPIs. the BAPI "Display details of a specific creditor" can be used without first calling the BAPI "Display list of creditors". The relevant SAP Business Object for this scenario is Creditor. The functions or methods of these other objects are used implicitly (delegation principle). the two BAPIs remain functionally independent of each other. Example _________ __________________________________________________________________ 11 . • Which SAP Business Objects are involved? From the scenario definition and with the help of the process model you can get information about the SAP Business Objects relevant to the BAPI scenario. especially the other BAPIs of the SAP Business Object in question? In line with the scenario concept BAPIs must complement each other to create a complete scenario. a BAPI is required to read data about a creditor. Example In the scenario to be implemented. • To what extent can the BAPI's functionality be implemented within the scope of the business object? A BAPI should be developed so that it provides functionality exclusively within the context of its associated SAP Business Object. You can describe the scenario in the form of a process model. using another BAPI. because if the creditor ID is known. Their relationships with each other must be clearly defined.
_________ __________________________________________________________________ 12 . Review Purpose In the previous step you created a concept for a scenario a BAPI could be applied to. Process Flow You should carry out the review of the BAPI scenario in cooperation with all persons involved in the BAPI development and those responsible for quality control in your development group. Before you implement the scenario and begin defining and developing the BAPI. You also defined relevant SAP Business Objects.A Tutorial on Business Application Programming Interface_____________________________ The BAPIs required to read creditor details in the above scenario are only able to access data in the SAP Business Object Creditor. You will also have identified the SAP Business Objects relevant to the BAPI scenario. Other object types are not involved. Result Start developing the BAPI only after you have successfully completed the review. you should carry out a review of the scenario concept. • Is the BAPI assigned to the SAP Business Object in a meaningful and semantically correct way? Result Once you have considered these issues you will be able to clearly conceptualize the functionality of the planned BAPI(s).
open the Business Object in the Business Object Repository (BOR). double click the name of the Business Object. as described in Creating Individual Programming Objects and Programming BAPIs. In this step. Exceptions are currency codes. you will decide on the names. then plan a name for the one to be created. You can use the default technical name (object type) of the SAP Business Object as the basis of the function group name. or if a function group does not exist already. planning a name for one. For example. Ascertain whether a function group has already been created for the BAPIs of the SAP Business Object in question. To ascertain the technical name of the Business Object. Only after you have planned and defined these required details can you start to implement the BAPI. For information about naming a method refer to Naming the Method in the BOR. the following steps must be completed: • • • Determining the SAP Business Object and Its Key Fields Defining the Interface Structure of the BAPI Identifying the name of the function group. Use the suffix "nnnn" as the name of the function group. • Assigning a name to the function module Choose a name that gives an indication of what the BAPI is used for. and characteristics of the BAPI and determine the structures the BAPI will be based on. as described in Determining the SAP Business Object and Its Key Fields. parameters. if the technical name of the object is BUS1008 then the associated BAPI function group is called 1008. for example.A Tutorial on Business Application Programming Interface_____________________________ Defining a BAPI and Its Interface Purpose After you have carried out the review of the BAPI concept and it has been accepted. • • Naming Parameters in the Function Module Defining the format for passing the values in the function module interface. in the case of a BAPI which reads details for the object type Creditor. The technical name of a SAP Business Object usually takes the form of BUSnnnn. This is because BAPIs are programming interfaces and not end user interfaces. If a function group does not already exist. The naming convention is: BAPI_<Business Object name>_<method name>. Parameters must not be converted before they are passed to and from the BAPI interface. you can start defining the BAPI itself. ISO codes and fields with an internal key. For example. the name of the associated function module is BAPI_CREDITOR_GETDETAIL. Process Flow To define the scope and required components of the BAPI to be implemented. • • • Specifying the Required Objects in ABAP Dictionary Naming the Method in the BOR Naming Parameters in the BOR _________ __________________________________________________________________ 13 . where n is a number. To display further details. All BAPIs belonging to one SAP Business Object should be stored as function modules in one function group. the object type.
This key field must be defined as a parameter with the name CREDITORID in the function modules of the instant-dependent BAPIs for this Business Object. This key can consist of several key fields. instance-dependent methods relate to one instance (one specific occurrence) of an SAP Business Object type. For further information see Defining the Interface Structure of the BAPI. In the case of instance-dependent BAPIs. A key is defined in the BOR for most SAP Business Objects. because the name links the key fields to the parameters. The business objects are displayed in the order of the R/3 application hierarchy. You can differentiate between instance-dependent and instance-independent BAPI methods. Select Tools → ABAP Workbench → Overview → Business Object Browser . Example SAP Business Object Creditor has a key field named CreditorId. The contents of these key fields uniquely identify one individual instance of an SAP Business Object. Select the required SAP Business Object in the application hierarchy and double click it to open it. To display the Business Object's key fields. the key fields of the corresponding SAP Business Object must be used as parameters in the function module the BAPI is based on so that the associated object instance can be identified. for example to one specific sales order. To display the Business Object and its key fields follow the steps below: 1. The names of the key fields in the SAP Business Object and the corresponding parameters in the BAPI function module must be the same. 3. 2. Unlike instance-independent methods. _________ __________________________________________________________________ 14 .A Tutorial on Business Application Programming Interface_____________________________ 1 23 Determining the SAP Business Object and Its Key Fields You have to identify the relevant SAP Business Object in the Business Object Repository (BOR) and determine whether the key fields of the Business Object are relevant for your BAPI. expand the node Key fields. All the key fields defined in the BOR for the SAP Business Object in question must be used as the parameters in the function module.
These BAPIs return one key value. the calling program has to pass the ID of the creditor and the company code. Exceptions are write BAPIs. the individual import.GetDetail and Customer. For BAPIs that generate instances. the following parameters must be set in the function module which the BAPI is based on: The key field CreditorID of the SAP Business Object as an import parameter An import parameter for the company code A Return parameter that reports messages back to the calling program A parameter for general details of the creditor A parameter for specific details of the creditor A parameter for bank details of the creditor _________ __________________________________________________________________ 15 . as described in the list item above. If a key value is to be passed to the BAPI by the calling program. an order number in the BAPI SalesOrder. that is. Specify what other data is relevant as import. the key field of the Business Object should be set as an export parameter in the BAPI function module. Caution You cannot use Changing and Exception parameters in a function module which implements a BAPI.GetStatus. export or table parameters for the BAPI. proceed as follows: 1. Process Flow To define the interface parameters. this could be a customer number (CustomerNo) in the BAPIs Customer.A Tutorial on Business Application Programming Interface_____________________________ Defining the Interface Structure of the BAPI Purpose In this step you are going to define the BAPI interface.CheckPassword. 2. the key field must be set as an import parameter in the function module of the BAPI. export and table parameters required for calling the BAPI. Usually they return a table with a selection of key values. Every BAPI must have an Export parameter return that reports messages back to the calling program. the BAPIs Create or CreateFromData. To read creditor details. For BAPIs that are class methods a key field is neither set as an import nor as an export parameter in the BAPI function module.CreateFromData. for example. To map these requirements onto the BAPI interface. Class methods are instance-independent and are called without the use of key values. Check whether the key fields of the SAP Business Object are required in the interface. For example. Example The BAPI to be developed is to read data from the SAP Business Object Creditor. or the number of a sales document in the BAPI SalesOrder. That way a specific instance of the Business Object is identified. The creditor data returned is to include general details. The key fields of the SAP Business Object are some of the most important BAPI parameters. specific details and bank details. for example.
Now you can specify the names of these parameters in the function module. the following parameters were identified: • • • • • • An import parameter for the key field CreditorId of the SAP Business Object An import parameter for the company code A Return parameter A parameter for general details of creditor A parameter for specific details of creditor A parameter for bank details of creditor You could use the following names for these parameters in the function module: Parameters and their Names in the Function Module Contents Creditor number Company code General creditor details Specific creditor details Return parameter Bank details Name in Function Module CREDITORID COMPANYCODE CREDITORGENERALDATA CREDITORCOMPANYDATA RETURN CREDITORBANKDATA Parameter Type IMPORTING IMPORTING EXPORTING EXPORTING EXPORTING TABLES _________ __________________________________________________________________ 16 . and the latter are restricted to a maxiumum of 20 characters. When assigning parameter names follow the guidelines below: • • The names must be in English The names of parameters in the function module can generally be a maximum of 30 alphanumeric characters. Choose meaningful names and do not use abbreviations. because the names of parameters in the function module must be identical to the parameter names in the BOR. Give meaningful names to the parameters in the function module interface to give the BAPI an easy-to-use interface. Example • • In the above example based on the creditor scenario. Prerequisites You can only define export. import and table parameters in the function module interface of the BAPI. The names of parameters in the function module must be written in capitals.A Tutorial on Business Application Programming Interface_____________________________ Naming Parameters in the Function Module Purpose In the previous step you identified the contents of the interface parameters. This is because the names you choose for the function module parameters are used in the Business Object Repository (BOR) as the names of the corresponding method parameters. The names of parameters in a function module that implements a BAPI can only have a maxiumum of 20 alphanumeric characters.
A Tutorial on Business Application Programming Interface_____________________________ Specifying the Required Objects in ABAP Dictionary Purpose After you have specified the contents and names of the required interface parameters you can identify and define the required data objects in the ABAP Dictionary. Up until Release 4.0 it is possible to assign English names to the data elements in the ABAP Dictionary. The first example here uses structures created in Release 3.0. Note the following: • • You can use individual fields. Names should begin with the prefix BAPI. You can use alphanumeric characters and underscores. Every parameter must refer to a Dictionary object. from Release 4. In this Release structure names had a maximum of 10 characters. Give meaningful names to the data structures you create. Parameters and their Reference Fields in Release 3. This enables changes to be made in R/3 applications without affecting BAPIs.0 you can use up to 30 characters. • Chose meaningful names in English for the structure fields.1 Parameter in the Function Module CREDITORID COMPANYCODE CREDITORGENERALDATA CREDITORCOMPANYDATA RETURN CREDITORBANKDATA Reference Field/Table BAPI1008-VENDOR_NO BAPI1008-COMP_CODE BAPI1008_4 BAPI1008_5 BAPIRETURN2 BAPI1008_6 Parameters and their Reference Fields in Release 4. Whenever possible use these names for the field and parameter names. The second example shows how you could name the structures more meaningfully in Release 4. You have to create your own data structures for the BAPI interface that are independent of the data structures generally used in the R/3 application.0 Parameter in the Function Module CREDITORID COMPANYCODE CREDITORGENERALDATA CREDITORCOMPANYDATA RETURN CREDITORBANKDATA Reference Field/Table BAPI1008-VENDOR_NO BAPI1008-COMP_CODE BAPI1008_CREDITORGENERALDATA BAPI1008_CREDITORCOMPANYDATA BAPIRETURN2 BAPI1008_CREDITORBANKDATA _________ __________________________________________________________________ 17 . You can use existing data elements and domains for the fields in the BAPI structures.0 ten characters were available for naming structures. structures and tables as parameters. Example In the example in the previous steps the reference fields/tables shown below were identified for the parameters. As of Release 4.1.
Prerequisites The individual components of BAPI names are identified by the use of upper and lower case letters. BAPIs are identified by the API indicator (green circle) to the right of the method name. To get an idea about naming BAPIs take a look at existing BAPIs of an SAP Business Object in the BOR. then select a BAPI. Select an object type in the application hierarchy in the Business Object Browser.0 the names of the BAPI parameters in the BOR and the names of the parameters in the corresponding function module must be identical. • To get an idea about naming BAPI parameters. ChangePassword. For example: • • • ExistenceCheck ChangePassword GetDetail If you are implementing one of the frequently used BAPIs use the appropriate generic name. ChangePassword. Expand the node for the object's methods. then finally select Parameter. You have already named the parameters of the function module in Naming Parameters in the Function Module. for example. Unlike parameter names in the function module that must be written completely in upper case. and can only have a maximum of 30 characters. _________ __________________________________________________________________ 18 . Caution From Release 4. Every new word in the parameter name begins with a capital letter. BAPI names must be meaningful and be in English. Naming Parameters in the BOR Purpose The parameter names of the methods in the Business Object Repository (BOR) are based on the parameter names in the function module. When naming parameters of a BAPI in the BOR take account of the following: • • The parameters must be in English. This was not necessarily the case in earlier releases. the components of parameter names in the BOR are separated by upper and lower case letters.A Tutorial on Business Application Programming Interface_____________________________ Naming the Method in the BOR Purpose You can now plan the name of the BAPI method in the Business Object Repository (BOR). take a look at the parameters of existing BAPIs in the BOR. for example. Select an SAP Business Object in the application hierarchy in the Business Object Browser and expand the node Methods. A parameter name in the BOR cannot have more than 20 characters.
A Tutorial on Business Application Programming Interface_____________________________ Example In the example in the previous steps six parameters for a BAPI were identified and names given to these parameters in the function module. The table below shows what the parameter names could look like in the function module and in the BOR. Parameters and their Names in the Function Module and in the BOR Contents Creditor number Name in Function Module CREDITORID Name in the BOR Defined as a key field of the Business Object Creditor and NOT as a BAPI parameter. CompanyCode CreditorGeneralData CreditorCompanyData Return CreditorBankData Company code General creditor details Specific creditor details Return parameter Bank details COMPANYCODE CREDITORGENERALDATA CREDITORCOMPANYDATA RETURN CREDITORBANKDATA _________ __________________________________________________________________ 19 .
Creating the function group in the Function Builder (if required). Make sure that the documentation is translated into the required languages. Refer to Example of a Function Module. Writing documentation for the BAPI. Defining the function module as a method of the corresponding SAP Business Object in the BOR. structures. Writing the program for the function module. • • • Using the program to map the internal data format onto the external data format. as described in Conversion Between Internal and External Data Formats. in the ABAP Dictionary. see Programming BAPIs for more information. Also. The BAPI documentation must be written in the Function Builder for the function module that the BAPI is based on. for example. _________ __________________________________________________________________ 20 .A Tutorial on Business Application Programming Interface_____________________________ Creating Individual Programming Objects Purpose After you have identified the individual programming objects and given them names you should create them in the R/3 System as required. Creating the function module in the Function Builder. as described in Defining Methods in the BOR Using the BOR/BAPI Wizard. fields and domains. You should then verify that the parameters and parameter types of the method in the BOR match the parameters of the underlying function module in the Function Builder. Process Flow To create the required programming objects in R/3 the following steps are required: • • • • Creating the Dictionary objects. BAPI documentation is essential because it is very difficult to use a BAPI that has not been well documented.
Activities To generate the required function modules see Converting between Internal and External Data Formats. to enable further development in the R/3 application.A Tutorial on Business Application Programming Interface_____________________________ Conversion between Internal and External Data Formats Use According to the guidelines BAPI interfaces should only have English field names. You can generate function modules which help to automatically convert and map the data. mapping the result from the internal structure onto the BAPI (structuring export parameters) Features The function modules generated have the following functions: • • • • They map between German and English field names They convert ISO codes They convert currency amounts into the required internal or external format They convert internal and external keys such as those used by the PSP Element (Project structure plan) Any problems that could arise during data conversions are reported back using the RETURN parameter. Existing function modules can not yet be regenerated with this transaction. Moreover in one of the previous steps you created your own structures for your BAPI which are different from the structures used in R/3 applications. mapping the inbound parameters onto the internal structure (structuring import parameters) When implementing the BAPI. As a result of these discrepancies the fields of the internal working structure of the BAPI must be mapped onto the fields of the BAPI interface before the BAPI is called. yet at the same time. in the internal working structures of a BAPI German field names are often used. You can use the generated function modules in the source code of your BAPI for: • • • • Mapping the internal working structures of the BAPI onto the external BAPI structures before the BAPI is called Mapping the result onto the internal structures after the BAPI call When implementing the BAPI. _________ __________________________________________________________________ 21 . The Application Example illustrates the use of these function modules. Limitations Occasionally you may have to manually edit the source code of a function module after it has been automatically generated. However. To regenerate an existing function module you have to manually delete the function module and then generate it anew. For more information refer to Internal and External Data Formats. This is necessary to be able to freeze the BAPI structure and to maintain a stable BAPI interface.
The table contains the following columns: . _________ __________________________________________________________________ 22 . Specify the required direction for mapping. Step by Step Procedure To generate the function module follow the steps below: 1. In the appropriate input fields enter the names of the external BAPI structure and the internal working structure you are making the conversion between. 3. In addition to the source text for the function module you can have a blank FORM routine added for your own program code if you have to make manual modifications. type Displays the conversion type. type. To generate the function module.Conv. i. Select Continue. 2.A Tutorial on Business Application Programming Interface_____________________________ 1 23 Converting Between Internal and External Data Formats Prerequisites Before you can generate the function modules to map between the internal working structures and the external BAPI structures. You can incorporate it into the source code of your BAPI as required. For further information select F1 help for columns Status and Conv.e. In the field Function group enter the name of the function group to which the generated function module is to be added. . . Select Tools → Business Framework → BAPI Development → Generate module to map fields. A table is displayed containing suggestions for the conversion of each field of the external BAPI structure.Status Indicates if the conversion is possible or if data is missing. The input fields for the name of the function module and the short text contain suggested values which you can accept or change.Field in external structure Contains the field names of the external BAPI structure.Field in internal structure Displays the fields of the internal structure to which/from which mapping is to be carried out. 5. Select Function module → Generate A dialog box is displayed in which you can enter details of the function module to be generated. . is the internal structure to be mapped onto the external structure or vice versa. The FORM routine contains the same parameters as the generated function module. select Save. Result The function module is stored in the Function Builder in the function group you specified. To do this. you must make sure that the internal and external structures exist. select Form to edit. 4.
This function module has the following interface: function map2i_bapi_material_price_to_mat_preis importing external structure bapi_material_price changing internal structure mat_preis exceptions error_during_iso_convertion error_converting_currency_amount. which converts the currency and amount fields. After invoking the BAPI the application programmer must convert these fields into the internal format used in R/3 in order to be able to process the fields. the application developer can generate the function module. This structure consists of the following fields: Fields in the internal working structure Field matnr waers stprs Description Material number Currency code Unit price Data element matnr waers stprs Domain matnr waers strps The BAPI structure bapi_material_price contains an ISO currency code and a currency amount.... .. The external structure bapi_material_price contains the fields: Fields in the external BAPI structure Field currency_iso currency amount Description ISO currency code Currency code Amount Data element isocd waers bapimatprice Domain Isocd waers bapicurr The application programmer in the R/3 System who intends to use this BAPI uses the internal structure mat_preis in his or her own program. _________ __________________________________________________________________ 23 . preis like mat_preis. bapi_preis like bapi_material_preis. map2i_bapi_material_price_to_mat_preis. Using the function Generate module to map fields. The application code could be as follows: .A Tutorial on Business Application Programming Interface_____________________________ Application Example The BAPI used in this fictitious example can read the standard price of a material: bapi_material_get_price importing material like mara-matnr exporting material_price like bapi_material_price. data: matnr like mara-matnr.
* Map and convert the result to internal format call function map2i_bapi_material_price_to_mat_preis exporting external = bapi_preis changing internal = preis. _________ __________________________________________________________________ 24 .A Tutorial on Business Application Programming Interface_____________________________ * Call BAPI call function bapi_material_get_price exporting material = matnr changing material_price = bapi_preis. * * * exceptions error_during_iso_convertion error_during_currency_amount_conversion preis-matnr = matnr.
Otherwise select Business Object Repository. Then select Continue. A list of parameters and default names is displayed which you need to edit as required.A Tutorial on Business Application Programming Interface_____________________________ 1 23 Defining Methods in the BOR Using the BOR/BAPI Wizard Prerequisites If the function module which your BAPI is based on has been fully implemented you can define it as a method of an SAP Business Object in the Business Object Repository (BOR). Synchronous. You have already identified the technical name in Defining a BAPI and Its Interface. You will have to modify the suggested name. In the next dialog box enter the name of the function module. _________ __________________________________________________________________ 25 . In the next dialog box indicate whether you want to display all object types or only business objects. Begin every new word of the method name with a capital letter and do not use underscores. the suggested method name might be BapiSalesorderGetstatus. When the relevant SAP Business Object is displayed. Delete the prefix BAPI and the business object name. 3. 4. Make sure that the parameter names of the method in the BOR are identical to the parameter names in the function module. Make sure that a BAPI is not dialog orientated. so that only the method name is left. Select Utilities → API Methods → Add method. On the initial Business Object Builder screen you can directly access the SAP Business Object if you know the technical name of the object (object type). Each new word in the parameter name must start with a capital letter. based on the name of the function module. The application hierarchy is displayed. Select Next Step. In the next dialog box specify the following information for the method to be defined: Method A default name for the method is provided. for example. BAPIs are usually implemented synchronously. BAPI_CREDITOR_GETDETAIL and select Continue. Example: If the name of the function module is BAPI_SALESORDER_GETSTATUS. Select the required SAP Business Object in the application hierarchy and open it. Step by Step Procedure First find the relevant SAP Business Object in the BOR: 1. Instance-independent Enter relevant details for your BAPI. Select Tools → Business Framework → BAPI Development → Business Object Builder. Radio buttons Dialog. To define your BAPI as a method of the Business Object: 1. You should edit this so that the resulting name is GetStatus. 2. 2. select Change. Texts Enter meaningful descriptions for your BAPI. You use the BOR/BAPI-Wizard to do this.
A Tutorial on Business Application Programming Interface_____________________________ Also specify whether the individual table parameters are used for data import or data export. To do this look at the method in the BOR. check that all the definitions have been made correctly by the BOR/BAPI Wizard. Select Next Step. _________ __________________________________________________________________ 26 . Table parameters are marked with a tick in the column 'MLine' (multiple lines). Result After the program has been generated and executed. To create the method select Yes in the next dialog box. 5.
endfunction. _________ __________________________________________________________________ 27 . check return-code is initial.. perform set_return using '10' changing return. if sy-subrc ne 0. The key field parameter "COMPANYCODEID" is defined as the import parameter.. Specific BAPI data structures are used. endif. identified by the prefix BAPI. The BAPI CompanyCode. . Source Code: function bapi_companycode_getdetail. * authority check: S_TABU_DIS V_T001 perform check_authority_t001 changing return. check return is initial.A Tutorial on Business Application Programming Interface_____________________________ Example of a Function Module This example function module implements the BAPI CompanyCode.. The function module performs authorization checks.. Note the following in the source code: • • • • • The name of the function module is in the format: BAPI_<Business Object name>_<Method name>. *"-----------------------------------------------------*"*"Local interface: *" IMPORTING *" VALUE(COMPANYCODEID) LIKE BAPI0002_2-COMP_CODE *" EXPORTING *" VALUE(COMPANYCODE_DETAIL) LIKE BAPI0002_2 *" STRUCTURE BAPI0002_2 *" VALUE(COMPANYCODE_ADDRESS) LIKE BAPI0002_3 *" STRUCTURE BAPI0002_3 *" VALUE(RETURN) LIKE BAPIRETURN *" STRUCTURE BAPIRETURN *"-----------------------------------------------------. * company code call function 'FI_COMPANY_CODE_DATA' exporting i_bukrs = companycodeid importing e_t001 = t001 exceptions error_message = 1 others = 0. The function module covers all exceptions.GetDetail of the SAP Business Object CompanyCode (BUS0002).GetDetail reads details of a company code.
Specify the appropriate object type and then start running the test by selecting Test. Check that the BAPI can be called by making RFC calls to the underlying function module. Prerequisites Carry out the test together with persons responsible for quality control in your development group.A Tutorial on Business Application Programming Interface_____________________________ Testing the BAPI Purpose After you have implemented the function module your BAPI is based on and you have defined the BAPI as an SAP Business Object method in the Business Object Repository (BOR) you should check that the BAPI functions properly. _________ __________________________________________________________________ 28 . To test the BAPI implementation. Process Flow You can test the BAPI in the following ways: • By calling the underlying function module You can individually test the function module in the Function Builder. Result If you find any errors in the BAPI implementation. • Testing the BAPI in the BOR You can test the BAPI by testing the individual method of the Business Object in the Business Object Builder. You need to know the technical name of the Business Object (object type) that you have already specified in Defining a BAPI and Its Interface. You can enter the appropriate test values in the parameters of your function module and by running the test you can verify that the source code in the function module is processed without errors. Note that for an instance-dependent BAPI you have to first specify an instance before you can run the BAPI test. Check the availability of documentation in the different logon languages. correct them and repeat the tests until you and the quality control team in your group are fully satisfied with the BAPI implementation. • Check that the BAPI can be called by BAPI ActiveX Control. Before you start testing make sure that the underlying function module has been completely implemented and that the BAPI has been correctly defined in the BOR as a Business Object method. you need to specify appropriate test values in the parameters of the BAPI. • By calling the BAPI in a Visual Basic program If possible write a program in Visual Basic to call the BAPI. Call the Business Object Builder by selecting Tools → Business Framework → BAPI Development → Business Object Builder. Select Create instance and specify the required instance.
• Check the new status of the function module in the Function Builder and the method in the BOR. Set the status of the method to 'released' in the Business Object Builder. and freeze the BAPI as a method in the BOR.A Tutorial on Business Application Programming Interface_____________________________ 1 23 Releasing and Freezing the BAPI After you have completed the function module and BAPI tests and you are satisfied that they function properly. and incompatible changes are rejected. Place the cursor again on your BAPI in the Business Object Builder and select Utilities → API methods → Freeze method. Select Function module → Release → Release. Freeze the method. You can now release the function module the BAPI is based on and the method in the Business Object Repository (BOR). Once the BAPI has been released and frozen. Select the relevant SAP Business Object in the Business Object Builder and expand the node Methods. Releasing and freezing also prevents anyone making incompatible changes to the BAPI. To release and freeze a BAPI follow the steps below: • • First release the function module in the Function Builder. it becomes available as a fully implemented Business Object method. Place the cursor on your BAPI and select Edit → Change status → Released. Releasing and freezing the BAPI should be done in cooperation with the persons responsible for the development objects involved and those responsible for quality control. the implementation is complete. _________ __________________________________________________________________ 29 . For more information about what to look out for when making changes to existing BAPIs see Enhancements to Existing BAPIs. because all changes made to a released and frozen BAPI are automatically checked for compatibility in the BOR and the ABAP Dictionary.
provide access to R/3 data and processes in a consistent way. • Other Features Also pay attention to the following when you program BAPIs: • • • • • • • Programming Change BAPIs Programming Replicate/Clone BAPIs Programming Value Ranges Internal and External Data Formats Reporting Errors Providing Input Help (F4 Help) Improving the Performance of your BAPI _________ __________________________________________________________________ 30 .A Tutorial on Business Application Programming Interface_____________________________ Programming BAPIs Use This section describes how to program the BAPI you defined in the previous sections. These are: Mandatory Rules • A BAPI must not contain any dialogs. • • • • Recommendations • Minimize interface complexity. It is not easy to formalize the functional scope of a BAPI. the BAPI must not return any R/3 screen dialogs to the calling application. display a list on the screen. such as the frequently used BAPIs. BAPIs must not produce any screen output. even those that perform similar functions. This is true for the BAPI itself and for any function module that may be indirectly called by the BAPI. as interfaces of SAP Business Objects. If required every BAPI must be able to carry out its own authorization checks. Every BAPI has a different functional content. for example. in other words. In other words. Because of this a BAPI should always select a range between A-Z. you must follow certain rules when programming BAPIs. Use the object/method model when choosing parameters and combining them in structures. select the most important parameters and combine them in structures in a meaningful way. Database changes can only be made through updates. The differences are mainly due to the different characteristics and contents of SAP Business Objects. Application servers might not support ASCII. Prerequisites To ensure that BAPIs. a-z and 0-9. but use a different character set instead. Set and Get parameters and the global memory must not be used to transfer values. If this is the case a problem may arise when you select quantities or ranges or when these are sorted.
• ' ' (no value) This means that the corresponding parameter field does not have to be updated. a Change BAPI must be able to identify fields that have been modified and fields that have stayed the same. For instance. The additional change parameter must contain exactly the same number of fields and the same field names as the parameter. You must use the data element BAPIUPDATE as the data element for the update fields. When the BAPI is called. Features Two different approaches can be used to identify fields containing values that have been modified in a Change BAPI: • • Flagging fields to identify those fields containing modified values Comparing fields to identify those fields containing modified values 1. must be marked with an update flag. one specific purchase order. the fields in the additional change parameter whose counterparts in the corresponding parameter contain modifications. • That way the BAPI can identify both modified and unmodified fields in the parameter. • _________ __________________________________________________________________ 31 . the name of the additional change parameter is EquiSalesX. This can have the following values: 'X' This value means that the corresponding parameter field contains a modified value. • An additional change parameter must be created with the same number of fields and the same field names for every parameter in the BAPI containing modified field values. Flagging Fields to Identify Those Fields Containing Modified Values In this approach parameter fields containing modified values are identified by a suitable flag in an additional "change parameter". Moreover. the additional change parameter must also be a table. As the Change BAPI can carry out changes to existing data. if the parameter is called EquiSales. Using an initial value is no solution because an initial value could also represent a valid new value. If the parameter is a table. for example. in the ABAP programming language or on other development platforms you cannot assign the value "null" to all data types in order to mark fields and thus indicate that the remaining fields contain update values.A Tutorial on Business Application Programming Interface_____________________________ Programming Change BAPIs Use The BAPI Change modifies an existing instance of a SAP Business Object. Follow the conventions below when you create change parameters to identify modified fields: • The name of the additional change parameter consists of the parameter name with the suffix "X".
This way any database changes made between the time the data was read and the time the database is updated can be identified. This data could be. The additional compare parameter must contain exactly the same fields and the same structure as the parameter. the name of the additional compare parameter is EquiSalesX. for example. 2. For instance. When the Change BAPI is called all relevant fields in the compare parameter must be filled with the data at the time the database is read. the result of a previous GetDetail BAPI call. The BAPI Change then overwrites the existing value in the field Distr_Chan with the current value in the field Distr_Chan in the parameter EquiSales. The program objects in the R/3 System affected by this change are: Program Object SAP Business Object BAPI Parameter Fields in parameter EquiSales Name PieceOfEquipment Change EquiSales SalesOrg='abcd' Distr_Chan='US' Division='efgh' EquiSalesX SalesOrg=' ' Distr_Chan='X' Division=' ' Change parameter that identifies modified fields Fields in parameter EquiSalesX In the parameter EquiSalesX the value in the field Distr_Chan is 'X'. Then. • When you create compare parameters follow these conventions: • The name of the additional compare parameter consists of the parameter name with the suffix "X". if the parameter is called EquiSales. If data in any field is different then the field contains data that must be changed. Comparing Fields to Identify Those Fields Containing Modified Values In this approach parameter fields containing modified values are identified by comparing them with the fields in an additional "compare parameter": • • An additional compare parameter must be created with the same structure for each BAPI parameter containing update values. the data in the compare parameter can be compared field by field with the data in the corresponding parameter. This indicates that the field Distr_Chan of the parameter EquiSales contains a modified value. • _________ __________________________________________________________________ 32 .A Tutorial on Business Application Programming Interface_____________________________ Example A Change BAPI is used to change the value of the existing distribution channel (Distr_Chan) to Distr_Chan="US". • The data in the compare parameter can first be checked against the current database contents to ascertain whether it has changed in the meantime. The fields of the corresponding parameter may contain modified values.
Approach 2: Better for dialog-orientated applications with critical data. Programming Check facilities Comprehension Application _________ __________________________________________________________________ 33 . less demands are placed on caller.A Tutorial on Business Application Programming Interface_____________________________ Advantages of Both Approaches The advantages of each approach are shown in the table below: Area Performance Advantage Approach 1: Flag table can be compressed. Approach 2: BAPI programming is simpler. Approach 1: Fields containing modifications can be flagged. Approach 2: Can carry out check against current database to identify and prevent inconsistencies. Approach 1: Better for performance critical applications. that means. Compare data does not have to be read.
• Using subscription lists ("Push") System "B" maintains a list of systems requiring clones. You can specify whether the replication is carried out immediately or at a later time and in a separate step. You can also add other import parameters. The interface of these BAPIs depends on the characteristics and contents of the business object that is to be cloned. This method must be implemented for each business object to be cloned. depending on the specific requirements of your BAPI: • Clone The BAPI Clone is used by a system to replicate one business object on another system or to modify one business object that has already been cloned. All the data required for cloning an individual business object must be provided in the import parameters. At regular intervals system "B" replicates the business objects on all the systems in the list. material with or without plant data). The cloned business objects are created under the same object key. You should decide to implement one of these BAPIs. Moreover. to request all the materials belonging to a material group or to delimit the amount of data in the business object to be cloned (for example. Then system "B" replicates the requested business objects on system "A". For this reason these BAPIs must be implemented for each business object. If only parts of an object are to be cloned rather than the whole object. at least one of the BAPIs below must be implemented for each business object to be cloned. Features Both of the above cloning methods can be implemented with the following BAPIs: • Replicate A client system uses the Replicate BAPI to request clones of business objects from a server system.A Tutorial on Business Application Programming Interface_____________________________ Programming Replicate/Clone BAPIs Use To replicate a business object you can implement Replicate/Clone BAPIs. _________ __________________________________________________________________ 34 . The actual replication is carried out when the server system invokes one of the Clone BAPIs described below on the client system. The BAPI Replicate requests the replication of a business object. for example. You can do this by using a range table for the key fields of the business object. The BAPI's import parameters have to identify the business objects to be cloned. Each Clone BAPI must contain the import parameter Sender which identifies the system that sends or owns the business object. The objective of replication is to make specific instances of a business object available on one or more additional systems. Business objects can be cloned in two ways: • By request ("Pull") System "A" requests clones from system "B". depending on what is most practical for the business object. Only create the Parameter RETURN as an export parameter. Each Replicate BAPI must contain the parameter CloneReceivers which specifies the systems on which the business objects are to be replicated. you can use other optional import parameters. Only create the Parameter RETURN as an export parameter.
Only create the Parameter RETURN as an export parameter. • CloneMultiple The BAPI CloneMultiple is used by a system to replicate several business objects on another system or to modify several business objects that have already been cloned. Each CloneMultiple BAPI must contain the import parameter Sender which identifies the system that sends or owns the business objects. the BAPI CloneMultiple can clone or modify several instances of an object at the same time. it does require a far more complex interface and error handling process. Unlike the BAPI Clone. This BAPI should be used for objects with small amounts of data. Although the BAPI CloneMultiple is more efficient than the BAPI Clone.A Tutorial on Business Application Programming Interface_____________________________ This BAPI should be used for more complex objects that will not be cloned in large numbers. All the relevant data for cloning several business objects must be provided in the import parameters. _________ __________________________________________________________________ 35 . you can use other optional import parameters. If only parts of objects are to be cloned rather than whole objects.
MATNR Application specific. Data element BAPISIGN Compare operator. e.GetList. CP (contains pattern) or BAPIOPTION NP (does not contain pattern) Lower limit of value range Upper limit of value range Application specific. BAPI CustomerCode. Prerequisites To enable the use of selection criteria you have to create the relevant selection parameters of the BAPI as a structure or table with the following fields: Fields for Value Ranges Field Name SIGN OPTION LOW HIGH Description Selection operator that determines whether the range specified is to be included or excluded.g.A Tutorial on Business Application Programming Interface_____________________________ Programming Value Ranges Use The parameters in BAPIs that can be used to search for specific instances of a business object. for example.g.g. MATNR You can use the function module BALW_RANGES_CHECK to check the values entered in SIGN and OPTION. e. have to enable BAPI users to specify appropriate selection criteria. e. _________ __________________________________________________________________ 36 .
Exceptions Because of the reasons above. where YYYY is the year. _________ __________________________________________________________________ 37 . YYYYMMDD. BAPIs should only carry out data conversions between the data format used in the database and external formats used by the calling program in exceptional circumstances. not application interfaces. should not be used in the BAPI interface in any other format than the format used in the database. you can use the transaction described in Converting Between Internal and External Data Formats. i. even though currencies do exist with three digits after the decimal point. the data type CURR cannot be used in the BAPI interface. Fields such as a date field.A Tutorial on Business Application Programming Interface_____________________________ Internal and External Data Formats Use BAPIs are programming interfaces used in the most diverse application areas. These exceptions are: • Currency amount fields In an R/3 System a currency amount field is only useful when a currency code accompanies it. so that the decimal point in the amounts can be set correctly. • Internal keys In some situations an internal technical key is maintained in the database alongside the external key. a field for the currency code must be assigned to each currency amount field. if two Yen are stored in the field of data type CURR as 0. To meet the requirements of this diverse range of applications. For example. In particular. A unit of measure field must be assigned to every quantity field.e. The function module BAPI_CURRENCY_CONV_TO_INTERNAL converts currency amounts from external data formats into internal data formats. These exceptions are listed below. Examples are work breakdown structure plans or networks in project systems. All R/3 currency data types have two digits after the decimal point. For these reasons. a shared strategy for representing data in the BAPI interface must be used. To convert data formats in these exceptional circumstances. a non-SAP system cannot reasonably be expected to understand these semantics. for instance. Quantity fields have no general domain that can be used for BAPI structures. MM the month and DD the day. The function module BAPI_CURRENCY_CONV_TO_EXTERNAL converts currency amounts from R/3 internal data formats into external data formats. Accordingly. • Quantity fields Like currency amount fields. BAPIs are programming interfaces. the decimal point in quantity fields must be converted correctly. to connect non-SAP systems or PC products to the R/3 System.02. Adhere to the following guidelines when using currency amount fields in BAPIs: You must not use parameters and fields of data type CURR in the interface All parameters and fields for currency amounts must use the domain BAPICURR The position of the decimal point in currency amount fields must be converted correctly You can use two function modules for this conversion. the use of values that affect Customizing or are language dependent must be avoided.
The following conversion BAPIs exist for this purpose. However. For example. no conversion takes place and the values are returned unconverted. to display data on the screen.A Tutorial on Business Application Programming Interface_____________________________ You must always use the external key in the BAPI interface. and unit of measure fields.DataConversionInt2Ext This BAPI converts the internal data format into the required external data format. BapiService. If this is not the case. In such cases the calling program must be able to convert between the internal and external data formats. with a few exceptions. BAPIs for Converting Between Internal and External Data Formats (Converting Domains) BAPIs are programming interfaces in which. Implement the BAPI as follows: When you export data from the BAPI both fields must contain corresponding values. Use the domains below for the ISO codes: Domains for SAP internal codes and ISO codes Size Currency key Unit of measure Language key Country key ISO Code Domain isocd isocd_unit laiso intca SAP Code Domain waers meins spras land1 For every domain there is a data element of the same name. Use the naming convention. _________ __________________________________________________________________ 38 . country. application programmers calling a BAPI from within their program may sometimes require the external format. • ISO codes In R/3 Systems ISO codes are currently supported for language. Fieldname_for_SAPCode_ISO for the field containing the ISO code. If you use one or more of these fields in your BAPI you have to make two fields available for each of these fields in the BAPI interface: one field containing the SAP code and another containing its corresponding ISO code. When you import data into the BAPI the ISO code is only significant if no value was given in the SAP code. the field LANGU contains the country codes used internally in R/3.DataConversionExt2Int This BAPI converts the external data format into the required internal data format. The corresponding field for the ISO code would then be named LANGU_ISO and would contain the corresponding ISO code EN. for instance E. for example. currency. The calling program uses them to obtain the required data formats: • • BapiService. Conversion routines are maintained in the ABAP Dictionary for the domains on which the data to be converted are based. only the internal data format should be used.
A Tutorial on Business Application Programming Interface_____________________________ Reporting Errors Use A BAPI should be able to record and classify all possible errors that may occur. This is empty if no log used. or as a table parameter. _________ __________________________________________________________________ 39 . CODE CHAR 5 MESSAGE LOG_NO LOG_MSG_NO CHAR 220 CHAR 20 NUMC 6 Return Parameter from Release 4. Number of application log. In this Release the Return parameter is filled by the function module BALW_BAPIRETURN_GET. Structure of BAPIRETURN Field TYPE Type CHAR 1 Description S = success message E = error message W = warning message I = information message A = termination message (Abort) The first two characters are used for the message class and the remaining ones for the message number (key fields from table T100). Caution From Release 4. If the RETURN parameter is not set or is set to an initial value this means that an error has occurred.0 the return parameter must be based on one of the two reference structures described below.1 In Release 3. Features The structure of the parameter RETURN is dependent on the R/3 Release the BAPI is developed for. A general error message has to be sent for those error situations that cannot sufficiently be identified and distinguished. This parameter returns exception messages or success messages to the calling program. Before filling the RETURN parameter you should either initialize the structure with CLEAR or the table with REFRESH and CLEAR. All error messages or indeed any message that may be returned by the BAPI must be defined in table T100. This message can then be processed by the calling program in a different program branch. whose components are described in the table below. Full message text from table T100. Current number of message in application log.1 the Return parameter is based on the structure BAPIRETURN.0 onwards From Release 4.0 you must not use Exceptions in a BAPI interface. Return parameter in Release 3. The parameter RETURN can either be implemented as an export parameter and thus as a structure. You have to create a parameter named RETURN for every BAPI. All variables have been replaced with text.
It contains the following fields: Field TYPE Type CHAR 1 Description S = success message E = error message W = warning message I = information message A = termination message (abort) Message ID Message number Full message text from table T100. Both structures must be filled in the logon language. It contains the following fields: Field TYPE Type CHAR 1 Description S = success message E = error message W = warning message I = information message A = termination message (abort) Message ID Message number Full message text from table T100. ROW and FIELD in which error messages can be assigned to a specific field. it can identify the field containing this value in the returned error message using the additional fields in the structure BAPIRET2. This is empty if no log is used Current number of message in application log ID NUMBER MESSAGE LOG_NO CHAR 20 NUMC 3 CHAR 220 CHAR 20 LOG_MSG_NO • NUMC 6 BAPIRET2 This reference structure contains the additional fields PARAMETER. However. All variables have been replaced with text Number of application log. This is empty if no log is used Current number of message in application log ID NUMBER MESSAGE LOG_NO CHAR 20 NUMC 3 CHAR 220 CHAR 20 LOG_MSG_NO NUMC 6 _________ __________________________________________________________________ 40 . use only the first two characters of the message ID. if you want messages to be compatible with earlier R/3 Releases. All variables have been replaced with text Number of application log.A Tutorial on Business Application Programming Interface_____________________________ Both structures take into account the name space extension of the message ID made in Release 4. If a BAPI ascertains that an invalid value has been entered in a field. Only use this structure if you need the functionality of the additional fields to minimize the complexity of the parameter.0. The structure BAPIRET2 is filled via the function module BALW_BAPIRETURN_GET2. The two structures are: • BAPIRETURN1 This structure is filled via the function module BALW_BAPIRETURN_GET1.
A Tutorial on Business Application Programming Interface_____________________________ PARAMETER ROW CHAR 32 INT 4 Identifies the parameter containing the invalid value Identifies the line number of the data record containing the invalid value Identifies the field containing the invalid value FIELD CHAR 30 Application Log and Application Error Tables If the information provided in the Return parameter is not sufficient. The logging should be done by the BAPI itself so that function modules called directly by this BAPI do not have to be modified. The use of the application log and/or error tables is optional. _________ __________________________________________________________________ 41 . the calling application can define its own additional error tables. you can log errors with the application log. for example. There are no set guidelines for these additional tables. The calling program then has immediate control over the contents of the error table and does not have to first search for error messages. If this still does not provide enough information. if there are error messages (type E) in the table. The Return parameter in your BAPI could give details of the messages in the error tables.
matchcodes or domain fixed values linked to the field in the ABAP Dictionary. This table comprises the following fields which you have to fill with the corresponding entries of your BAPI.A Tutorial on Business Application Programming Interface_____________________________ Providing Input Help (F4 Help) Use Users of an R/3 System can use the F4 key to obtain information about the possible input values for a certain field on the screen. This is necessary because the HelpValues. for example. you must create or specify the appropriate check table.GetList method is available in the documentation for the function module BAPI_HELPVALUES_GET. For example. This function module must have the following predefined interface: _________ __________________________________________________________________ 42 .GetList method to obtain the valid input values for a field in your BAPI and return them to the calling program. For information about check tables. To do this you can carry out authorization checks within your BAPI: Table BAPIF4T is provided for this purpose. matchcodes or domain fixed values for that field in the field's reference structure. Authorization Check In some situations it will be necessary to only allow those persons with a particular user profile to access to information in F4 possible entries. matchcodes or domain fixed values in the reference structure of a field in order to enable a calling program to access the valid input values for the field. DTEL (data element) The name of a data element for which a possible entry is specified. Detailed information about the structure and use of the HelpValues. an elementary input help could be specified for the data element PERNR_D and be protected from unauthorized access. Features In order to enable the HelpValues. • • • OBJTYPE (object type) The technical name of the SAP Business Object. GetList.GetList. you should therefore specify the appropriate check table. a calling program can use the method HelpValues. the user of a Visual Basic program which incorporates a BAPI to display or modify data in R/3 should have transparent access to the functionality of the F4 input help. for example. In order to provide input help for a field. METHOD (verb) The name of a BAPI for the Business Object named above. which obtains the possible input values for a field that is passed in a BAPI call. For example.GetList method refers to the help view for the check table. via BAPI calls. Note Whenever possible. Information about the possible input values for a field should also be available to those users who are working with the data in the R/3 System from an external program. • FNAM (name of function module) The name of the function module you have to create and that carries out the authorization check for the data element. matchcodes and domain fixed values see the ABAP Dictionary. BUS1065. This method is based on the RFC-capable function module BAPI_HELPVALUES_GET.
FNAM OBJTYPE. During runtime the function module is called dynamically by the BAPI HelpValues. FNAM _________ __________________________________________________________________ 43 . Copy this function module and follow the documentation provided with it. ' ' (no value) if the user of the BAPI is authorized to display the input values for a field.the following fields in table BAPIF4T must level. method or data element level: To carry out authorization check at this .. DTEL. The additional parameter SHLPNAME contained in the function module interface provides the name of the active input help for the table or for the data element. METHOD.GetList. be filled. Business Object BAPI Data element OBJTYPE.A Tutorial on Business Application Programming Interface_____________________________ *"------------------------------------------------------*"*"Local interface: *" IMPORTING *" VALUE(OBJTYPE) LIKE BAPIF4F-OBJTYPE *" VALUE(METHOD) LIKE BAPIF4F-METHOD *" VALUE(DTEL) LIKE BAPIF4F-DTEL *" VALUE(SHLPNAME) LIKE BAPIF4F-SHLPNAME *" VALUE(TABNAME) LIKE BAPIF4F-TABNAME *" EXPORTING *" VALUE(RETURN) LIKE BAPIF4F-RETURN *"--------------------------------------------------------- As the template for your function module you can use the function module BF_BAPI_F4_AUTHORITY which provides exactly this interface. An authorization check can be carried out at Business Object.. The parameter TABNAME contains the name of the value table. FNAM OBJTYPE.. The return code of the parameter RETURN is: 'X' if the user of the BAPI is not authorized to call up the valid input values for a field.. METHOD.
running a statistic on plant level will have a negative impact on the performance of the BAPI. on a Visual Basic platform. or your BAPI could return a message to the calling programm indicating that the amount of data has exceeded a certain limit and that a new selection should be made. The less specific the key of a modified data record is. causing the record to be locked. whereas a statistic based on plant and material will cause fewer locks because it will apply to fewer BAPIs. Additional guidelines for BAPI programming The function module on which a BAPI is based can be accessed by external programs via RFC. • • • • • • • • _________ __________________________________________________________________ 44 . you could specify a limit so that only the first n data records are read. Avoid unnecessary database access. In contrast. which use the SAPgui (graphical user interface) as a front end. For example. inserts do not lock the database. Do not define parallel processes. if possible. These read transactions have to wait for the commit work command of the update transaction to be processed. the majority of the data remains on the application server. the entire data is transferred to the client system from the application server. You need to cover the situation when your BAPI has to read mass data. you should follow these additional guidelines when programming BAPIs: • Large amounts of data Mass data is treated differently in ABAP programs. Ensure that you have chosen the correct order of the update modules. Note that you must not buffer data in the global memory. All tables that are not protected by SAP internal locks must always be updated in the same order to prevent a deadlock. lock only parts of a development object. Minimize the use of read transactions which depend on a previous database commit (committed read). For example. In contrast to updates. you should adhere to the general guidelines of ABAP programming. Make use of buffers when assigning numbers to reduce lock periods. for example in the local memory of the function module. for example a list containing many entries. Buffer data. For this reason. Try not to lock entire development objects.A Tutorial on Business Application Programming Interface_____________________________ Improving the Performance of your BAPI Use In order to improve the performance of your BAPI. Do make use of arrays. If large amounts of data are read in the R/3 System. Do not generate programs at runtime. resulting in a heavy network load and increased memory requirements on the part of the client system. such as: • • • • • • Use only complete WHERE conditions to minimize the amount of data to be transferred. Minimize the duration of database locks by making updates after inserts. You can reduce the duration of database locks and the risk of blocking other processes by making database updates as close as possible to the commit work command. the more likely it is that the data record will be accessed by multiple BAPIs. and in programs developed on external development platforms such as Visual Basic. Only the data that is actually displayed is sent to the front end.
Incompatible Interface Enhancements Changes to the contents or functionality of a BAPI often result in the introduction of new parameters without which the interface can no longer function. Incompatible interface enhancements are: • • • Changes to the field length Changes to the field type Inserting a field within a structure _________ __________________________________________________________________ 45 .A Tutorial on Business Application Programming Interface_____________________________ Enhancements to Existing BAPIs Purpose Application developers who are using BAPIs in their application programs must be able to rely on the fact that the BAPI's interface is not going to change. the compatibility of changes to the contents or functional scope of a BAPI can only be safeguarded by the person developing the BAPI. Whereas the compatibility of syntax changes is automatically checked by the ABAP Dictionary. if these are added to the end of a structure A field is considered to be optional if it can be left out completely in a BAPI call. Often. you need to ensure that any syntax changes or changes to the contents or functionality of the BAPI are upward and downward compatible. because they no longer enable the BAPI to be upward or downward compatible.GetList which can be used as an additional selection criteria for selecting sales orders in the R/3 System. • New optional fields. once a BAPI is released and frozen. or changes to the type or length of a domain. The BOR also provides version control for your BAPIs. that is. If you continue developing your BAPI after you have released and frozen it. You can differentiate between compatible and incompatible BAPI enhancements: Compatible Interface Enhancements Compatible interface enhancements are modifications to a BAPI which do not compromise the BAPI's upward or downward compatibility. Note Enhancements to BAPIs only take effect when you have defined the changes in the BOR. As a result of this. Example An additional input field for the applicant's educational background is added to the BAPI Applicant. it must fulfill certain requirements as to the stability of its interface. changes have been saved and generated. Examples of syntax changes are changes to parameter names. these changes also cause existing parameters to lose their original meaning. Compatible interface enhancements are: • New optional parameters A parameter is considered to be optional if it can be left out completely in a BAPI call. Applications which access the BAPI are not affected by compatible interface enhancements. Example A new parameter is added to the BAPI SalesOrder. Such modifications are considered to be incompatible.CreateFromData.
yet another BAPI. you should attempt to make compatible changes in order to limit the impact of your modifications on existing programs which use the BAPI. If additional incompatible modifications must be made to the BAPI at a later date. _________ __________________________________________________________________ 46 . Provide release notes during the entire retirement phase of the BAPI to inform your users about the changes. you must not make this change to the existing BAPI. must be created. in order to maintain the interface integrity of the existing BAPI SalesOrder. as described in this section. Position the cursor on the BAPI and select Edit → Change status to → Expired. This number can then be incremented should further enhancements become necessary. When adding a new import parameter. SalesOrder. Do not remove the original BAPI from the Business Object Repository (BOR) once it has been superseded by an additional BAPI. select the relevant SAP Business Object in the Business Object Builder and open the node Methods.CreateFromData. To implement these changes. SalesOrder. Instead. you first identify this BAPI as expired and continue its support in the release in which you have introduced the new BAPI as well as in the release subsequent to that. During this time the original BAPI must remain fully functional and executable. a new BAPI. create an additional BAPI (or more.CreateFromData. Otherwise you will have to make an incompatible interface enhancement. Instead. To do so. if required). If so. Example A number of incompatible changes must be made to the BAPI SalesOrder. document which method or methods are to be used as alternatives to the expiring BAPI. is created.CreateFromData2. • • In the BOR.CreateFromData1. the new parameter can be added as a compatible interface enhancement. Give the new BAPI the same name as the existing BAPI and add a number at the end of the name. consider whether the interface would function without the parameter. Procedure With Incompatible Interface Changes If it is necessary to make an incompatible change to your BAPI. The graphic below illustrates the expiry phase of a BAPI.A Tutorial on Business Application Programming Interface_____________________________ • • Deleting parameters and fields Adding new mandatory fields or mandatory parameters Process Flow When continuing the development of your BAPI. BAPI Expiry Phase The following tasks are required when a BAPI has expired: • Identify the status of the original BAPI as 'expired' in the BOR.
This prevents unintentional and erroneous modifications to BAPI structures. domains or structures that are being used by a BAPI that has been released are rejected by the ABAP Dictionary. domains or structures of a BAPI that has not been released are accepted by the ABAP Dictionary. _________ __________________________________________________________________ 47 . Compatible changes or changes to data elements.A Tutorial on Business Application Programming Interface_____________________________ Checks in the ABAP Dictionary Syntax changes to a BAPI are automatically checked against the ABAP Dictionary: • • Incompatible changes to data elements.
you should define your development as the method YGetList. The following sections describe how BAPIs can be adapted within the framework of each of these four ways. For this reason SAP recommends that. Process Flow There are four ways the standard R/3 System can be adapted to meet customer needs: Customizing. Customizing There are no special Customizing settings for BAPIs. You can also modify the BAPI source code but do follow the "Guidelines for Modifying the SAP Standard System".A Tutorial on Business Application Programming Interface_____________________________ Customer Modifications of BAPIs Purpose You can make enhancements or modifications to existing BAPIs. you could copy the function module BAPI_CUSTOMERCODE_GETLIST into Y_BAPI_CUSTOMERCODE_GETLIST. For example. Changes can be made. Keep in mind that an improved mechanism for making customer modifications of the SAP Standard System will be introduced in a later R/3 Release. enhancements. To do this: • Copy the function module the BAPI is based on into the customer name space. Creating a BAPI for a new Business Object You can create a subtype for an existing object type. For further information see also "Guidelines for Modifying the SAP Standard System" in SAPnet. Before you decide to modify an SAP BAPI familiarize yourself with the general procedure for making customer enhancements to the SAP standard system. however. When you have changed and tested the function module and its interface you can define it as a new method of the appropriate business object. See also Enhancements to Existing BAPIs. if you have modified the BAPI GetList of the Business Object CustomerCode. modifications and customers' own developments. in the ABAP Dictionary. Make the required changes to the new function module by changing the interface and the source code as required. as described in Defining Methods in the BOR Using the BOR/BAPI Wizard Make sure you give the method a name taken from the customer name space. Enhancements At present there are no customer exits or application-specific exits for BAPIs. for the time being you use one of the procedures described below to make modifications to a BAPI's source code so as not to change the SAP Standard System in the process: Creating a BAPI for an existing Business Object You can copy an existing BAPI and add it to an existing Business Object as a new BAPI. Modifications You can modify an existing BAPI interface provided that only new optional parameters are involved. This way all methods of the object are _________ __________________________________________________________________ 48 • • . For example. This section focuses specifically on customer enhancements and modifications of BAPIs rather than on customer enhancements in general. Refer to Enhancements to the SAP Standard. See also Enhancements to Existing BAPIs. New fields can be added at the end of a BAPI interface structure.
You can then make changes to the copied method. If you do. For example. This object type (subtype) acquires all methods of the existing object type. Follow the "Guidelines for Modifying the SAP Standard System" when creating other required development objects. _________ __________________________________________________________________ 49 . • Your Own Developments Using the information in these guidelines you can also create new methods for Business Objects.A Tutorial on Business Application Programming Interface_____________________________ inherited by the subtype. To do this: • Copy an existing Business Object type into the customer name space. You can now change the required BAPI of the Business Object YSalesOrder by creating a new function module for the BAPI and assigning it to the method using the BOR/BAPIWizard. this means the names must begin with X or Y. make sure that you have given your method in the BOR and the function module a name from the customer name space. you could copy the Business Object SalesOrder into YSalesOrder.
For further information on ALE technology and using BAPIs in the context of ALE see ALE Programming. Process Flow When a BAPI is used to exchange data asynchronously within the context of ALE the following processes are involved: • • • When the BAPI is called in the sending system. make sure that a BAPI of this type is actually required for the task in hand. This IDoc is dispatched to the target system. Additional Guidelines If you are sure you want to implement your BAPI as an asynchronous interface you should _________ __________________________________________________________________ 50 . the associated IDoc and the two function modules. In the target system another function module is used to call the BAPI with the data from the IDoc.A Tutorial on Business Application Programming Interface_____________________________ Implementing BAPIs in ALE Scenarios Purpose Since Release 3. Even if one of the systems fails. This transaction is described in detail in ALE Programming.0 ALE (Application Link Enabling) technology has enabled data to be exchanged between individual distributed SAP Systems and non-SAP systems. You can use a transaction to create the additional objects required for the BAPI in this process. Prerequisites Before you can implement a BAPI used to transfer data asynchronously in ALE. that is. Loose coupling A synchronous interface would constitute too narrow a coupling between the client and the server system. • Performance The interface is frequently used or it deals with large volumes of data. In distributed environments it is particularly important that the individual systems are loosely coupled together and are independent of each other. If the connection is interrupted the client system would not be able to function properly. Loose coupling means that the individual systems for the most part communicate asynchronously with each other. a function module fills the corresponding IDoc with the data from the BAPI call. For these reasons asynchronous messaging is used for data communication between the participating systems in ALE distribution scenarios. In this situation a synchronous interface cannot be used because performance would be too low.0 you can implement an asynchronous BAPI interface by generating an IDoc from the BAPI and using it in an appropriate ALE distribution scenario. or a communications link is interrupted. This section provides a general overview of points you should keep in mind when implementing a BAPI to exchange data asynchronously. If one of the following conditions applies then you should implement your BAPI as an asynchronous interface: • • Consistent database changes in both systems Data must be updated consistently on both the local system and on the remote system. the remaining systems must be able to continue to function. From Release 4.
If the field type is filled with E (error) or A (abort) in at least one of the transferred Return parameter entries. After the function module which converts the IDoc into the corresponding BAPI in the receiving system has been called. All BAPI export parameters with the exception of the Return parameter are ignored and are not included in the IDoc that is generated. The BAPI Return parameter must use the reference structure BAPIRETURN1 or BAPIRET2. _________ __________________________________________________________________ 51 .A Tutorial on Business Application Programming Interface_____________________________ keep in mind the following points in addition to the usual BAPI programming guidelines: • • • • The BAPI must not issue a Commit Work command. Otherwise status 53 is assigned (application document posted). the status 51 (application document has not been posted) is assigned to all the status records of the IDoc. status records are written for the IDoc in which messages sent in the Return parameter are logged.
Ensure that you answer "yes" to each item on the list. related BAPIs? Is the functionality to be implemented by the BAPI exclusively within the scope of the associated Business Object? Is the BAPI assigned to the appropriate SAP Business Object? Has there been a review of the BAPI concept and scenario? Defining the BAPI Have you identified the SAP Business Object in the Business Object Repository to which the BAPI will be added as a method? Have you identified the key fields of this Business Object? Have you defined the interface of the BAPI? Have you included the key fields of the SAP Business Object in the BAPI interface? Have you included a Return parameter? Have you identified the name of the function group or have you planned a _________ __________________________________________________________________ 52 . Print this checklist and use the printout during the entire implementation phase of your BAPI.A Tutorial on Business Application Programming Interface_____________________________ 1 23 BAPI Implementation Checklist This checklist summarizes the individual steps you need to complete when implementing a BAPI. BAPI Implementation Checklist OK? Task Defining the scenario in which the BAPI will be used Have you defined the scenario in which the BAPI is to be used? Have you identified the SAP Business Object involved? Have you defined the functional scope of the BAPI? Have you defined the relationship between the BAPI you are planning to implement and other.
0)? Defining the structures and fields of the function module parameters _________ __________________________________________________________________ 53 .e. i. IMPORTING and TABLES parameters? Have you included the key fields of the SAP Business Object as parameters of the function module (i. depending on whether the BAPI is instancedependent or instance-independent)? Have you assigned correct names to the parameters in the function module? Do the function module parameters for the Business Object's key fields have the same name as the key fields of the Business Object in the BOR? Is the name of each parameter in the function module a maximum of 20 characters in length? Are the names of the parameters in the function module in English? Have you avoided the use of abbreviations in the names of function module parameters? Did you ensure that none of the parameters in the function module is customizing-relevant or affects system settings in any other way? Is the interface independent of the current customizing settings of the system? Are all IMPORTING parameters independent from each other. using the format BAPI_<Business Object name>_<method name>? Defining the interface parameters in the function module Have you defined the function module interface using only EXPORTING. did you ensure that none of the parameters is derived from another? Have you defined the formats in which the values must be transferred in the function module interface? Are you using the Dictionary structure BAPIRETURN1 or BAPIRET2 for the Return parameter (as of Release 4.A Tutorial on Business Application Programming Interface_____________________________ name for a new function group to be created? Have you planned the name of the function module on which the BAPI is based.e.
by obtaining input help (F4 help). preferably those names that have been assigned to the corresponding data elements in the ABAP Dictionary? Can the user of your BAPI access the values for each import field either by referring to the documentation.GetList)? Defining the BAPI in the Business Object Repository Have you planned the name of the method in the BOR? Have you defined the names of the parameters in the BOR? Are the names of the parameters a maximum of 20 characters in length? Did you choose English names for the parameters? Are the names of the parameters of the method in the BOR and the names of the parameters in the function module the same? _________ __________________________________________________________________ 54 . LOW and HIGH for the corresponding BAPI parameter that selects values (for example. or by using a GetDetail BAPI? Have you used a structure with the fields SIGN. Material. OPTION.A Tutorial on Business Application Programming Interface_____________________________ Have you assigned a corresponding currency code field to each field with currency amounts? Have you assigned a field for the unit of measure to each quantity field? Have you defined Dictionary structures for each function module parameter? Do the names of the Dictionary structures start with BAPI? Are these structures independent of the structures used in the R/3 application? Have you defined the fields in the Dictionary structures? Have you defined Help views or fixed values for the fields in order to enable your BAPI to provide input help (F4 help) for each field? Are the field names a maximum of 10 characters in length? Have you used English names for the fields.
if required? Did you create the function module? Did you create the documentation for the BAPI in the Function Builder? Did you use the program to map between internal and external data formats? Did you write the program for your function module? Did you use the BOR/BAPI wizard to define the BAPI as a method in the BOR? Are the parameter names and types of the method in the BOR and of the function module in the Function Builder the same? Documentation Did you write appropriate documentation for the BAPI in the Function Builder? Is the documentation complete? Has the documentation been translated into the required languages? Testing the BAPI Did you test the function module using the test environment of the Function Builder? Did you test the BAPI using the test environment of the Business Object Builder? Did you test the BAPI by calling the method via the BAPI ActiveX Control? _________ __________________________________________________________________ 55 .A Tutorial on Business Application Programming Interface_____________________________ Did you ensure that there are no underscores in the parameter names? Did you start each new word in a method name with a capital letter? Creating the objects in the R/3 System Did you create the required Dictionary objects? Did you create the function group.
A Tutorial on Business Application Programming Interface_____________________________ Did you test the BAPI by making an RFC call to the underlying function module? Did you test the documentation for its completeness. correctness and availability in the required logon languages? Has the BAPI been released and frozen? _________ __________________________________________________________________ 56 .
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.