Application Development and Automation 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: 
Read only

BAPI

Former Member
0 Likes
515

hello sap gurus,

Can any one tell me what is BAPI and why we use this?.And please give me one example.

Thank you very much in advance.

3 REPLIES 3
Read only

Former Member
0 Likes
447

BAPI stands for Business API(Application Program Interface).

I have answered this question before..

A BAPI is remotely enabled function module ie it can be invoked from remote programs like standalone JAVA programs, web interface etc..

You can make your function module remotely enabled in attributes of Function module but

A BAPI are standard SAP function modules provided by SAP for remote access. Also they are part of Businees Objest Repository(BOR).

BAPI are RFC enabled function modules. the difference between RFc and BAPI are business objects. You create business objects and those are then registered in your BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. in this case u only specify the business object and its method from external system in BAPI there is no direct system call. while RFC are direct system call 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.

Add<subobject> ( ) and Remove<subobject> ( ) The BAPI Add<subobject> adds a subobject to an existing object inst! ance and the BAPI and Remove<subobject> removes a subobject from an object instance. These BAPIs are instance methods.

EXAMPLE

&----


*& Report ZBAPI_MATERIAL_SAVEDATA

*&

&----


*& AUTHOR

*&----


*& PURPOSE : THIS REPORT USES BAPI MATERIAL SAVE DATA TO UPDATE AND CREATE

*& THE MATERIAL

*&

*&

*&

*&

&----


REPORT ZBAPI_MATERIAL_SAVEDATA NO STANDARD PAGE HEADING MESSAGE-ID (ZHNC).

TYPES:BEGIN OF TY_MAT,

MATERIAL(4),

IND_SECTOR(1),

MATL_TYPE(4),

    • BASIC_VIEW(1),

    • SALES_VIEW(1),

    • PURCHASE_VIEW(1),

  • STORAGE_VIEW(1),

MATL_GROUP(9),

BASE_UOM(3),

BASE_UOM_ISO(3),

  • MATL_GROUP1(1),

  • BASE_UOM1(1),

  • BASE_UOM_ISO1(1),

PLANT(4),

DEL_FLAG(1),

PUR_GROUP(3),

BASE_QTY(13),

  • PLANT2(4),

  • DEL_FLAG5(1),

  • PUR_GROUP1(1),

  • BASE_QTY1(1),

  • PLANT3(4),

STGE_LOC(4),

MRP_IND(1),

  • PLANT4(4),

  • STGE_LOC1(4),

  • MRP_IND1(1),

SALES_ORG(4),

DISTR_CHAN(2),

DEL_FLAG1(1),

MIN_ORDER(13),

  • SALES_ORG1(4),

  • DISTR_CHAN1(2),

  • DEL_FLAG2(1),

  • MIN_ORDER1(1),

LANGU(2),

MATL_DESC(40),

END OF TY_MAT.

DATA: IT_DATA TYPE TABLE OF TY_MAT,

WA_DATA LIKE LINE OF IT_DATA.

*decalraing flag

data: v_flag value ''.

*DECLARING WORK AREAs TO BE PASSED TO THE FUNCTION MODULE.

DATA: BAPI_HEAD LIKE BAPIMATHEAD,

BAPI_CLIENTDATA LIKE BAPI_MARA,

BAPI_CLIENTDATAX LIKE BAPI_MARAX,

BAPI_PLANTDATA LIKE BAPI_MARC,

BAPI_PLANTDATAX LIKE BAPI_MARCX,

BAPI_STORAGELOCATIONDATA LIKE BAPI_MARD,

BAPI_STORAGELOCATIONDATAX LIKE BAPI_MARDX,

BAPI_SALESDATA LIKE BAPI_MVKE,

BAPI_SALESDATAX LIKE BAPI_MVKEX,

BAPI_MAKT LIKE BAPI_MAKT,

BAPI_RETURN LIKE BAPIRET2.

*INTERNAL TABLE TO HOLD THE MATERIAL DESCRIPTION

DATA: BEGIN OF IT_MAKT OCCURS 0.

INCLUDE STRUCTURE BAPI_MAKT.

DATA END OF IT_MAKT.

DATA:BEGIN OF IT_RET OCCURS 0.

INCLUDE STRUCTURE BAPIRET2.

DATA END OF IT_RET.

*INTERNAL TABLE TO HOLD HEADER DATA

DATA: IT_EXCEL TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

*SELECTION-SCREEN ELEMENTS

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETER: FNAME TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT 'C:\Documents and Settings\Administrator\Desktop\MATMAS.XLS' .

PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,

P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,

P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,

P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.

SELECTION-SCREEN END OF BLOCK B1.

*DECLARATION OF EXCELAL TABLE

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.

PERFORM F_GET_FILE USING FNAME.

START-OF-SELECTION.

PERFORM F_XLS_ITAB USING FNAME

CHANGING IT_EXCEL.

PERFORM F_MOVE_DATA.

perform F_GET_DATA.

&----


*& Form F_GET_FILE

&----


  • text

----


  • -->P_FNAME text

  • <--P_SY_SUBRC text

----


