Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Substitution with BAPI_ACC_DOCUMENT_POST

Former Member
0 Likes
6,059

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!

4 REPLIES 4
Read only

Former Member
0 Likes
2,663

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.

Read only

0 Likes
2,663

Which is the purpose of CALL FUNCTION 'FI_SUBSTITUTION_HEADER'?

Read only

ThomasZloch
Active Contributor
0 Likes
2,663

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

Read only

Former Member
2,663

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