• No results found

BAPI Programming

N/A
N/A
Protected

Academic year: 2021

Share "BAPI Programming"

Copied!
169
0
0

Loading.... (view fulltext now)

Full text

(1)

BAPI Programming

HEL P .CABF A BAPI R EF

R e l e a s e 4 . 6 B

(2)

Copyright

© Copyright 2000 SAP AG. All rights reserved.

No part of this brochure may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

Microsoft®, WINDOWS®, NT®, EXCEL®, Word® and SQL Server® are registered trademarks of

Microsoft Corporation.

IBM®, DB2®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®, AS/400®, OS/390®, and OS/400® are registered trademarks of IBM Corporation.

ORACLE® is a registered trademark of ORACLE Corporation, California, USA.

INFORMIX®-OnLine for SAP and Informix® Dynamic ServerTM are registered trademarks of Informix Software Incorporated.

UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of The Open Group.

HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Laboratory for Computer Science NE43-358, Massachusetts Institute of Technology, 545 Technology Square, Cambridge, MA 02139.

JAVA® is a registered trademark of Sun Microsystems, Inc. , 901 San Antonio Road, Palo Alto, CA 94303 USA.

JAVASCRIPT® is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.

SAP, SAP Logo, mySAP.com, mySAP.com Marketplace, mySAP.com Workplace, mySAP.com Business Scenarios, mySAP.com Application Hosting, WebFlow, R/2, R/3, RIVA, ABAP, SAP Business Workflow, SAP EarlyWatch, SAP ArchiveLink, BAPI, SAPPHIRE, Management Cockpit, SEM, are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other products mentioned are trademarks or registered trademarks of their respective companies.

(3)

Icons

Icon Meaning Caution Example Note Recommendation Syntax Tip

(4)

Contents

BAPI Programming ...6

BAPI Programming Guide... 7

BAPIs ... 9

BOR ... 11

Terminology ... 13

Further Documentation on BAPIs... 14

Defining and Implementing the BAPI ... 15

BAPI Explorer... 17

Working with Display Functions ... 18

Working with Tools and Projects ... 20

Defining the Scenario... 21

Reviewing the Scenario Concept... 23

Defining a BAPI and Its Interface ... 24

Standardized BAPIs ... 26

Standardized Parameters... 29

Determining the Object Type and Its Key Fields... 31

Defining the Interface Structure of the BAPI ... 32

Naming Parameters in the Function Module ... 34

Defining Data Formats... 36

Specifying Development Objects in ABAP Dictionary... 37

Naming the Method in the BOR ... 40

Naming Parameters in the BOR... 41

Naming the Function Module and the Function Module Group... 43

BAPIs Used for Outbound Processing ... 45

Creating Development Objects and Documentation ... 46

BAPI Interface and Function Module... 48

Testing the BAPI and Its Documentation ... 52

Releasing the BAPI... 53

General Programming Guidelines for BAPIs ... 54

Transaction Model for Developing BAPIs ... 58

BAPI Transaction Model with Commit... 60

BAPI Transaction Model Without Commit... 63

Customer Enhancement Concept for BAPIs ... 65

Internal and External Data Formats ... 69

Providing Input Help (F4 Help) ... 73

Providing Interface Descriptions ... 75

Buffering with Write BAPIs ... 77

Example of Implementation and Process Flow ... 83

Improving Performance ... 86

Documentation Guidelines ... 88

Programming Standardized BAPIs ... 90

(5)

Example of a GetDetail() BAPI... 94

Programming GetStatus() BAPIs ... 96

Example of a GetStatus() BAPI... 97

Programming ExistenceCheck() BAPIs... 98

Example of an ExistenceCheck() BAPI ... 100

Programming Create() BAPIs ... 102

Example of a Create() BAPI ... 104

Programming Change() BAPIs ... 106

Example of a Change () BAPI ... 108

Programming Delete() BAPIs... 110

Example of a Delete() BAPI... 112

Programming Cancel() BAPIs... 113

Example of a Cancel() BAPI... 114

Programming Replicate()/SaveReplica() BAPIs... 115

Example of a SaveReplica() BAPI... 118

Programming Methods for Sub-Objects ... 120

Programming Standardized Parameters ... 122

Address Parameters... 123

Change Parameters ... 125

Extension Parameters ... 129

Return Parameters (Error Handling)... 130

Selection Parameters ... 134

TestRun Parameters... 135

Text Transfer Parameters ... 136

Tools for Developing BAPIs ... 137

Defining Methods in the BOR Using BOR/BAPI Wizard ... 138

Converting Internal and External Data Formats... 140

Application Example ... 142

SAP Enhancements to Released BAPIs... 144

Compatible Enhancements... 146

Incompatible Enhancements... 148

Customer Modifications and Developments... 151

BAPI Modifications ... 152

Creating Subtypes ... 156

Redefining BAPIs ... 157

Defining Delegation Relationships ... 158

BAPI Development... 159

Creating Subtypes ... 160

Namespaces... 161

Using BAPIs in Distributed Systems (ALE) ... 164

(6)

BAPI Programming

(7)

BAPI Programming Guide

BAPI Programming Guide

Purpose

This document describes the SAP guidelines for developing and implementing Business

Application Programming Interfaces [Page 9] (BAPIs). It is targeted at SAP developers and SAP partners who want to implement BAPIs.

Customers are also recommended to follow these guidelines when developing BAPIs. All developments should be done in the customer name space; all changes to existing developments objects of the SAP standard are considered to be modifications. (See

Namespaces [Page 161]).

As these guidelines are targeted for internal use at SAP, procedures or tools may be mentioned that do not apply or are not available to customers. Information that applies internally to SAP is indicated.

This document describes the guidelines valid at the time this document was published.

Prerequisites

To program and implement a BAPI with these guidelines you need to have: •••• Basic knowledge of BAPIs, as described in the BAPI User Guide [Ext.]

•••• Knowledge of the ABAP programming language and ABAP Workbench •••• Basic knowledge of the R/3 System

Process Flow

To implement a BAPI follow the processes described in the sections below as closely as possible:

Defining and Implementing the BAPI [Page 15]

Creating Development Objects and Documentation [Page 46] General Programming Guidelines for BAPIs [Page 54]

Testing the BAPI and Its Documentation [Page 52] Releasing the BAPI [Page 53]

Programming Standardized BAPIs [Page 90] Programming Standardized Parameters [Page 122] SAP Enhancements to Existing BAPIs [Page 144]

.

(8)

BAPI Programming Guide

document the development of your BAPIs. For SAP internal development it is obligatory to use a project form.

The BAPI Quality Checklist [Page 166] from earlier releases is still provided at the end of this document.

Other topics related to developing BAPIs are:

Modifications and Customers’ Own Developments [Page 151] Using BAPIs in Distributed Systems (ALE) [Page 164]

(9)

BAPIs

BAPIs

Definition

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 of SAP Business Object Types

