Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all articles
Browse latest Browse all 943

Adding fields to table BKPF and updating in posting transactions.

$
0
0

 

I research about it and i want to share my solution.

 

This post is just to share knowledge and to receive your opinions.

 

First i went to dictionary ABAP and selected the BKPF table, then clicked in append structure.

 

 

after that this pop up dynpro is showed and you need to select the "Create Append" button

 

 

put the name in the box and then create, here you need to create the structure as any other, finally active.

 

Note: the field name must start with ZZ or YY. more information in Methods for Modifying Dictionary Tables - Contributor Corner - SCN Wiki

 

Until here we just have the fields to use, the next step is creating an BTE (bussines Transaction Event), if you don't know what is BTE or how it works see the doc FI Enhancement Technique - How-To-Guide on the Usage of Business Transaction Events (BTE)

 

Just to abstract.

"Business Transaction Events (BTE) allows attaching additional components, in the form of a function module to the R/3 system. Business transaction events function in the same manner as customer exits"- Jelena Perfiljeva in doc Business Transaction events(BTE) - Code Gallery - SCN Wiki

I used the BTE process Interface '00001120' - DOCUMENT POSTING:  Field substitution header/items, the sample function module is "SAMPLE_PROCESS_00001120", in FIBF transaction you can see more documentation.

 

Sample function.

FUNCTION SAMPLE_PROCESS_00001120.
 *"----------------------------------------------------------------------
 *"*"Lokale Schnittstelle:
 *"  IMPORTING
 *"     VALUE(I_BKDF) TYPE  BKDF OPTIONAL
 *"  TABLES
 *"      T_BKPF STRUCTURE  BKPF
 *"      T_BSEG STRUCTURE  BSEG
 *"      T_BKPFSUB STRUCTURE  BKPF_SUBST
 *"      T_BSEGSUB STRUCTURE  BSEG_SUBST
 *"      T_BSEC STRUCTURE  BSEC OPTIONAL
 *"  CHANGING
 *"     REFERENCE(I_BKDFSUB) TYPE  BKDF_SUBST OPTIONAL
 *"----------------------------------------------------------------------
 ENDFUNCTION.

The main purpose of this process is update head or line fields using the tables T_BKPFSUB and T_BSEGSUB, we going to use the T_BKPFSUB because the change was in the head of FI document, by logic the custom fields isn't in the Substitutable fields table, so, we need to appending it too with our fields.

 

Note: you need to copy the SAMPLE functions, never do changes in these, then you copy that go to the FIBF transaction to update the tables control.

 

Finally i didn't want to change the screen of every FI posting screens, for allow to the user to write in that fields, i just use the function  POPUP_GET_VALUES_USER_HELP

 

DATA: BEGIN OF FIELDS OCCURS 2.      INCLUDE STRUCTURE SVAL.   DATA: END OF FIELDS.   CLEAR FIELDS.   FIELDS-TABNAME = 'BKPF'.   FIELDS-FIELDNAME = 'ZZXBLNR_2'.   FIELDS-FIELD_OBL = 'X'.   APPEND FIELDS   CALL FUNCTION 'POPUP_GET_VALUES_USER_HELP'      EXPORTING         POPUP_TITLE = POPUP_TITLE      IMPORTING         RETURNCODE = RETURNCODE      TABLES         FIELDS = FIELDS   EXCEPTIONS        ERROR_IN_FIELDS                 = 1        OTHERS                          = 2               .   CHECK SY-SUBRC = 0.   LOOP AT FIELDS .      IF FIELDS-FIELDNAME = 'ZZFIELD1'.        t_bkpf-ZZFIELD1 = FIELDS-VALUE.        T_BKPFSUB-ZZFIELD1 = FIELDS-VALUE.      ENDIF.   ENDLOOP.  MODIFY T_BKPF INDEX 1 TRANSPORTING ZZFIELD1.  MODIFY T_BKPFSUB INDEX 1 TRANSPORTING ZZFIELD1.

And that's all, if you want to make a validation after posting the document about this fields you can try with the BTE P/S Interface '00001030 - POST DOCUMENT:Posting of standard data.' for FI transactions and '00001050 - POST DOCUMENT: Accounting interface' to interface like MIRO, PCP0, etc.

 

Finally remember in BTE's do a SY-TCODE or SY-REPID or document class types validation because it affect to many transactions.

 

Hope you find it helpful.

 

Thank you to take the time to read.

 

Francisco Romero.


Viewing all articles
Browse latest Browse all 943

Trending Articles