Application Development 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: 

BAPI_ACC_DOCUMENT_POST

Former Member
0 Kudos

I know many questions have been asked about this BAPI, I've done countless searches but all the questions are advanced compared to where I am at, so here it goes..

These are the errors I am getting in BAPI return tables generated by the code below.

  • 609 Error in document: BKPFF $ MPECLNT130
  • 002 No item information transferred into Accounting
  • 602 Required field USERNAME was not transferred in parameter DOCUMENTHEADER

NOTE: when I entered these exact same parameters in the "BAPI" transaction test run, posting was actually successful.

report zpost
TYPE-POOLS truxs.

"declaring tables to be passed to BAPI

data:
DOCUMENTHEADER LIKE BAPIACHE09 occurs 0 WITH HEADER LINE,
ACCOUNTGL LIKE BAPIACGL09 occurs 0 with HEADER LINE,
CURRENCYAMOUNT LIKE BAPIACCR09 occurs 0 with HEADER LINE,

"declare working areas for each of the above tables.

wa_DOCUMENTHEADER type BAPIACHE09,
wa_ACCOUNTGL type BAPIACGL09,
wa_CURRENCYAMOUNT type BAPIACCR09,

"BAPI return table

return type table of bapiret2 WITH HEADER LINE.

"populate BAPI manually
wa_DOCUMENTHEADER-username = 'ADEL'.
wa_DOCUMENTHEADER-header_txt = 'header1'.
wa_DOCUMENTHEADER-comp_code = 'amle'.
wa_DOCUMENTHEADER-DOC_DATE = '250517'.
wa_DOCUMENTHEADER-PSTNG_DATE = '250517'.
wa_DOCUMENTHEADER-DOC_TYPE = 'SA'.
append wa_DOCUMENTHEADER to DOCUMENTHEADER.

wa_ACCOUNTGL-ITEMNO_ACC = 1.
wa_ACCOUNTGL-GL_ACCOUNT = '410010000'.
wa_ACCOUNTGL-ITEM_TEXT = 'item test'.
wa_ACCOUNTGL-PROFIT_CTR = 'Z010101040'.
append wa_accountgl to accountgl.

wa_ACCOUNTGL-ITEMNO_ACC = 2 .
wa_ACCOUNTGL-GL_ACCOUNT = '121201300'.
wa_ACCOUNTGL-ITEM_TEXT = 'item test'.
append wa_accountgl to accountgl.

wa_CURRENCYAMOUNT-ITEMNO_ACC = 1.
wa_currencyamount-CURRENCY = 'EGP'.
wa_currencyamount-AMT_DOCCUR = '-1000.0'.
wa_currencyamount-AMT_BASE = '-1000.0'.
append wa_CURRENCYAMOUNT to currencyamount.

wa_CURRENCYAMOUNT-ITEMNO_ACC = 2.
wa_currencyamount-CURRENCY = 'EGP'.
wa_currencyamount-AMT_DOCCUR = '1000.0'.
wa_currencyamount-AMT_BASE = '1000.0'.
append wa_CURRENCYAMOUNT to currencyamount.


          CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
            EXPORTING
              documentheader          = documentheader
*             CUSTOMERCPD             =
*             CONTRACTHEADER          =
*           IMPORTING
*             OBJ_TYPE                =
*             OBJ_KEY                 =
*             OBJ_SYS                 =
            tables
*             ACCOUNTGL               =
*             ACCOUNTRECEIVABLE       =
*             ACCOUNTPAYABLE          =
*             ACCOUNTTAX              =
              currencyamount          = currencyamount
*             CRITERIA                =
*             VALUEFIELD              =
*             EXTENSION1              =
              return                  = return
*             PAYMENTCARD             =
*             CONTRACTITEM            =
*             EXTENSION2              =
*             REALESTATE              =
*             ACCOUNTWT               =
 .<<<<breakpoint-here for debugging
6 REPLIES 6

Jelena
Active Contributor
0 Kudos

Why are you doing APPEND? DOCUMENTHEADER is a structure, not a table. You don't need the WA_... part at all there.

0 Kudos
  • Agree, here Abap will consider you pass the (ugly, obsolete) header line of the internal table to the BAPI (and due to your code it's an initial record)
  • You also forgot to pass the accountgl table.
  • BAPI mostly use internal format for data (e.g. date) when SE37/BAPI test use dynpro conversion from ext to int format.
  • etc.

Reread your code more carefully.

former_member213491
Participant
0 Kudos

Hi Karim,

Please review your code and below link give you some idea.

https://blogs.sap.com/2013/07/23/accounttax-in-bapiaccdocumentpost/

gabriel_pill-kahan
Active Participant
0 Kudos

Hi,

Please enter dates in internal format, e.g. '20170525'.

Former Member
0 Kudos

You are not passing accountgl

former_member192023
Active Participant
0 Kudos

wa_DOCUMENTHEADER-PSTNG_DATE ='250517'.

Maybe this is the issue place because of the wrong key in.