BAPIs are defined as API methods of SAP business object types. These business object types and their BAPIs are described and stored in the Business Object Repository [Page 11] (BOR). A BAPI is implemented as a function module, that is stored and described in the Function Builder.

BAPIs of SAP Interface Types

As of Release 4.5A BAPIs can also describe interfaces, implemented outside the R/3 System that can be called in external systems by R/3 Systems. These BAPIs are known as BAPIs used

for outbound processing. The target system is determined for the BAPI call in the distribution

model of Application Link Enabling (ALE).

BAPIs used for outbound processing are defined in the Business Object Repository (BOR) as API methods of SAP Interface Types. Functions implemented outside the R/3 System can be standardized and made available as BAPIs. For further information see BAPIs Used For Outbound Processing [Page 45].

Integration

BAPIs can be called within the R/3 System from external application systems and other programs. BAPIs are the communication standard for business applications. BAPI interface technology forms the basis for the following developments:

• Connecting:

• New R/3 components, for example, Advanced Planner and Optimizer (APO) and Business Information Warehouse (BW).

• Non-SAP software • Legacy systems

• Isolating components within the R/3 System in the context of Business Framework • Distributed R/3 scenarios with asynchronous connections using Application Link

Enabling (ALE)

• Connecting R/3 Systems to the Internet using Internet Application Components (IACs) • PC programs as frontends to the R/3 System, for example, Visual Basic (Microsoft) or

Visual Age for Java (IBM).

• Workflow applications that extend beyond system boundaries • Customers' and partners' own developments

The graphic below shows how BAPI interfaces enable different types of applications to be linked together.

(10)

BAPIs

BAPIs - Interfaces to the R/3 System

Business Workflow R/3 satellite systems /

distributed systems (ALE)

Internet / Intranet

Customers and partners‘ own developments

VisualBasic/JAVA...

Isolating components in the Business Framework (R/3, R/2)

B

Business

Component ComponentBusiness

Business Component Business Object BAPI BAPI Business Object BAPI BAPI Business Object BAPI BAPI Business Object BAPI BAPI BAPI BAPI BAPI BAPI Business Object BAPI BAPI Business-Object BAPI BAPI

(11)

BOR

BOR

Definition

The Business Object Repository (BOR) is the object-oriented repository in the R/3 System. It contains the SAP business object types and SAP interface types as well as their components, such as methods, attributes and events.

BAPIs are defined as methods of SAP business object types (or SAP interface types) in the BOR. Thus defined, the BAPIs become standard with full stability guarantees as regards their content and interface.

For general information on creating business objects see the documentation on SAP Business Workflow [Ext.].

Use

The BOR has the following functions for SAP business object types and their BAPIs: • 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.

This finds the functionality searched for 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.

Integration

A BAPI is implemented as a function module, that is stored and described in the Function Builder. You should only define a BAPI as a method of an SAP business object type in the BOR, if the function module that the BAPI is based on has been fully implemented.

Access to the BOR is restricted at SAP.

BOR/BAPI Wizard

(12)
(13)

Terminology

Terminology

Definition

The table below contains definitions of the terms used in this document:

Term/Synonym Definition

Object type

Business object type SAP business object type

Generic definition of business objects. Describes the general characteristics and common attributes of instances of SAP business object types.

Business object

Business object instance SAP business object instance

One instance of an SAP business object type

BOR

Business Object Repository

Central repository within the R/3 System containing all the business object types and SAP interface types together with their definitions and methods.

BAPI

Business Application Programming Interface

Standardized programming interface enabling external

applications to access business processes and data in the R/3 System.

BAPIs are defined in the BOR as methods of SAP business object types that carry out specific business functions.

BAPIs are implemented as RFC-enabled function modules and are created in the Function Builder of the ABAP Workbench. Interface type

SAP interface type

Definitions of attributes, methods and events grouped together in one context.

An object type can support one or more interface types. The functional group of associated attributes, methods and events defined for the interface type together with their interfaces are used by the object type and are inherited by the respective subtypes of the object.

(14)

Further Documentation on BAPIs

Further Documentation on BAPIs

In the Open BAPI Network under the URL www.sap.com/bapi application developers can view the latest information on BAPI developments undertaken by SAP and by partners.

The following R/3 documentation contains further information about developing BAPIs and developing with BAPIs:

Document

BAPI User Guide [Ext.] Information about using BAPIs in application programs.

BAPI Programming Guide

[Page 7] Describes how BAPIs are developed in SAP and whatguidelines you have to follow. This document can also be used by customers and partners, who want to develop their own BAPIs, or enhance SAP BAPIs.

ALE Programming Guide [Ext.] Information about ALE technology (Application Link Enabling), including guidelines on using and programming BAPIs

implemented in ALE distributed environments.

Library of ALE Business Processes [Ext.]

Overview of ALE business processes (application scenarios of Application Link Enabling). ALE business processes delivered in the standard system are preconfigured and include important application examples of the distribution of business functions and processes.

BAPI ActiveX Control [Ext.] Describes how external client applications can use SAP’s BAPI ActiveX Control to access SAP business objects.

Calling BAPIs with BAPI Control [Ext.] in the

Tutorial: Communication Interfaces [Ext.]

Describes how business objects are called from the R/3 System using SAP’s BAPI ActiveX Controls and how the data is displayed using Table View Controls

SAP Automation RFC and BAPI Interfaces [Ext.]

Describes how C++ and Java class libraries are used to access BAPIs on C++ and Java platforms.

R/3 DCOM Component

Connector [Ext.] Describes how the R/3 DCOM Component Connectordeveloped jointly by SAP and Microsoft is used to integrate R/3 objects and COM objects seamlessly. SAP business objects and their BAPIs can be called directly from COM-based development tools. COM components are also provided in the SAP development environment.

The R/3 DCOM Component Connector SDK is shipped as part of RFC SDK for Windows NT.

(15)

Defining and Implementing the BAPI

Defining and Implementing the BAPI

Purpose

Various components of the ABAP Workbench are used when you define and implement a BAPI. These are shown in the graphic below.

BAPIs are defined in the Business Object Repository (BOR) as API methods of SAP business object types. BAPIs are implemented in the Function Builder as RFC-enabled function modules. The definitions and descriptions of the data structures used by the BAPI are stored in the ABAP Dictionary.

BOR, Function Builder and ABAP Dictionary

Business Object Repository

Business Object BO:

Method 1 = M1 Method 2 = M2 ABAP Workbench Function Builder Function module BAPI_BO_M2 Function module BAPI_BO_M1 Definition and description of data structures ABAP Dictionary

Prerequisites

For function modules that implement BAPIs, certain standards and rules must be adhered to over and above the standard programming rules for function modules.

The following sections guide you through the steps involved in developing a BAPI. The sections contain information about the guidelines and conventions that you should adhere to when defining and implementing a BAPI. When implementing BAPIs follow the requirements below to ensure you achieve consistent behavior and representation of BAPIs as object-oriented methods of SAP business object types or SAP interface types.

