Page tree
Skip to end of metadata
Go to start of metadata

This is the home page of BAPI

Introduction

BAPI technology (Business Application Programming Interface) is the main API technology available to customers to read and update data, that may be called from within SAP or externally using RFC protocol and ALE/IDoc technology.

This is a concept mainly based on Business Object types (SWO1 transaction) and closely related to ALE/IDoc technology (see demo chapter below).

BAPI term is also used to refer to a function module whose name starts with BAPI (which anyway should be reserved to function modules that belong to BAPI technology).

A BAPI corresponds to a method of the corresponding Business Object type, and it adopts the method's name. BAPI naming convention is: <Name space>BAPI_<business object>_<method>. It is 30 characters maximum. You may abbreviate each part of it if needed, for example BAPI_FLBOOKING_CREATEFROMDATA for method CreateFromData of object type FlightBooking.

Standardized BAPI

A standardized BAPI implements the following methods and parameters of the Business Object type:

  • Methods
    • GetList
    • GetDetail
    • GetStatus
    • ExistenceCheck
    • Create
    • Change
    • Delete
    • Cancel
    • Replicate or SaveReplica
  • Parameters
    • Address Parameters
    • Change Parameters
    • Extension Parameters
    • Return Parameters (Error Handling)
    • Selection Parameters
    • Test Run Parameters
    • Text Transfer Parameters

Passing custom fields

Custom fields may be passed using EXTENSIONIN and EXTENSIONOUT parameters of the BAPI function module. This example in SAP Library shows how to fill EXTENSIONIN when there are few custom fields, as SAP says in its example: "take care that you have 960 bytes in pieces of 240 byte. Luckily we have less than 240 byte so we need only one move".

So that to work all the time, you may call the following routine to ease the initialization of EXTENSIONIN parameter:

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
FORM transfer_to_extensionin
    USING
      is_bapi_extensionin TYPE any
    CHANGING
      cs_bapiparex        TYPE bapiparex.
  DATA l_distance_characters TYPE I.
  FIELD-SYMBOLS <any> TYPE any.

  DESCRIBE DISTANCE BETWEEN cs_bapiparex-structure
            AND cs_bapiparex-valuepart1
            INTO l_distance_characters
            IN CHARACTER MODE.
  ASSIGN cs_bapiparex+l_distance_characters(*) TO <any>
        CASTING LIKE is_bapi_extensionin.
  <any> = is_bapi_extensionin.
ENDFORM.

Example of use:

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
DATA ls_extensionin TYPE bapiparex.
DATA lt_extensionin TYPE TABLE OF bapiparex.
DATA ls_extensioninx TYPE bapiparex.
DATA lt_extensioninx TYPE TABLE OF bapiparex.
DATA ls_bapi_te_mara TYPE bapi_te_mara.
DATA ls_bapi_te_marax TYPE bapi_te_marax.

ls_extensionin-structure = 'BAPI_TE_MARA'.
ls_bapi_te_mara-material = lv_matnr.
ls_bapi_te_mara-zzfld01  = lv_zzfld01.
ls_bapi_te_mara-zzfld02  = lv_zzfld02.
PERFORM transfer_to_extensionin USING ls_bapi_te_mara CHANGING ls_extensionin.
APPEND ls_extensionin TO lt_extensionin.

ls_extensioninx-structure = 'BAPI_TE_MARAX'.
ls_bapi_te_marax-material = lv_matnr.
ls_bapi_te_marax-zzfld01  = 'X'.
ls_bapi_te_marax-zzfld02  = 'X'.
PERFORM transfer_to_extensionin USING ls_bapi_te_marax CHANGING lt_extensioninx.
APPEND ls_extensioninx TO lt_extensioninx.

For more information, see SAP Library - BAPI - Customer Enhancement and Modification of BAPIs (CA-BFA)

Demo data

You may have a loot at Flight Data Application.

SFLCONN, SFLIGHT and SFLTRIP business objects (SWO1 transaction) use respectively these BAPIs:

  • BAPI_FLCONN_GETDETAIL, BAPI_FLCONN_GETLIST
  • BAPI_FLIGHT_CHECKAVAILIBILITY, BAPI_FLIGHT_GETDETAIL, BAPI_FLIGHT_GETLIST, BAPI_FLIGHT_SAVEREPLICA
  • BAPI_FLTRIP_CANCEL, BAPI_FLTRIP_CREATE, BAPI_FLTRIP_GETLIST.

Method SaveReplica of business object SFLIGHT (BAPI_FLIGHT_SAVEREPLICA) has been wrapped into IDoc message type FLIGHT_SAVEREPLICA (BDBG transaction).

SAPBC_REPLICATE_FLIGHTS program creates a flight by using IDoc message type FLIGHT_SAVEREPLICA (and so it finally calls the BAPI).

  • No labels

2 Comments

  1. Hi

    Could you please send me sample code for  SPAN

    Unknown macro: { font-family}

    .L1S33

    Unknown macro: { color}

    'BAPI_BUS2054_CHANGE_MULTI' 

    I need to update 4 customer fields in PRPS table.

    Please help me out...

  2. Please ask questions in the forums. Comments here are to be used to suggest enhancements to this wiki. New wikis are to be created in the Staging area.