FORM F_GET_FILE USING P_FNAME LIKE FNAME.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

PROGRAM_NAME = SYST-REPID

DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

  • STATIC = ' '

  • MASK = ' '

CHANGING

FILE_NAME = P_FNAME

  • EXCEPTIONS

  • MASK_TOO_LONG = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

MESSAGE E006(ZHNC).

ENDIF.

ENDFORM. " F_GET_FILE

&----


*& Form F_XLS_ITAB

&----


  • text

----


  • -->P_FNAME text

  • <--P_IT_EXCEL text

----


FORM F_XLS_ITAB USING P_FNAME

CHANGING P_IT_EXCEL.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = FNAME

I_BEGIN_COL = P_BEGCOL

I_BEGIN_ROW = P_BEGROW

I_END_COL = P_ENDCOL

I_END_ROW = P_ENDROW

TABLES

INTERN = IT_EXCEL

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " F_XLS_ITAB

&----


*& Form F_MOVE_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM F_MOVE_DATA .

DATA : LV_INDEX TYPE I.

FIELD-SYMBOLS <FS>.

*--- Sorting the internal table

SORT IT_EXCEL BY ROW COL.

CLEAR IT_EXCEL.

LOOP AT IT_EXCEL.

MOVE IT_EXCEL-COL TO LV_INDEX.

*--- Assigning the each record to an internal table row

ASSIGN COMPONENT LV_INDEX OF STRUCTURE WA_DATA TO <FS>.

*--- Asigning the field value to a field symbol

MOVE IT_EXCEL-VALUE TO <FS>.

AT END OF ROW.

APPEND WA_DATA TO IT_DATA.

CLEAR WA_DATA.

ENDAT.

ENDLOOP.

*

ENDFORM. " F_MOVE_DATA

&----


*& Form F_GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM F_GET_DATA .

LOOP AT IT_DATA INTO WA_DATA.

MOVE-CORRESPONDING WA_DATA TO BAPI_HEAD.

BAPI_HEAD-BASIC_VIEW ='X'.

BAPI_HEAD-SALES_VIEW ='X'.

BAPI_HEAD-PURCHASE_VIEW ='X'.

BAPI_HEAD-STORAGE_VIEW ='X'.

MOVE-CORRESPONDING WA_DATA TO BAPI_CLIENTDATA.

BAPI_CLIENTDATAX-MATL_GROUP = 'X'.

BAPI_CLIENTDATAX-BASE_UOM = 'X'.

BAPI_CLIENTDATAX-BASE_UOM_ISO = 'X'.

MOVE-CORRESPONDING WA_DATA TO BAPI_PLANTDATA.

BAPI_PLANTDATAX-PLANT = BAPI_PLANTDATA-PLANT.

BAPI_PLANTDATAX-DEL_FLAG = 'X'.

BAPI_PLANTDATAX-PUR_GROUP = 'X'.

BAPI_PLANTDATAX-BASE_QTY = 'X'.

MOVE-CORRESPONDING WA_DATA TO BAPI_STORAGELOCATIONDATA.

BAPI_STORAGELOCATIONDATA-PLANT = BAPI_PLANTDATA-PLANT.

BAPI_STORAGELOCATIONDATAX-PLANT = BAPI_STORAGELOCATIONDATA-PLANT.

BAPI_STORAGELOCATIONDATAX-STGE_LOC = BAPI_STORAGELOCATIONDATA-STGE_LOC.

BAPI_STORAGELOCATIONDATAX-MRP_IND = 'X'.

MOVE-CORRESPONDING WA_DATA TO BAPI_SALESDATA.

BAPI_SALESDATAX-SALES_ORG = BAPI_SALESDATA-SALES_ORG.

BAPI_SALESDATAX-DISTR_CHAN = BAPI_SALESDATA-DISTR_CHAN.

BAPI_SALESDATAX-DEL_FLAG = BAPI_SALESDATA-DEL_FLAG.

BAPI_SALESDATAX-MIN_ORDER = 'X'.

REFRESH IT_MAKT.

IT_MAKT-LANGU = WA_DATA-LANGU.

IT_MAKT-MATL_DESC = WA_DATA-MATL_DESC.

APPEND IT_MAKT.

CLEAR IT_RET.

REFRESH IT_RET.

PERFORM F_CALL_BAPI.

READ TABLE IT_RET WITH KEY TYPE = 'S'.

IF SY-SUBRC EQ 0.

PERFORM F_BAPI_COMMIT.

WRITE:/ 'MATERIAL CREATED OR UPDATED SUCESSFULLY WITH MATERIAL NO',WA_DATA-MATERIAL.

ELSE.

MESSAGE E000(ZHNC) WITH 'ERROR IN CREATING THE MATERIAL'.

*WRITE: / 'ERROR IN CREATIN MATERIAL',IT_RET-MESSAGE.

*PERFORM F_DOWNLOAD.

ENDIF.

*ENDIF.

ENDLOOP.

ENDFORM. " F_GET_DATA

&----


*& Form F_CALL_BAPI

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM F_CALL_BAPI .

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

HEADDATA = BAPI_HEAD