(16)

Defining and Implementing the BAPI

Process Flow

The development of a BAPI is divided into the steps below (see also the appropriate project template in the BAPI Explorer [Page 17] or the BAPI Quality Checklist [Page 166]):

Task For further information see:

1. Defining the scenario in which the BAPI will be used

Defining the Scenario [Page 21]

2. Reviewing the BAPI scenario and how the

BAPIs interact with one another Reviewing the Scenario Concept [Page 23] 3. Defining a BAPI and Its Interface Defining the BAPI and Its Interface [Page 24]

4. Creating individual programming objects Creating Development Objects and Documentation [Page 46]

5. Programming BAPIs General Programming Guidelines for BAPIs [Page 54]

6. Testing the BAPI and its documentation Testing the BAPI and Its Documentation [Page 52]

7. Releasing the BAPI Releasing the BAPI [Page 53]

8. Enhancing existing BAPIs, if required SAP Enhancements to Existing BAPIs [Page 144]

(17)

BAPI Explorer

BAPI Explorer

Definition

The BAPI Explorer is the R/3 System working environment for developing BAPIs themselves and for developing with BAPIs.

Use

Prerequisites

The BAPI Explorer is available as of Release 4.6A and enhances or replaces the BAPI Browser used in earlier releases. The BAPI Explorer uses the latest HTML control technology. For this reason to work with the BAPI Explorer, you must be using a SAPgui of version 4.6A.

If you are using a SAPgui from an earlier release, the BAPI Browser (Transaction BAPI45) is automatically called instead of the BAPI Explorer. For information about working in the BAPI Browser see BAPI Browser [Ext.] in the BAPI User Guide.

Purpose

In the BAPI Explorer, application developers can get an overview of the status of BAPIs in the BOR. The BAPIs can be determined either by the position of the associated obect or interface type in the component hierarchy in the BOR, or from an alphabetical list. All information required to use a particular BAPI is provided in the BAPI Explorer.

The BAPI Explorer is used internally in SAP to develop BAPIs, but can also be used by

customers and partners. The BAPI Explorer provides all the tools used to create BAPIs and the required development objects in an integrated programming environment. The entire

development process of a BAPI takes place in the framework of form-controlled "projects" to achieve maximum quality, stability and usability of the BAPI.

Structure

The BAPI Explorer is divided into two areas: •••• Hierarchy display

Here all the business object types or interface types for which BAPIs have been defined are displayed. For further information see Working with Display Functions [Page 18]. •••• Work area

Here the details and documentation of the development object selected in the hierarchy display can be viewed.

The tools used to develop BAPIs are also available in the work area. For further information see Working with Tools and Projects [Page 20].

Integration

To call the BAPI Explorer choose Tools → Business Framework → BAPI Explorer. To call it directly use Transaction BAPI.

(18)

Working with Display Functions

Working with Display Functions

Use

In the hierarchy display of the BAPI Explorer all the business object types or interface types for which BAPIs have been defined are displayed.

Using the tabs Alphabetical and Hierarchical in the hierarchy display, you can select whether the business object types or interface types are displayed alphabetically or as they are assigned in the component hierarchy in the BOR.

By expanding the relevant nodes you can navigate up to the parameter level of individual BAPIs.

Features

The following display functions are also provided which enable you to directly access BAPIs and their details in the BOR.

•••• Displaying details

Under the Detail view of the work area all the technical details of the development object selected in the hierarchy are displayed.

In most cases you can double-click on a field in the Detail display to get to the

developent environmnt or to display further information. For example, in the detail display for a particular method, by double clicking on the name of the function module, it will be displayed in the Function Builder.

•••• Displaying and Printing Documentation

In the Documentation view of the work area the documentation for the development object selected in the hierarchy is displayed.

The data element documentation for each parameter field is contained in the documentation for structured BAPI parameters.

If you have installed Microsoft Internet Explorer Version 4.0 on the front-end computer, you can print the documentation using the standard SAPgui print function.

•••• Changing the level of the hierarchy display

The component hierarchy may have many hierarchy levels. To make it easier to find a business object type and its BAPIs, you can use the function Goto → Change hierarchy

level to limit the display to two hierarchy levels.

•••• Specifying the BAPIs to be displayed

The default is to display only released BAPIs of business object types. By choosing Goto → BAPIs to display, you can display all the BAPIs contained in the BOR, that is BAPIs of SAP interface types and BAPIs that have not yet been released.

Business object types and interface types are identified by different symbols. To display these, choose Goto → Display legend.

•••• Searching for BAPIs

(19)

Working with Display Functions

− Object name, e.g. BusinessProcess

− Object type (technical object name) e.g. SAP0001 − Object description, e.g. Plan*

− Method name, e.g. GetList

(20)

Working with Tools and Projects

Working with Tools and Projects

Use

The views Tools and Projects in the work area are mainly used for developing BAPIs.

Features

Depending on the development object selected in the hierarchy display, in the Tools view, the following tools and navigation options are provided:

•••• Direct access to the Business Object Builder, Function Builder and ABAP Dictionary. •••• List generator to create lists of BAPIs using specified selection criteria.

In the Project view you can create projects to assist you with following and documenting the development procedures below:

•••• Implementing new BAPIs (for internal SAP use, BAPI developments must be carried out and documented using a project in the BAPI Explorer)

•••• Changing released BAPIs (only for SAP internal use)

•••• Requesting a new business object type (only for SAP internal use)

For each of these projects there is a project form that takes you step by step through the entire development process and provides direct navigation options to the required development tools and information.

Within the project management you can save and delete your projects and you can edit the projects managed by other users by selecting Other users.

If you have installed Microsoft Internet Explorer Version 4.0 on the front-end computer, you can print the project form using the standard SAPgui print function.

(21)

Defining the Scenario

Defining the Scenario

Purpose

Before you program a BAPI you should clearly define the processes and situations the BAPI will be used for. BAPIs should only be implemented within the context of a meaningful business scenario.

For examples of BAPI scenarios refer to Overview of ALE Integration Scenarios [Ext.] in the Library of ALE Business Processes. SAP developers will also find templates for defining and documenting BAPI scenarios.

Process Flow

To define the scenario the BAPI is to be used in, 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.

Keep in mind whilst you are planning the scenario that COMMIT WORK commands must not be used in BAPIs. COMMIT WORK commands can adversely effect the process flow of the scenario and how the BAPIs in the scenario work together.=

•••• Which SAP business object types are required and do they exist?

From the scenario definition you can get information about the SAP business object types relevant to the BAPI scenario. If the business object types required do not exist, they must be created. For information about creating SAP business object types see the documentation, SAP Business Workflow [Ext.]. For SAP internal development you have to complete a business object request form in the BAPI Explorer.

A BAPI is required to read the data of a company code. First of all, a list of all company codes is to be displayed. From this list a company code can be selected, and then using another BAPI, details about this company code are to be displayed. The relevant SAP business object type for this scenario is CompanyCode.

