Skip to Content
Author's profile photo Divya Munnuru

Extending BKPF Table by adding custom or ZZ Fields in SAP

Hello Everyone,

The primary motive behind writing this blog is based on a personal experience wherein while extending the BKPF table and creating the accounting document, data could not be posted to the table. Upon further investigation, it was found that few structures needed to be extended in some reports and those reports needed to be regenerated.

It was difficult to find complete information on exactly what needs to be done in one go. Hence I would like to jot down all information in this blog.

Many a times due to client requirements, database tables need to be extended.  Only extending database table is not sufficient as we need to know all dependent tables and reports which have to be regenerated or extended along with the base table.

In our case, for extending BKPF table, we had to regenerate many reports, extend structure and depending tables etc. Let me explain the entire process in detail.

Requirement: Extending table BKPF with new fields.

Accounting documents make up the financials of your organization. BKPF (Accounting Document Header) is a standard table in SAP R/3 ERP systems which stores the header lines for accounting documents and consists of Company Code, Document No, Fiscal Year (as key fields). We had to extend BKPF Table with 3 new ZZ fields (ZZTRANTXT, ZZDECTXT, ZZAOACFO).

With the introduction of new fields, the selection criteria for creating accounting document were expanded as follows.

  • Effective Date
  • Document type
  • Transaction text (ZZTRANTXT)
  • Description text (ZZDECTXT)
  • Agency (ZZAOACFO)

In our scenario, the following had to be extended/modified.

Step 1: VBKPF table (standard SAP Table which is used to store Document Header for Document Parking information). This is available within R/3 SAP systems and needs to be extended with the new ZZ fields.

Step 2: The structure ACCHD should be extended since we were using BAPI_ACC_DOCUMENT_POST

BAPI_ACC_DOCUMENT_CHECK. This BAPI (BAPI_ACC_DOCUMENT_POST

, BAPI_ACC_DOCUMENT_CHECK) has an extension table which is used to map to BKPF table .

 

Step 3: Following Include LFACIF4S has a structure called P_ACC which needs to have newly added ZZ Fields. In order to get these new fields into this structure we need to run following report SAPFACCG so that the structure is regenerated in the include.

 

P_acc Structure:

 

Step 4: When we post document using preliminary_posting_post_all function module, include LF040Z02 needs to be regenerated with newly added custom fields.

Step 5: Run RFBIPGG0 for regenerating LF040Z02 Include. This report is relevant when we post a document using FV50. Here we have to enhance FV50 with new custom fields. Another scenario needs to be considered in case if you are posting document using FBVB transaction, then above include LF040Z02 becomes irrelevant.

Step 6: Structure INVFO needs to be extended with newly added custom fields.

Step 7: When we finally post document using function module PRELIMINARY_POSTING_POST_ALL, this FM internally uses BDC and posts the document using transaction FBVB.

Step 8: The BADI FI_HEADER_SUB_1300 could be used for screen enhancement. You might have to create an Enhancement Point in program SAPMF05A.

Note: New Z fields can be added to FB03 only in the form of hard screen modification and is not recommended.

For any queries please get in touch with contacts mentioned below.

*personal mails deleted*

 

 

Assigned tags

      12 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Chandan Gurav
      Chandan Gurav

      Great Stuff Divya.. Thanks for sharing

      Author's profile photo Priyanka Sadana
      Priyanka Sadana

      Very well explained 🙂

      Author's profile photo Mbye Njie
      Mbye Njie

      Nice post, thank you very much 🙂

      Author's profile photo Monika Patel
      Monika Patel

      Nice post. Thanks for sharing

      Author's profile photo Divya Munnuru
      Divya Munnuru
      Blog Post Author

      🙂

       

      Author's profile photo Kyle McCarter
      Kyle McCarter

      BRILLIANT! Divya this blog is just what I needed today. Thank you, and bless you too 🙂

      Author's profile photo Divya Munnuru
      Divya Munnuru
      Blog Post Author

      🙂 Thank you

      Author's profile photo Shreyash Agrawal
      Shreyash Agrawal

      Thanks, Divya for posting this. It really helped in understanding the approach.

      However, I need more information on this process as I am trying to implement an almost similar solution and am stuck. Any help would be appreciated.

      Author's profile photo Divya Munnuru
      Divya Munnuru
      Blog Post Author

      Hi Shreyash,

       

      Could you please let me know what exactly you looking for ?

       

      Regards,

      Divya

      Author's profile photo sowmya kedaresetti
      sowmya kedaresetti

      can you please tell me how to update xref2_hd  field in bkpf by using BAPI_ACC_DOCUMENT_POST

       

      Author's profile photo Tomasz Piwowarski
      Tomasz Piwowarski

      Hi

      I have a problem in FB02

      Value in this new field is not changing but change log on document is created.

      I have found FM CHANGE_DOCUMENT which should make changes in table BKPF.

      Include LFAGL_F005F03.

      I whant to add new line to code of this FM (with my new fileld) but how to do this without entering acces Key?

      There is no enhance point...

      Author's profile photo Mateo Cano
      Mateo Cano

      Hi Divya. Maybe another way of enhacement screen in FB02 or FB03?

      Hard screen modification is the only way ? Thanks!