Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

bapi vs function module

Former Member
0 Kudos

Hi all,

can any body help me what is the actual diff between BAPI and gegeral FUNCTION MODULE.

3 REPLIES 3

Former Member
0 Kudos

Hi,

BAPI stands for Business Application Programming Interface. It is a library of functions that are released to the public as an interface into an existing SAP system from an external system.

RFC is the protocol used to call functions in an R/3 system by a caller external to R/3 or to call programs external to R/3 from an R/3 system.

Functions can only be called via RFC, if they are tagged as RFC functions in the SAP development workbench. They are then called RFC function modules. BAPIs are complete sets of (BAPI) function modules that model a business application.

When you are familiar with web developments: RFC can be compared to HTTP and BAPIs are CGI applications.

In other words: A BAPI function is a function module that can be called remotely using the RFC technology.

BAPI's are RFC enabled API's where as FM's are not.

Regards

Former Member
0 Kudos

Check this thread.

Regards,

Maha

Former Member
0 Kudos

BAPI Conventions

Methods

Parameters

Standardized BAPIs

Standardized Parameters

Important things to remember..

BAPI/ALE Integration

Methods

• If the BAPI to be implemented is a standardized BAPI, use the generic names, for example, GetList, GetDetail.

• The method name must be in English (maximum 30 characters).

• The individual components of a BAPI name are separated by the use of upper and lower case.Example: GetList

Underscores ("_") are not allowed in BAPI names.

• Each BAPI has a return parameter that is either an export parameter or an export table.

• So that customers can enhance BAPIs, each BAPI must have an ExtensionIn and an ExtensionOut parameter.

Parameters

• If standardized parameters are used, you have to use the names specified for standardized parameters.

• BAPI parameter names should be as meaningful as possible. Poorly chosen names include abbreviations and technical names (e.g. "flag", table names, etc.).

The parameter and field names must be in English with a maximum of 30 characters.

• The components of a parameter name in the BOR are separated by upper and lower case letters to make them easier to read. Example: CompanyCodeDetail

• Values that belong to each other semantically should be grouped together in one structured parameter, instead of using several scalar parameters.

• For ISO-relevant fields (country, language, unit of measure, currency), additional fields for ISO codes are provided.

• Unit of measure fields must accompany all quantity fields and currency identifiers must accompany currency amount fields.

Standardized BAPIs

Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all business object types. Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs. Whenever possible, a standardized BAPI must be used in preference to an individual BAPI.

The following standardized BAPIs are provided:

Reading instances of SAP business objects

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

The BAPI GetList() is a class method.

GetDetail() With the BAPI GetDetail() the details of an instance of a business object type are retrieved and returned to the calling program. The instance is identified via its key. The BAPI GetDetail() is an instance method.

BAPIs that can create, change or delete instances of a business object type

The following BAPIs of the same object type have to be programmed so that they can be called several times within one transaction. For example, if, after sales order 1 has been created, a second sales order 2 is created in the same transaction, the second BAPI call must not affect the consistency of the sales order 2. After completing the transaction with a COMMIT WORK, both the orders are saved consistently in the database.

Create( ) and

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

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

Delete( ) and Undelete( ) The BAPI Delete() deletes an instance of an SAP business object type from the database or sets a deletion flag.

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

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

Example Program

DATA: BAPI_Z05DOGI_DELIVERY LIKE BAPIOBDLVHDRCON-DELIV_NUMB ,

BAPI_Z05DOGI_HEADER_DATA LIKE BAPIOBDLVHDRCON OCCURS 0 WITH HEADER LINE ,

BAPI_Z05DOGI_HEADER_CONTROL LIKE BAPIOBDLVHDRCTRLCON OCCURS 0 WITH HEADER LINE,

BAPI_Z05DOGI_ITEM_DATA LIKE BAPIOBDLVITEMCON OCCURS 0 WITH HEADER LINE,

BAPI_Z05DOGI_ITEM_CONTROL LIKE BAPIOBDLVITEMCTRLCON OCCURS 0 WITH HEADER LINE ,

BAPI_Z05DOGI_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE .

CLEAR: BAPI_Z05DOGI_DELIVERY , BAPI_Z05DOGI_HEADER_DATA , BAPI_Z05DOGI_HEADER_CONTROL , BAPI_Z05DOGI_ITEM_DATA ,BAPI_Z05DOGI_ITEM_CONTROL , BAPI_Z05DOGI_RETURN .

REFRESH: BAPI_Z05DOGI_HEADER_DATA , BAPI_Z05DOGI_HEADER_CONTROL , BAPI_Z05DOGI_ITEM_DATA , BAPI_Z05DOGI_ITEM_CONTROL , BAPI_Z05DOGI_RETURN .

BAPI_Z05DOGI_DELIVERY = ZMM_WB1-ISSUE .

BAPI_Z05DOGI_HEADER_DATA-DELIV_NUMB = ZMM_WB1-ISSUE.

APPEND BAPI_Z05DOGI_HEADER_DATA.

BAPI_Z05DOGI_HEADER_CONTROL-DELIV_NUMB = ZMM_WB1-ISSUE.

BAPI_Z05DOGI_HEADER_CONTROL-POST_GI_FLG = 'X'.

APPEND BAPI_Z05DOGI_HEADER_CONTROL.

BAPI_Z05DOGI_ITEM_DATA-DELIV_NUMB = ZMM_WB1-ISSUE.

BAPI_Z05DOGI_ITEM_DATA-DELIV_ITEM = 10.

BAPI_Z05DOGI_ITEM_DATA-DLV_QTY = LFIMGGIA.

BAPI_Z05DOGI_ITEM_DATA-SALES_UNIT = XTAB-MEINS.

            • BAPI_Z05DOGI_ITEM_DATA-DLV_QTY_IMUNIT = LFIMGGIA.

BAPI_Z05DOGI_ITEM_DATA-FACT_UNIT_NOM = UMVKZLIPS.

BAPI_Z05DOGI_ITEM_DATA-FACT_UNIT_DENOM = UMVKNLIPS.

APPEND BAPI_Z05DOGI_ITEM_DATA.

BAPI_Z05DOGI_ITEM_CONTROL-DELIV_NUMB = ZMM_WB1-ISSUE.

BAPI_Z05DOGI_ITEM_CONTROL-DELIV_ITEM = 10.

BAPI_Z05DOGI_ITEM_CONTROL-CHG_DELQTY = 'X'.

APPEND BAPI_Z05DOGI_ITEM_CONTROL.

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CONFIRM_DEC'

EXPORTING

DELIVERY = BAPI_Z05DOGI_DELIVERY

HEADER_DATA = BAPI_Z05DOGI_HEADER_DATA

HEADER_CONTROL = BAPI_Z05DOGI_HEADER_CONTROL

TABLES

ITEM_DATA = BAPI_Z05DOGI_ITEM_DATA

ITEM_CONTROL = BAPI_Z05DOGI_ITEM_CONTROL

RETURN = BAPI_Z05DOGI_RETURN.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = BAPI_Z05DOGI_RETURN.

Regards,

Raghunath.S