•••• What functionality should the BAPI provide and how does it affect related BAPIs, especially the other BAPIs of the SAP business object type in question?

In line with the scenario concept, BAPIs must complement each other to create a complete scenario. Their relationships with each other must be clearly defined.

To read the details of a company code as described in the above example scenario, two BAPIs are required:

• To display all the company codes • To display a specific company code

(22)

Defining the Scenario

The interdependency between these two BAPIs is evident because first the list of company codes is displayed to obtain the ID of the specific company code sought. From this ID details of the company code can be displayed.

However, the two BAPIs remain functionally independent of each other, because if the company code ID is known, the BAPI "Display details of a specific company code" can be used without first calling the BAPI "Display list of all company codes". •••• 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 type. If the data of a different SAP business object type is to be read or updated then the appropriate interface for this object type must be used. The functions or methods of these other object types are used implicitly.

The BAPIs required to read the details of a company code in the above example scenario are only able to access data in the SAP business object type

CompanyCode. Other object types are not involved.

•••• Is the BAPI assigned to the SAP business object type 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).You will also have identified the SAP business object types relevant to the BAPI scenario.

(23)

Reviewing the Scenario Concept

Reviewing the Scenario Concept

Purpose

In the previous step you created a concept for a scenario a BAPI could be applied to. You also defined the relevant SAP business object types.

Before you implement the scenario and begin defining and developing the BAPI, you should carry out a review of the scenario.

Process Flow

You should carry out the review of the BAPI scenario together with all the people involved in the development of the BAPI and those responsible for quality control in your development group. Confirm that the scenario as it stands is meaningful and that the BAPIs in the scenario can interoperate without any problems.

(24)

Defining a BAPI and Its Interface

Defining a BAPI and Its Interface

Purpose

After you have carried out the review of the BAPI concept and it has been accepted, you can start defining the BAPI itself.

In this step, you will decide on the names, parameters, and characteristics of the BAPI and determine the structures in the ABAP Dictionary which the BAPI will be based on. Only after you have planned and defined these required details can you start to implement the BAPI and create the required programming objects.

The table below illustrates where the planned information is written and how it fits together.

Information in the BOR, Function Builder and ABAP Dictionary

Business Object Repository (BOR)

Business object : Interfaces : Key fields : Attributes : Methods : Parameters : Events : .... CompanyCode .... CompanyCodeId .... GetDetail CompanyCodeDetail CompanyCodeAddress Return Function Builder BAPI_COMPANYCODE_GETDETAIL COMPANYCODEID COMPANYCODE_DETAIL COMPANYCODE_ADDRESS RETURN Function module : Parameter Importing : Exporting : ABAP Dictionary Structures Fields BAPI 0002_2 : COMP_CODE : BAPI0002_3 : BAPIRET2 :

Process Flow

To implement your BAPI in accordance with the required conventions, follow the guidelines for each of the tasks below. Follow the instructions in the references given in the second column.

Task For further information see:

1. Check if the BAPI is in the Standardized BAPIs category.

These BAPIs provide basic functions and can be implemented for most of the SAP business object types. Check whether the

(25)

Defining a BAPI and Its Interface

2. You have to identify the SAP business object type in the Business Object Repository or if necessary, create one.

Test whether the key fields of the business object type are relevant for your BAPI.

Determining the Object Type and Its Key Fields [Page 31]

For information about creating SAP business object types see the documentation, SAP Business Workflow [Ext.].

3. Define the structure and the scope of the BAPI

interface Defining the Interface Structure ofthe BAPI [Page 32]

and

Standardized Parameters [Page 29]

4. Give names to the required parameters in the

function module. Naming Parameters in the FunctionModule [Page 34]

5. Define the data formats in which the values must

be transferred in the function module interface. Defining Data Formats [Page 36] 6. Specify the required data objects in the ABAP

Dictionary.

Specifying Development Objects in the Dictionary [Page 37]

7. Assign a name to the method in the BOR. Naming the Method in the BOR [Page 40]

8. Assign a name to the method parameter in the

BOR. Naming Parameters in the BOR[Page 41]

9. Specify the name of the function module that the BAPI is based on, and the name of the function group in which the function module is to be stored.

Naming the Function Module and the Function Module Group [Page 43]

Result

(26)

Standardized BAPIs

Standardized BAPIs

Use

Some BAPIs and methods provide basic functions and can be used for most SAP business object types. Such BAPIs are known as “standardized” BAPIs.

Features

With object methods and especially with BAPIs, you can differentiate between instance methods and class methods. Instance methods refer to precisely one instance (one specific occurrence) of an SAP Business Object type, for example, to one explicitly specified customer order. Whereas class methods are instance-independent.

BAPIs for Reading Data

The following BAPIs provide you with read-only access to data in the associated business object type:

GetList()

With the BAPI GetList() you can select a range of object key values, for example, company codes and material numbers. The BAPIs GetList() is a class method.

For more information see Programming GetList() BAPIs [Page 91].

GetDetail()

The BAPI GetDetail() uses a key to retrieve details about an instance (one specific occurrence) of a business object type and returns this data to the calling program. Then this information is reported back to the calling program. The BAPI GetDetail() is an instance method.

For more information see Programming GetDetail() BAPIs [Page 93].

GetStatus()

The BAPI GetStatus() is used to query the status of an SAP business object instance, for example, the processing status of a sales order. This BAPI is used only for displaying the status of an object and does not retrieve full details like the BAPI GetDetail(). The BAPI GetStatus() is an instance method.

For more information see Programming GetStatus() BAPIs [Page 96].

ExistenceCheck()

The BAPI ExistenceCheck() checks whether an entry exists for a business object instance, for example, whether the customer master has been created. The ExistenceCheck() BAPI is an instance method.

For more information see Programming ExistenceCheck() BAPIs [Page 98].

BAPIs for Creating or Changing Data

(27)

Standardized BAPIs

Create() or CreateFromData()

The BAPI Create() or CreateFromData() creates an instance of an SAP business object type, for example, a purchase order. These BAPIs are class methods.

For more information see Programming Create() BAPIs [Page 102].

Change()

The BAPI Change() changes an existing instance of a SAP business object type, for example, a purchase order. The () BAPI is an instance method.

For more information see Programming Change() BAPIs [Page 106].

Delete() and Undelete()

The BAPI Delete() deletes an instance of an SAP business object type from the database, for example, a purchase order.

The BAPI Undelete() removes a deletion flag. These BAPIs are instance methods.

For more information see Programming Delete() BAPIs [Page 110].

Cancel()

Unlike the BAPI Delete () the BAPI Cancel() cancels an instance of a business object, that is the instance to be cancelled remains in the database and an additional instance is created that is canceled).

The Cancel() BAPI is an instance method.

For more information see Programming Cancel() BAPIs [Page 113].

Add<subobject> and Remove<sub-object>

The BAPI Add<sub-object> adds a sub-object to an existing object instance and the BAPI and

