BAPI Extension

light111BAPI Extension


The BAPI FM interface supports standard fields but there can be cases  where the customer  adds some Z-fields to the db table / some other business function is activated in the system which in turn adds some fields to the DB tables. In either of the cases the standard BAPI interface won’t be able to update these  addon fields. SAP provides a way to update these addon fields in terms of BAPI Extension technique.

The bapi extension structure allows to pass the structure name ( name of the structure that contains addon fields) and values.  Once this is done, the BAPI takes care of updating the fields.

Let’s illustrate this- with Contract Account creation in SAP FICA.

Tx- CAA3

The highlighted section appears only when certain business function is activated in the system. Which means when certain business function is activated certain new fields added to the underlying DB table and the screen section appears.

12

The underlying DB table gets some fields with addition of INCLUDE structure.

34

Let;s check the BAPI used to create contract account. The highlighted structure in the TABLES section contains only the standard contract account fields.

567

Now the BAPI uses the EXTENSION to pass the addon fields to the interface.

89

The BAPI extension-in reference structure contains the addon fields.

11

The BAPI extension-in ddic reference structure- BAPIPAREX allows to pass the STRUCTURE name(BAPI_TE_FKKVKPI) and the values in the VALUEPART-1/2/3/4.

12


 

DATA: ls_ctraccreateinfo TYPE bapifkkvkci.
DATA: ls_ctracdetail TYPE bapifkkvki.
DATA: lv_contractaccount TYPE bapifkkvk-cont_acct.
DATA: lt_ctracpartnerdetail TYPE TABLE OF bapifkkvkpi1.
DATA: lt_return TYPE TABLE OF bapiret2.

DATA: lt_extensionin TYPE TABLE OF bapiparex.
DATA: ls_fkkvkpi TYPE bapi_te_fkkvkpi.

PERFORM perp_contract_create_info.
PERFORM perp_contract_partner_details.
PERFORM perp_contract_ext_in_details.

CALL FUNCTION ‘BAPI_CTRACCONTRACTACCOUNT_CR1’
EXPORTING
ctraccreateinfo = ls_ctraccreateinfo
ctracdetail = ls_ctracdetail
* TESTRUN =
* VALIDFROM =
IMPORTING
contractaccount = lv_contractaccount
TABLES
ctracpartnerdetail = lt_ctracpartnerdetail
* CTRACCHARGESDISCOUNTS =
* CTRACLOCKDETAIL =
return = lt_return
extensionin = lt_extensionin
* CTRACCORRRECEIVER =
* CTRACTAXEXEMPTION =
.

IF lt_return IS NOT INITIAL.
LOOP AT lt_return INTO DATA(ls_return).
WRITE:/ ls_return-message.

ENDLOOP.
ENDIF.
*&———————————————————————*
*& Form PERP_CONTRACT_CREATE_INFO
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
FORM perp_contract_create_info .

ls_ctraccreateinfo-acct_cat = ‘Z1’.
ls_ctraccreateinfo-appl_area = ‘S’.
ls_ctraccreateinfo-buspartner = ‘0000000002’.
ls_ctraccreateinfo-cont_acct = ‘1100000002’.
ls_ctraccreateinfo-legacy_acct = ”.

ls_ctracdetail-acct_name = ‘Test Contract Account’.

ENDFORM.
*&———————————————————————*
*& Form PERP_CONTRACT_PARTNER_DETAILS
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
FORM perp_contract_partner_details .
APPEND INITIAL LINE TO lt_ctracpartnerdetail ASSIGNING FIELD-SYMBOL(<fs_ctracpartnerdetail>).
<fs_ctracpartnerdetail>-acct_relat = ’01’.
<fs_ctracpartnerdetail>-toler_group = ‘YNSB’.
<fs_ctracpartnerdetail>-comp_code = ‘S001’.
<fs_ctracpartnerdetail>-standard_comp_code = ‘S001’.
ENDFORM.
*&———————————————————————*
*& Form PERP_CONTRACT_EXT_IN_DETAILS
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
FORM perp_contract_ext_in_details .

ls_fkkvkpi-kofiz_sc = ‘Y1’.
ls_fkkvkpi-zahlkond_sc = ‘YN01’.

APPEND INITIAL LINE TO lt_extensionin ASSIGNING FIELD-SYMBOL(<fs_ext_in>).
<fs_ext_in>-structure = ‘BAPI_TE_FKKVKPI’.
<fs_ext_in>-valuepart1 = ls_fkkvkpi.

ENDFORM.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s