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

Hi Guys

I am trying to use BAPI_ACC_DOCUMENT_POST for Asset posting in G/L Account.I need to use the because I want to check the import Data with BAPI_ACC_DOCUMENT_CHECK, coming in via Excel File.

I use the Bapi, but how should i fill the structures/ tables - any code lines ? See my example and my return table ...


* DOCUMENTHEADER

BUS_ACT                           RFBU
USERNAME                       <user-name>
HEADER_TXT                     HEADER_TXT
COMP_CODE                     1000
DOC_DATE                        15.04.2009
PSTNG_DATE                    15.04.2009
FISC_YEAR                       2009
FIS_PERIOD                      04
DOC_TYPE                       KN
REF_DOC_NO                   REF_NR

* ACCOUNTGL

ITEMNO_ACC                    0000000002
GL_ACCOUNT                   8800100
ITEM_TEXT                       Asset
ACCT_TYPE                     A
BUS_AREA                      1000
TAX_CODE                       N1
COSTCENTER                 
WBS_ELEMENT              2.023000001
ORDERID                        
ASSET_NO                     40000000
SUB_NUMBER                 0

* ACCOUNTPAYABLE

ITEMNO_ACC                     0000000001
VENDOR_NO                     100004
GL_ACCOUNT                    44000100
ITEM_TEXT                        4441225511
W_TAX_CODE                     **


* CURRENCYAMOUNT

ITEMNO_ACC                     0000000002
CURRENCY_ISO                EUR
AMT_DOCCUR                   1.000,0000-

ITEMNO_ACC                     0000000001
CURRENCY_ISO                EUR
AMT_DOCCUR                   1.000,0000

Return Table :


E RW                 609 Error in document: BKPFF $ FQ1CLNT206
E AAPO             161 Accounting transaction category RFBURFBU000000000000 is not defined.
E AA                  326 Enter a transaction type
E CJ                   021 WBS element <<<PR23000001>>> does not exist

===> But the WBS ELEMENT exist. Also strange, if I run the bapi again in the se37 the error " WBS element does not exist" is gone.

Could you please help me !

Thanks a lot!!!!

Benjamin

3 REPLIES 3

Former Member
0 Kudos

Hi,

Try this sample code

<< Unformatable code removed >>\

Please post only relevant portions

Regards

Krishna

Edited by: Rob Burbank on May 5, 2009 1:15 PM

0 Kudos

Hi Krishna,

Check this out


report z_test_bapi_gl_ac_doc .
data:
obj_type like bapiache02-obj_type,
obj_key like bapiache02-obj_key,
obj_sys like bapiache02-obj_sys,
documentheader like bapiache08,

accountgl like bapiacgl08
occurs 0 with header line,
currencyamount like bapiaccr08
occurs 0 with header line,
return like bapiret2
occurs 0 with header line,
extension1 like bapiextc
occurs 0 with header line,

t_edidd like edidd occurs 0 with header line,
bapi_retn_info like bapiret2 occurs 0 with header line.
data: error_flag.

documentheader-username = sy-uname.
documentheader-header_txt = 'Test using BAPI'.
documentheader-comp_code = '1000'.
documentheader-doc_date = sy-datum.
documentheader-pstng_date = sy-datum.
documentheader-doc_type = 'SA'.

accountgl-itemno_acc = '1'.
accountgl-gl_account = '0000160100'.
accountgl-comp_code = '1000'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '0000010000'.
append accountgl.

accountgl-itemno_acc = '2'.
accountgl-gl_account = '0000160100'.
accountgl-comp_code = '1000'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '0000010000'.
append accountgl.

currencyamount-itemno_acc = '1'.
currencyamount-currency = 'GBP'.
currencyamount-amt_doccur = '100.00'.
append currencyamount.

currencyamount-itemno_acc = '2'.
currencyamount-currency = 'GBP'.
currencyamount-amt_doccur = '-100.00'.
append currencyamount.

* call BAPI-function in this system *
call function 'BAPI_ACC_GL_POSTING_POST'
exporting
documentheader = documentheader
* importing
* obj_type = obj_type
* obj_key = obj_key
* obj_sys = obj_sys
tables
accountgl = accountgl
currencyamount = currencyamount
return = return
extension1 = extension1
exceptions
others = 1.
if sy-subrc <> 0.
message e999(re) with 'Problem occured'.
else.
loop at return.
if not return is initial.
clear bapi_retn_info.
move-corresponding return to bapi_retn_info.
if return-type = 'A' or return-type = 'E'.
error_flag = 'X'.
endif.
append bapi_retn_info.
endif.
endloop.
if error_flag = 'X'.
message e999(re) with 'Problem occured'.
rollback work.
else.
commit work.
endif.
endif

Got it from [here|http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bapi_acc_document_post-622561?cv=expanded], Also going thru BAPI Document always help

Hope this helps!

Regard

Shital

0 Kudos

Hi Shital!

Does this code also provide the possiblity to post from creditor against an asset (-). See my tables/structures above.

My report should book against a costcenter, wbs or internal order (ACCOUNTGL ) from a creditor or debitor ( ACCOUNTPAYABLE / Receiver).

How is that possible ???

Thanks

Benjamin