Remove<sub-object> removes a sub-object from an object instance. These BAPIs are instance

methods.

For further information see Programming Methods for Sub-Objects [Page 120].

If you are implementing BAPIs that create or change data you should consider using buffering. For further information see Buffering for Write BAPIs [Page 77].

BAPIs for Mass Processing

The BAPIs listed in the above section, “BAPIs for Creating or Changing Data”, can also be used for mass processing. Here, when a BAPI is called, several business object instances are processed at the same time.

With BAPIs for mass processing, the suffix “Multiple” is added to the method name, for example,

(28)

Standardized BAPIs

We strongly recommend that you create instance-dependent BAPIs with buffering instead of Multiple() BAPIs. For further information see Buffering with Write BAPIs [Page 77].

BAPIs for Replicating Business Object Instances

The following BAPIs are used for replicating business object instances:

Replicate() and SaveReplica()

The BAPIs Replicate() and SaveReplica() are implemented as methods of replicable business object types(). They enable specific instances of an object type to be copied to one or more different systems. These BAPIs are used mainly to transfer data between distributed systems within the context of Application Link Enabling (ALE). These BAPIs are class methods. For more information see Programming Replicate()/SaveReplica() BAPIs [Page 115].

(29)

Standardized Parameters

Standardized Parameters

Use

There are some parameters that can be created for various BAPIs because they contain the same or equivalent data in all BAPIs. Such parameters are known as “standardized” parameters. They should be implemented the same in all BAPIs.

Features

Address parameters

Specific reference structures are defined for address parameters in BAPIs. You should copy these structures to use in your BAPI, especially if the underlying object type uses the central address management (CAM).

For more information see Address Parameters [Page 123].

Change Parameters

In BAPIs that cause database changes (for example, Change() and Create() BAPIs) you must be able to distinguish between parameter fields that contain modified values and parameter fields that have not been modified. This distinction is made through the use of standardized

parameters.

For more information see Change Parameters [Page 125].

Extension parameters

The parameters ExtensionIn and ExtensionOut provides customers with a mechanism that enables BAPIs to be enhanced without modifications. For further information see Customer Enhancement Concept for BAPIs [Page 65].

Return Parameters

Each BAPI must have an export Return parameter for returning messages to the calling application. To provide application programmers with a consistent error handling process for BAPI calls, all Return parameters must be implemented in the same, standardized way. For further information see Return Parameters (Error Handling) [Page 130].

Selection Parameters

The parameters in BAPIs used to search for specific instances of a business object type, for example, BAPI GetList(), have to enable the caller of the BAPIs to specify appropriate selection criteria. Standardized selection parameters are used to do this.

For more information see Selection Parameters [Page 134].

Test Run Parameters

The parameter TestRun is used in the BAPIs that generate instances - Create() or

CreateFromData(), to check the entries for the object instance in the database before actually

(30)

Standardized Parameters

For further information see Test Run Parameters [Page 135].

Text Transfer Parameters

To transfer BAPI documentation texts, for example, documentation of a business object type, you have to create standardized text transfer parameters.

(31)

Determining the Object Type and Its Key Fields

Determining the Object Type and Its Key Fields

Purpose

Object type

You have to identify the SAP business object type required for your BAPI in the Business Object Repository or if necessary, create one. For information about creating SAP business object types see the documentation, SAP Business Workflow [Ext.]. For SAP internal development you have to complete a business object request form in the BAPI Explorer.

Key Fields

A key is defined in the BOR for the majority of SAP business object types. This key may consist of several key fields which are used to identify an individual single instance of the SAP business object type.

You can differentiate between instance-dependent (instance methods) and instance-independent (class methods) BAPIs. Unlike instance-independent methods, instance-dependent methods relate to one instance (one specific occurrence) of an SAP business object type, for example to one specific sales order.

In the case of instance-dependent BAPIs, the key fields of the corresponding SAP business object type must be used as parameters in the function module the BAPI is based on so that the associated object instance can be identified. For further information see Defining the Interface Structure of the BAPI [Page 32].

The names of the key fields in the SAP business object type and the corresponding parameters in the BAPI function module must be the same, because the name links the key fields to the parameters.

The SAP business object type, CompanyCode, has a key field named

CompanyCodeId.

This key field must be defined as a parameter with the name COMPANYCODEID in the function modules of the instant-dependent BAPIs for this business object type.

Process Flow

To display a business object type and its key fields:

1. Select Tools →=ABAP Workbench → Overview =Business Object Browser=. The business

object types are displayed in the order of the R/3 application hierarchy.

2. Select the required SAP business object type in the application hierarchy and double click it to open it.

(32)

Defining the Interface Structure of the BAPI

Defining the Interface Structure of the BAPI

Purpose

In this step you are going to define the scope and interface structure of the BAPI, that is, the individual import, export and table parameters required for calling the BAPI. You will specify the names of these parameters in the section Naming Parameters in the Function Module [Page 34]

You cannot use change and exception parameters in a function module which implements a BAPI.

Process Flow

Try to structure the BAPI as clearly as possible. Match the import parameters with each other to avoid having redundant data in the interface.

To identify the interface parameters for your BAPI, proceed as follows:

1. Check that the key fields of the SAP business object type in question are required and specify how they are going to be used in the BAPI interface. The key fields of the SAP business object type are some of the most important BAPI parameters.

• If a key value is to be passed to the BAPI by the calling program, the key field must be set as an import parameter in the function module of the BAPI. That way a specific instance of the business object type is identified.

For example, this could be a customer number (CustomerNo) in the BAPIs

Customer.GetDetail() and Customer.CheckPassword(), or the number of a sales

document in the BAPI SalesOrder.GetStatus().

• For BAPIs that generate instances, for example, the BAPIs Create() or

CreateFromData(), each key field of the business object type should be set as an

export parameter in the BAPI function module.

These BAPIs return one key value, for example, an order number in the BAPI

SalesOrder.CreateFromData().

• For BAPIs that are class methods no key field is set as the BAPI function module’s own parameter.

Class methods are instance-independent and are called without the use of key values. Usually they return a table with a selection of key values. Exceptions are write BAPIs, as described in the list item above.

2. Specify what other data is relevant in import, export or table parameters for the BAPI. Check that the parameters can be implemented as standardized parameters.

You have to create an export parameter, Return, to send messages back to the calling program. For details see Return Parameters (Error Handling) [Page 130].

(33)

Defining the Interface Structure of the BAPI

of the company code. The returned information should include detailed data and address data.

To map these requirements to the BAPI interface, the following parameters must be created in the function module which the BAPI is based on:

• The key field CompanyCodeID of the SAP business object type as an import

parameter

• A Return parameter that reports messages back to the calling program • A parameter for the details of the company code.

(34)

Naming Parameters in the Function Module

Naming Parameters in the Function Module

Purpose

In the previous step you identified the scope and the required contents of the interface

