‎2010 Mar 03 2:45 PM
Hello everybody,
i have a program in which is used the Bapi_acc_document_post. The problem is that the FI substitutions are not checked in the Bapi.
Does anyone knows how to do that the bapi checks the fi substitution?
Thanks!
‎2010 Mar 03 3:42 PM
Create a new BADI for definition ACC_DOCUMENT and in method Change try something like following
DATA: I_EXTENSIONS TYPE BAPIPAREX,
I_ACCIT TYPE ACCIT,
I_ACCCR TYPE ACCCR,
I_TABNAME(30) TYPE C,
I_FLDNAME(30) TYPE C.
DATA : LT_BKPF TYPE TABLE OF BKPF,
LS_BKPF TYPE BKPF,
LS_C_BKPF TYPE BKPF,
LS_BSEG TYPE BSEG,
LS_C_BSEG TYPE BSEG,
LS_BAPIRET2 TYPE BAPIRET2,
LT_BSEG TYPE TABLE OF BSEG,
SAVE_BINPT LIKE SY-BINPT,
L_TABIX LIKE SY-TABIX,
LV_BUZEI(3) TYPE N,
LV_XNEGP TYPE XNEGP,
LV_POSNR TYPE POSNR_ACC.
MOVE-CORRESPONDING C_ACCHD TO LS_BKPF.
READ TABLE C_ACCIT INTO I_ACCIT INDEX 1.
MOVE-CORRESPONDING I_ACCIT TO LS_BKPF.
LOOP AT C_ACCCR INTO I_ACCCR WHERE CURTP = '00'.
LS_BKPF-WAERS = I_ACCCR-WAERS.
EXIT.
ENDLOOP.
*****substitute header
MOVE-CORRESPONDING LS_BKPF TO LS_C_BKPF.
CALL FUNCTION 'FI_SUBSTITUTION_HEADER'
EXPORTING
I_BKPF = LS_BKPF
IMPORTING
E_BKPF = LS_C_BKPF
* E_SUBST =
.
MOVE-CORRESPONDING LS_C_BKPF TO LS_BKPF.
MOVE-CORRESPONDING LS_BKPF TO C_ACCHD.
APPEND LS_BKPF TO LT_BKPF.
CLEAR: SY-MSGTY,SY-SUBRC.
‎2010 Mar 03 4:12 PM
Which is the purpose of CALL FUNCTION 'FI_SUBSTITUTION_HEADER'?
‎2010 Mar 03 4:26 PM
This BAPI can be used to post financial documents (from outside or inside SAP), so it calls any logic that also applies when posting via FB01 and the likes. It does also call the substitution logic.
There might a different problem on your end that causes the substitution to not work as expected. Check if it works when posting the same stuff via FB01, also check the conditions.
Thomas
‎2010 Mar 08 2:22 PM
As i know this BADI does not calls the validation and the substitutions it checks only the Standard SAP functionality.
the FM FI_SUBSTITUTION_HEADER calls the FI substitutions in header level also you can use the FM
FI_SUBSTITUTION_ITEM for document items substitutions
FI_SUBSTITUTION_DOC for complete documents substitutions
FI_VALIDATION_HEADER for document header validations
FI_VALIDATION_ITEM for document items validation
FI_VALIDATION_DOC for complete document validations