CLIENTDATA = BAPI_CLIENTDATA

CLIENTDATAX = BAPI_CLIENTDATAX

PLANTDATA = BAPI_PLANTDATA

PLANTDATAX = BAPI_PLANTDATAX

STORAGELOCATIONDATA = BAPI_STORAGELOCATIONDATA

STORAGELOCATIONDATAX = BAPI_STORAGELOCATIONDATAX

SALESDATA = BAPI_SALESDATA

SALESDATAX = BAPI_SALESDATAX

IMPORTING

RETURN = IT_RET

TABLES

MATERIALDESCRIPTION = IT_MAKT

  • UNITSOFMEASURE =

  • UNITSOFMEASUREX =

  • INTERNATIONALARTNOS =

  • MATERIALLONGTEXT =

  • TAXCLASSIFICATIONS =

  • RETURNMESSAGES =

  • PRTDATA =

  • PRTDATAX =

  • EXTENSIONIN =

  • EXTENSIONINX =

.

APPEND IT_RET.

ENDFORM. " F_CALL_BAPI

&----


*& Form F_BAPI_COMMIT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM F_BAPI_COMMIT .

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

ENDFORM. " F_BAPI_COMMIT

Read only

Former Member
0 Likes
447

hi,

RFC is Remote Function Call - a function module, which can be called remotely from outside

BAPI is also a Remote enabled function module but the difference between BAPI and RFC is in BAPI there is a bussiness object attached to it which calls SAP application internally.

**********************************************

can you explain RFC and BAPI???

The difference between RFc and BAPI are business objects. You create business objects and those are then registered in your BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. in this case u only specify the business object and its method from external system in BAPI there is no direct system call. while RFC are direct system call 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.

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.

RFC is the protocol used by SAP for remote communication, that is, for communications between remote independent systems.RFC is used for communications between two independent SAP systems, or for communications between an SAP system and a non-SAP system, such as an external application. It can also be used for communications between modules on the same system.Using the RFC interfaces you can extend the functionality of R/3 applications from an external program.

An R/3 system also contains Business Application Programming Interfaces (also called Business APIs, or BAPIs), which provide a programming interface to business objects. BAPIs are a set of methods for working with and manipulating SAP business objects.Internally, BAPIs are implemented as function modules stored in the R/3 Function Builder. Each BAPI has an equivalent internally-named function module. However, you should use the BAPI and not the function module behind it, because the BAPI provides a stable, object-oriented view of R/3 applications and data. The internal function modules or even the fact that the BAPIs are implemented as function modules are not guaranteed to remain the same in future releases of R/3.

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.

*****************************************************************************

RFC and BAPIs are remote enabled function modules. They are practicly the same. A BAPI is one step further as it usually is a self contained business function, such as "Create Purchase Order", or "Change Sales Document". BAPIs interface is very well defined and documented. BAPIs can be found in the BAPI browser via transaction BAPI. RFCs are just remote enabled function modules.

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.

*******************************************************************************

BAPIs are RFCs, the only difference is that BAPIs usually encapulate some complete business object. For example, creating a sales order, the BAPI would do all of the steps required to create a sales order.

**************************************************************************************

please check this:

http://help.sap.com/saphelp_nw04/helpdata/en/e0/9eb2370f9cbe68e10000009b38f8cf/frameset.htm

BAPI Programming Guide

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf

BAPI User Guide

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf

BAPI is also a Remote enabled function module but the difference between BAPI and RFC is in BAPI there is a bussiness object attached to it which calls SAP application internally.

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.

http://help.sap.com/saphelp_46c/helpdata/en/9b/417f07ee2211d1ad14080009b0fb56/frameset.htm

http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html

Checkout !!

http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html

http://techrepublic.com.com/5100-6329-1051160.html#

http://www.sap-img.com/bapi.htm

http://www.sap-img.com/abap/bapi-conventions.htm

http://www.sappoint.com/abap/bapiintro.pdf

regards,

shiva

Read only

Former Member
0 Likes
447

Hi,

BAPI - These are published programs which is used to upload data into SAP system.

BAPI is Business Application Programming Interface and has the role as communication plattform for developing applications, e.g. booking material documents from flat files, see more in trx BAPI.

BAPI - Business Application - commonly a function module that is normally RFC enabled as well and acts as a method of a business object. For example, Sales Order as the business object with a method of create - the BAPI is BAPI_SALESORDER_CREATEFROMDAT2.

Use

The Business Framework - the open, component-based architecture, which allows software components from SAP and third parties to interact and integrate with each other, is becoming more and more important.

SAP business objects are at the heart of the Business Framework, enabling the interoperability of software components. They cover a wide spectrum of R/3 business data and processes.

SAP business objects are accessed through BAPIs (Business Application Programming Interfaces), which are stable, standardized methods. SAP business objects and their BAPIs provide an object-oriented view of R/3 business functions.

SAP provided the first BAPIs for customers and external providers in Release 3.1, enabling them to integrate their software components in the R/3 System and the Business Framework. The number of BAPIs is increasing with each R/3 Release and with this the extent of object-oriented access to the R/3 System.

Reward Me Points

By

Pari