parameters. Now you have to specify the names of these parameters in three function module.

Process Flow

You are only allowed to define export, import and table parameters for the BAPI function module interface. Change and exception parameters are not allowed.

The names you choose for the function module parameters are used in the Business Object Repository (BOR) as the names of the associated method parameters. The names of BAPI parameters in the BOR and the names of the parameters in the associated function module must be identical. For this reason parameters in function modules must have meaningful names in English to ensure the BAPI method call can be carried out without any problems.

When assigning parameter names follow the guidelines below: • The names must be in English.

• As of Release 4.5A the names of method parameters in the BOR can be up to 30 characters long. Parameter names in function modules that implement the BAPIs can therefore also have up to 30 alphanumeric characters. (In earlier Releases names of parameters in the BOR could only be a maximum of 20 characters long. The associated parameter names in the function module could only be 20 characters long).

• Choose meaningful names and do not use abbreviations.

In the above example based on the company code scenario, the following parameters were required:

• An import parameter for the key field CompanyCodeID of the SAP business object type

CompanyCode

• An export parameter for the detailed data of the company code. • An export parameter for the address data of the company code. • A return parameter that reports messages back to the calling program

You could use the following names for these parameters in the function module:

Contents Name in Function Module Parameter Type

Company code COMPANYCODEID IMPORTING Detailed data of company code COMPANYCODEDETAIL EXPORTING Address data of company code COMPANYCODEADDRESS EXPORTING Return Parameters RETURN EXPORTING

(35)
(36)

Defining Data Formats

Defining Data Formats

Purpose

Here you specify the formats in which the data has to be transferred in the function module interface.

BAPIs are not end user interfaces, they are programming interfaces that can be used in diverse application areas, for instance, to connect non-SAP systems and PC products to the R/3 System. Fields in BAPI parameters must be presented in a neutral form used in the database and not in a form formatted in the BAPI interface.

•••• Data must not be presented in a user-dependent or language-dependent format. For

example, the date in a BAPI must be in the internally used format YYYYMMDD, where YYYY is the year, MM the month and DD the day.

•••• Standard codes, such as ISO codes must be used, whenever possible.

Exceptions

SAP-specific data formats must be converted into the data format required externally. This applies to, for example:

•••• Currency amount fields •••• Quantity fields

•••• Fields that have an internal key •••• Specific fields in address structures

To do this you can generate function modules that can map the relevant data to each other and perform the conversion. For further information about these exceptions see Internal and External Data Formats [Page 69].

(37)

Specifying Development Objects in ABAP Dictionary

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

Process Flow

Note the following guidelines:

•••• You can use individual fields, structures and tables as parameters. Every parameter must refer to a Dictionary object.

Note that all the parameters must be defined as structures. If a parameter consists of one field only, this must be linked to a field in a BAPI structure.

Complex data types, such as table fields in structures, are not allowed.

•••• 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. This enables changes to be made in R/3 applications without affecting BAPIs.

Give meaningful names to the data structures you create. Names should begin with the prefix BAPI.

•••• You must not use INCLUDE structures in BAPI structures, because enhancements to INCLUDE structures generally lead to incompatible changes to the BAPI structure. For further information see Incompatible Enhancements [Page 148]. BAPI structures themselves should not be used in other structures.

Structure S1 consists of fields F1 and F2. Structure S2 includes structure S1 and has a field F3. If a field F3 is added to structure S1, this causes an incompatible change to structure S2 and leads to a name clash of the F3 fields.

The graphic below illustrates the problem:

Original structures:

Structure S1 Structure S2

Structure S1 Structure S2

Structures after adding field F3:

F1 F2

F1 F2 F3

F1 F2 F3

F1 F2 F3 F3

Problems in structure S2:

• Field added in the middle of structure (incompatible change) • Two fields have the same name (naming conflict)

Structure S2 includes structure S1

(38)

Specifying Development Objects in ABAP Dictionary

Before you use an existing data element or domain, you should consult the respective colleague responsible for the object.

•••• Choose meaningful names in English for the fields in the structures. Up until Release 4.0 ten characters were available for naming structures; from Release 4.0 you can use up to 30 characters. You can use alphanumeric characters and underscores.

As of Release 4.0 default field names in English exist for data elements in the ABAP Dictionary. Whenever possible use these names for the field and parameter names. The report BBAPIFLD generates the English default names for the fields and parameters. To use this report refer to the report documentation.

If German field names are used in the internal work structures of a BAPI you can use the transaction described in Converting Between Internal and External Data Formats [Page 140], to convert the German field names into English.

In the example in the previous steps, the reference fields/tables shown below were identified for the parameters.

The first example here uses structures created in Release 3.1. In this Release structure names had a maximum of 10 characters.

The second example shows how you could name the structures more meaningfully in Release 4.0.

Parameters and their Reference Fields in Release 3.1

Parameter in the Function Module Reference Field/Table

COMPANYCODEID BAPI0002_2-COMP_CODE COMPANYCODEDETAIL BAPI0002_2

COMPANYCODEADDRESS BAPI0002_2

RETURN BAPIRETURN1

Parameters and their Reference Fields in Release 4.0

Parameter in the Function Module Reference Field/Table

COMPANYCODE BAPI0002_2-COMP_CODE

COMPANYCODEDETAIL BAPI0002_COMPANYCODEDETAIL COMPANYCODEADDRESS BAPI0002_COMPANYCODEADDRESS

(39)
(40)

Naming the Method in the BOR

Naming the Method in the BOR

Process Flow

You can now specify the name of the BAPI as a method of a SAP business object type in the Business Object Repository (BOR).

The individual components of BAPI names are identified by the use of upper and lower case letters, for example, ChangePassword.

BAPI names must be meaningful and be in English, and can only have a maximum of 30 characters. For example:

•••• ExistenceCheck

•••• ChangePassword

•••• GetDetail

For standardized BAPIs use the corresponding generic name, for example, GetList, GetDetail. For further information about these BAPIs see Standardized BAPIs [Page 26].

In standard, object-oriented language use, parentheses() are added to the method name, for example GetList(), in documentation and user guides. This convention is also used in the document.

However, no parentheses are used when assigning BAPI names.

To get an idea about naming BAPIs, you should take a look at the existing BAPIs of an SAP business object type in the BOR.

(41)

Naming Parameters in the BOR

Naming Parameters in the BOR

Process Flow

You can now assign names to the individual method parameters in the Business Object Repository (BOR).

These names are based on the names of the parameters in the function module that you assigned in Naming Parameters in the Function Module [Page 34].

When naming BAPI parameters in the BOR follow the guidelines below:

•••• The components of parameter names in the BOR are separated by upper and lower case letters to make them easier to read. Each new word in the parameter name begins with a capital letter, for example, CompanyCodeDetail.

•••• From Release 4.0 the names of BAPI parameters in the BOR and the names of the

parameters in the associated function module must be identical except for the use of upper and lower case letters. This was not necessarily the case for BAPIs developed before Release 4.0.

