Skip to Content
Author's profile photo Former Member

BAPI Extension for Customer added Fields

Introduction

Customers often have to change the standard SAP objects in order to meet their own specific requirements. This might involve passing some additional information by adding few extra fields to the standard SAP table. These fields might get updated in underlying Standard SAP tables or customer database table and ultimately serve the business purpose.

Business Scenario

For example, assume that there is extra information that we want to save to the database while creating a new purchase order. I.e. Prepared By, Checked By, Approved By.

5..JPG

BAPI Extension Table

But this change might affect the further BAPI implementations. This is because BAPIs are designed to implement SAP standard business processes through a predefined standard interface. I.e. its import and export parameters for any BAPI are fixed. So addition of new customer fields has absolutely nothing to do with this predefined BAPI interface. This is because these fields are added to SAP database. So executing BAPI with the same import and export parameter is not sufficient. We have to pass extra information about newly added fields. This information is passed to the BAPI using BAPI table extension. The naming convention for BAPI table extensions is BAPI_TE_<table_name>.

Here the customer first creates a data structure that contains the customer-specific fields. In our example, it is CI_EKKODB. This structure is included in both the database table and the BAPI table extension. This ensures that the enhancements to the database table and in the table extension are always identical.

1.JPG

2..JPG

3..JPG

Extension container

Also, an extension parameter (ExtensionIn) in the BAPI interface is used to pass on the enhancements to the BAPI in container format. This extension parameter is always based on data structure BAPIPAREX. Using this parameter BAPI understands the format of the data to be passed.

8..JPG

9.JPG

Here, the STRUCTURE refers to the name of the BAPI table extension though which extra information is to be sent whereas VALUEPART1 to VALUEPART4 are the values that will be inserted in the additional table fields along with the table key field.  Key field, here, purchase_order_no is the extra information that needs to be passed to know the line in the database table where the data record needs to be written.

So extension container could look like

STRUCTURE

VALUEPART1

VALUEPART2

…..

BAPI_TE_MEPOHEADER

3300000180  Nikhil Pravin  Parvati

.

..

Here, ‘3300000180’ is the key field for EKKO table specifying which row to be updated. And “Nikhil Pravin Parvati” is the extra fields of EKKO specified in BAPI_TE_MEPOHEADER.

Source Code

6..JPG

Once the BAPI Extension Table and Extension Container are filled, Execute the BAPI by passing Extension Container as an table type argument.

7..JPG

Assigned Tags

      25 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Thank a lot Nikhil.

      Apparently I am struggling with BAPI extension. I read many posts but didn't get any satisfactory suggestions so far.

      I will go through the document and will revert back asap. 🙂

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Deepa for your feedback.

      Personally, I struggled a lot to learn BAPI with extension. Could not find any good information on internet.

      It was a really good exercise. I thought I should document it.

      Regards,

      NG 🙂

      Author's profile photo Naveen Vishal
      Naveen Vishal

      Good work Nikhil..keep it up ..!

      Regards,

      Naveen

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you very much Naveen.

      Regards,

      NG 🙂

      Author's profile photo Former Member
      Former Member

      Thanx a lot Nikhil...

      i searched a lott for BAPI with extension but didnt got any easy to understand material here..

      Good Job n once again thnx a lottt for such a beautiful presentation of BAPI with extension..

      Keep it up... all the best... 🙂

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks for your Interest Amit 🙂

      Author's profile photo Former Member
      Former Member

      Hi Nikhil - Very nice explanations & detailed document.  I wanted to know on the logic of routtne "customer_extension". Where exactly we need to write it. is it on customer enhancement 'SAPL2012' - FM "EXIT_SAPL2012_001".

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Manjunath MS

      Scope of this document is only to cover the BAPI extension fields after the customer fields has been added.

      So logic need to be incorporated only when we are calling respective BAPI (FM). So mostly in customized reports in which that BAPI needs to be called.

      For example, you want to write a code to upload Purchase Order data in mass.

      I hope I have answered your query.

      Author's profile photo Nandakumar S Nair
      Nandakumar S Nair

      Hi Nikhil,

      Very good document. Keep posting. 🙂

      Thanks & regards,

      Nandakumar S

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Nandakumar.


      Thanks for your Interest. 🙂

      Author's profile photo Former Member
      Former Member

      Very nice helpful document to clearly understanding BAPI extension.

      Thank you for posting .

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      You are welcome Jatin Singhal 🙂

      I am happy to know that you found this a useful content.

      Author's profile photo Pras Venkat
      Pras Venkat

      Hi Nikhil,

      That's a wonderful article !

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Jatin Singhal & Pras Venkat,

      I am glad to know that you found this article good enough.

      Kindly provide your fair ratings...

      🙂

      Author's profile photo Missoum Aménas
      Missoum Aménas

      Great presentation with a very  clear and precise explanation ! bravo Nikhil  !   🙂

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks for your compliment 🙂

      Author's profile photo Former Member
      Former Member

      Hi Nikhil/All,

      Do you have an idea about using E1BPPAREX in LSMW?

      For example, Object class, investment profile, scale, investment reason are already existing fields in table COAS but these fields are not in structure E1BP2075_7.

      How can I use the E1BPPAREX to pass the values of the above fields?

       

      Thanks in advance.

      Author's profile photo Kalyani Vaidyanathan
      Kalyani Vaidyanathan

      Very clear explanation. Thanks you.

      Author's profile photo Steven Yeung
      Steven Yeung

      Hi Nikhil,

      In the example, length of valuepart1 is only 240 characters while the length of all custom fields is 310 characters. Should the value be splitted into valuepart2 and how?

      Thanks,
      Steven

       

      Author's profile photo Akshay RP
      Akshay RP

      Hi Nikhil,

       

       

      There is one BAPI For FIXED Asset BAPI_FIXEDASSET_CREATE1  , We are adding custom Field on data base table ANLA , BAPI table extensions is BAPI_TE_   not available for ANLA table .

       

      Please sugest for this case of BAPI .

      Author's profile photo Jyoti Bhagat
      Jyoti Bhagat

      Hi Akshay,

       

      I guess the extension you are looking for is BAPI_TE_ANLU, since the custom fields of asset master are stored in the table ANLU instead of ANLA.

      Thanks!

      Author's profile photo Stanley J
      Stanley J

      Hi Nikhil,

      We have appended a structure with five fields each 250 characters in VBAK table and its customer enhancement tables. When we try to generate an IDOC(SALESORDER_CREATEFROMDAT202) we are getting run time error saying the total length of all the fields in customer enhancement table should not exceed more than 990 char of IDOC segment BAPIPAREX..  Please suggest a right approach.

       

      Regards,

      Stanley

       

      Author's profile photo Satyaranjan Mishra
      Satyaranjan Mishra

      Hi Nikhil,

      I was struggling with change sale order Extension. Now i got the solution

      Very Helpful post.

       

      Nice job keep it up.

       

      Regards

      Satyaranjan Mishra

      Author's profile photo Gayathri Bandari
      Gayathri Bandari

      Hi all,

      can anyone say how to update the custom fields in RFQ through BAPI.........?

      I have added the custom fields at header(ekko) and item(ekpo) level and at screen level RFQ(ME41,ME42,ME43).

       

      Please can any one help me.

      Thanks in Advance,

      Gayathri.

      Author's profile photo Lakashey Pajnee
      Lakashey Pajnee

      Really nice