•••• Standardized parameters have specified names. For more information see Programming Standardized Parameters [Page 122].

If you create your BAPI in the BOR using the BOR/BAPI Wizard, the Wizard uses the parameter names in the function module as the default names of the method

parameters. For information about the BOR/BAPI Wizard see Defining Methods in the BOR Using the BOR/BAPI Wizard [Page 138].

•••• Parameter names in the BOR must be in English.

•••• Parameter names in the BOR cannot be more than 30 characters.

In the example in the previous steps, four parameters for one BAPI were identified and the names of these parameters specified 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 Name in Function Module Name in the BOR

Company code COMPANYCODE CompanyCode Detailed data of company

code COMPANYCODEDETAIL CompanyCodeDetail Address data of company

code COMPANYCODEADDRESS CompanyCodeAddress Return Parameters RETURN Return

(42)
(43)

Naming the Function Module and the Function Module Group

Naming the Function Module and the Function Module

Group

Purpose

Here you specify the name of the function module the BAPI is based on.

You must also specify the function group which this function module is to be assigned to. If there is not an appropriate function group, you have to specify a name for a new function group.

Process Flow

Assigning a Name to the Function Module

Choose a name for the function module which gives an indication of what the BAPI is used for. The naming convention for BAPIs is BAPI_<Name of object type>_<method name>. You cannot exceed the maximum length of 30 characters. If required, you can shorten the name of the method, but the BAPI_<Name of object type> should always be written in full.

In the case of a GetDetail() BAPI, which reads details for the object type

CompanyCode, the name of the associated function module is BAPI_COMPANYCODE_GETDETAIL.

Specifying the Function Group

All the BAPIs belonging to an SAP business object type should be created in one or more function groups. BAPIs belonging to different SAP business object types must not be created in the same function group.

Ascertain whether a function group has already been created for the BAPIs of the SAP business object type in question. If a function group does not already exist, specify a name for one to be created.

As the basis for naming the function group, you can use either the default technical name (object type) of the SAP business object type or its object name.

• The technical name (object type) of an SAP business object type usually takes the form of BUSnnnn, where n is a number. Use the suffix "nnnn" as the technical name of the function group. For example, if the technical name of the object type is BUS1008, then the associated BAPI function group is called 1008.

To find out the technical name of the business object type, open the object type in the Business Object Repository (BOR), as described in the section Determining the Object Type and Its Key Fields [Page 31] To display further details, for example, the technical name, double click on the name of the business object type .

• The object name of an SAP business object type can be used for the name of the function group. For example, all BAPIs associated with the business object type,

(44)
(45)

BAPIs Used for Outbound Processing

BAPIs Used for Outbound Processing

Use

As of Release 4.5A BAPIs can also be defined which have been implemented outside the R/3 System yet can still be called from the R/3 System.

These BAPIs are known as BAPIs used for outbound processing. Unlike the conventional BAPIs that are implemented in the R/3 server system and also called here (inbound), outbound BAPIs are interfaces implemented on the client system. There are always separate systems for defining (client) and for implementing (server) outbound BAPIs.

The target system is determined for the BAPI call in the distribution model of Application Link Enabling (ALE).

Integration

BAPIs used for outbound processing are defined in the Business Object Repository as API methods of SAP interface types. Functions implemented outside the R/3 System can be

standardized and made available as BAPIs. BAPIs both for outbound processing and for inbound processing can be called in the same way via the ALE distribution model.

Features

When creating BAPIs for outbound processing keep in mind:

•••• BAPIs used for outbound processing simply require the interface definition; the function module cannot be programmed.

•••• Use the BOR/BAPI Wizard to create a BAPI of an SAP interface type. For further information see Defining Methods in the BOR Using the BOR/BAPI Wizard [Page 138].

•••• In Release 4.5A API methods of interface types must have the status “implemented”. •••• BAPIs used for outbound processing can be determined from the BOR using Transaction

SWO1. For further information see Determining BAPIs of Interface Types [Ext.] in the BAPI User Guide.

The information contained in the BAPI User Guide [Ext.] and in the BAPI

Programming Guide refers to with the exception of the abovementioned points -BAPIs of both SAP interface types and SAP business object types. If this is not the case, the documentation will explain what the differences are.

(46)

Creating Development Objects and Documentation

Creating Development Objects and Documentation

Purpose

After you have defined your BAPI, identified the relevant programming objects and given them names, you can create the programming objects in the R/3 System.

Process Flow

Task Tools / Further Information

1. If necessary, create the required SAP business object type in the Business Object Repository.

For SAP internal development you have to complete a business object request form in the BAPI Explorer.

For general information about creating business object types refer to the documentation on SAP Business Workflow [Ext.].

2. The data objects, for example, structures, fields and domains are stored in the ABAP Dictionary.

For further information see the ABAP Dictionary [Ext.].

3. Create the function module in the Function

Builder and the function group, if required. For further information see the ABAP Workbench: Tools [Ext.].BC -4. Create the documentation for the BAPI and

for each interface parameter and for each parameter field.

Documentation on the BAPI and its parameters is essential because it is very difficult to use a BAPI that has not been well documented.

For internal BAPI documentation you must follow the current BAPI

documentation guidelines which you can get from your contact person in the BAPI Development group.

See the general Documentation Guidelines [Page 88].

5. If required, generating the function modules that can convert between the internal and external data formats.

For details on how to do this see

Converting Between Internal and External Data Formats [Page 140]. 6. Writing the program for the function module

that the BAPI is based on.

Note that the COMMIT WORK command must not be used in the function module.

For further information see General Programming Guidelines for BAPIs [Page 54]

and

Programming Standardized BAPIs [Page 90]

For an example of a function module that implements a BAPI see BAPI Interface and Function Module [Page 48].

(47)

Creating Development Objects and Documentation

7. Using the BOR/BAPI Wizard, define the function module as a method of the

associated SAP business object type in the BOR.

Finally, make sure that the parameters and parameter types of the method in the BOR match the parameters of the underlying function module in the Function Builder.

For more information see Defining Methods in the BOR Using the BOR/BAPI Wizard [Page 138]. For an example of a function module that implements a BAPI see BAPI Interface and Function Module [Page 48].

(48)

BAPI Interface and Function Module

BAPI Interface and Function Module

The definition of a BAPI in the Business Object Repository and its associated function module in the Function Builder must correspond to each other. This example shows the relationships between the method and the function module.

The graphic below shows the SAP business object type PurchaseOrder (BUS2012) in the BAPI Browser view of the BOR. Note the following:

•••• The business object type has a key field PurchaseOrder.

•••• The method we are looking at, GetDetail(), displays details of a purchase order The method consists of several import, export, and import/export (table) parameters.

Business Object PurchaseOrder with Key Fields and Methods

Function Module BAPI_PO_GETDETAIL

This function module BAPI_PO_GETDETAIL implements the BAPI GetDetail() of the business object type PurchaseOrder.

(49)

BAPI Interface and Function Module

object types. It is, however, better to write the name of the object type in full, for example, BAPI_PURCHASEORDER_GETDETAIL and, if necessary, to shorten the method name. •••• BAPI data structures are used. These are recognized by the prefix BAPI, for example,

BAPIEKKOL.

•••• As of Release 4.0 the names of the parameters in the method in the BOR must be exactly the same as the names of the parameters in the function module. Underscores in parameter names are no longer allowed.

•••• The key field PURCHASEORDER of the business object type is defined as an import parameter.

•••• The function module performs authorization checks.

•••• The function module picks up exceptions in the Return parameter. From Release 4.5A the reference structure BAPIRET2 or BAPIRET1 must be used.

Source Code

Function Module BAPI_PO_GETDETAIL

*"---*"

*"local interface:

*" IMPORTING

*" VALUE(PURCHASEORDER) LIKE BAPIEKKO-PO_NUMBER

*" VALUE(ITEMS) LIKE BAPIMMPARA-SELECTION DEFAULT 'X'

*" VALUE(ACCOUNT_ASSIGNMENT) LIKE BAPIMMPARA-SELECTION

*" DEFAULT SPACE

*" VALUE(SCHEDULES) LIKE BAPIMMPARA-SELECTION

*" DEFAULT SPACE

*" VALUE(HISTORY) LIKE BAPIMMPARA-SELECTION

*" DEFAULT SPACE

*" VALUE(ITEM_TEXTS) LIKE BAPIMMPARA-SELECTION

*" DEFAULT SPACE

*" VALUE(HEADER_TEXTS) LIKE BAPIMMPARA-SELECTION

*" DEFAULT SPACE

*" VALUE(SERVICES) LIKE BAPIMMPARA-SELECTION

*" DEFAULT SPACE

*" EXPORTING

*" VALUE(PO_HEADER) LIKE BAPIEKKOL STRUCTURE BAPIEKKOL

*" VALUE(PO_ADDRESS) LIKE BAPIADDRESS

*" STRUCTURE BAPIADDRESS

*" TABLES

*" PO_HEADER_TEXTS STRUCTURE BAPIEKKOTX OPTIONAL

*" PO_ITEMS STRUCTURE BAPIEKPO OPTIONAL

*" PO_ITEM_ACCOUNT_ASSIGNMENT STRUCTURE BAPIEKKN

*" OPTIONAL

*" PO_ITEM_SCHEDULES STRUCTURE BAPIEKET OPTIONAL

*" PO_ITEM_TEXTS STRUCTURE BAPIEKPOTX OPTIONAL

*" PO_ITEM_HISTORY STRUCTURE BAPIEKBE OPTIONAL

*" PO_ITEM_HISTORY_TOTALS STRUCTURE BAPIEKBES OPTIONAL

*" PO_ITEM_LIMITS STRUCTURE BAPIESUH OPTIONAL

*" PO_ITEM_CONTRACT_LIMITS STRUCTURE BAPIESUC OPTIONAL

*" PO_ITEM_SERVICES STRUCTURE BAPIESLL OPTIONAL

(50)

BAPI Interface and Function Module

*"---* reset all structures and tables

CLEAR: PO_HEADER, PO_ADDRESS, PO_ITEMS, PO_HEADER_TEXTS, PO_ITEM_ACCOUNT_ASSIGNMENT, PO_ITEM_SCHEDULES, PO_ITEM_TEXTS, RETURN, EKPOKEY, PO_ITEM_HISTORY,

PO_ITEM_HISTORY_TOTALS, PO_ITEM_LIMITS, PO_ITEM_SERVICES, PO_ITEM_CONTRACT_LIMITS, PO_ITEM_SRV_ACCASS_VALUES, CEKKO, CEKPO, CEKKN, CEKET, CEKAN, SEKKO, SEKPO, CADR. REFRESH:

PO_HEADER_TEXTS, PO_ITEM_ACCOUNT_ASSIGNMENT, PO_ITEM_SCHEDULES, PO_ITEM_TEXTS, PO_ITEMS, RETURN, EKPOKEY, PO_ITEM_HISTORY, PO_ITEM_HISTORY_TOTALS, PO_ITEM_LIMITS, PO_ITEM_SERVICES, PO_ITEM_CONTRACT_LIMITS, PO_ITEM_SRV_ACCASS_VALUES, CEKKN, CEKET, SEKKO, SEKPO.

* select the header data from database

SELECT SINGLE * FROM EKKO WHERE EBELN EQ PURCHASEORDER. IF SY-SUBRC NE 0.

PERFORM FILL_BAPIRETURN TABLES RETURN

USING 'E' 'W5' '107' PURCHASEORDER SPACE SPACE SPACE. EXIT. ENDIF. * authority check

PERFORM PO_AUTHORITY_HEADER TABLES RETURN

USING EKKO.

IF NO_AUTHORITY NE SPACE.

PERFORM FILL_BAPIRETURN TABLES RETURN

USING 'E' 'W5' '033' SPACE SPACE SPACE SPACE. EXIT. ENDIF. ……. …….

SORT PO_ITEMS BY PO_NUMBER PO_ITEM.

SORT PO_ITEM_ACCOUNT_ASSIGNMENT BY PO_ITEM SERIAL_NO. SORT PO_ITEM_SCHEDULES BY PO_ITEM SERIAL_NO.

SORT PO_ITEM_HISTORY BY PO_ITEM SERIAL_NO.

SORT PO_ITEM_HISTORY_TOTALS BY PO_ITEM SERIAL_NO. SORT PO_ITEM_LIMITS BY PCKG_NO

SORT PO_ITEM_CONTRACT_LIMITS BY PCKG_NO LINE_NO. SORT PO_ITEM_SERVICES BY PCKG_NO LINE_NO.

(51)

References

Related documents

This document states how to create Web Service from an existing Function Module or BAPI and how to use that for any business scenario using SAP Interactive Forms by Adobe..

© SAP AG 2006 Function Builder Screen Painter ABAP Dictionary ABAP Editor Object Navigator Menu Painter Debugger Class Builder FI HR MM SD MM WM Customer.. ABAP

Here we have seen that an Entity Type Object USER has a Value Type Object(or Embeddable Object ) ADDRESS with corresponding fields name street, city, pin-code and state save to

Product instance SAP NW - EP Core implements the SAP NetWeaver usage type EP Core and always requires the installation of additional Business Packages (product instance Portal

If we want to convert a persistent saved display of an object into an instance of the corresponding ABAP class, SAP Webflow Engine calls

 SAP AG 1999 Application Function Module Program Report Business Workflow Function Module IDoc Interface Segment Type Segment IDoc Type Segment Name  Data structure:. in the

Other scripts access the public function to gain access to the private static instance of this script, which is returned via the public function so that only one instance of

Members These are instance variables and instance methods of an object. They can only be accessed or invoked through an object reference. Instance.. Variable A field that is