Skip to Content
0
Former Member
Sep 28, 2005 at 11:49 AM

Problems with BAPI_ACC_DOCUMENT_POST

1143 Views

Hi

I want to use the bapi_acc_document_post to create accounting documents. I have used the following code in order to test the funcitonality.

[code]&----


*& Report ZZBAPI *

&----


REPORT zzbapi.

DATA: l_bkpf TYPE bapiache09,

l_obj_type TYPE bapiache02-obj_type,

l_obj_key TYPE bapiache02-obj_key,

l_obj_sys TYPE bapiache02-obj_sys.

DATA: t_return TYPE STANDARD TABLE OF bapiret2,

t_bseg TYPE STANDARD TABLE OF bapiacgl09,

t_value TYPE STANDARD TABLE OF bapiaccr09,

w_return LIKE bapiret2.

DATA: w_value TYPE bapiaccr09,

w_return2 TYPE bapiret2,

w_bseg TYPE bapiacgl09.

START-OF-SELECTION.

l_bkpf-obj_type = 'BKPFF'.

l_bkpf-obj_sys = 'DEV101'.

l_bkpf-obj_key = '$'.

l_bkpf-username = sy-uname.

l_bkpf-comp_code = '1000'.

l_bkpf-bus_act = 'RFBU'.

l_bkpf-header_txt = 'BAPI TEST'.

l_bkpf-fisc_year = '2005'.

l_bkpf-doc_date = sy-datum.

l_bkpf-pstng_date = sy-datum.

l_bkpf-fis_period = sy-datum+4(2).

l_bkpf-doc_type = 'DC'.

CLEAR: w_bseg.

w_bseg-itemno_acc = 1.

w_bseg-gl_account = '0000012350'.

w_bseg-comp_code = '1000'.

w_bseg-pstng_date = sy-datum.

w_bseg-doc_type = 'DC'.

w_bseg-fisc_year = sy-datum+0(4).

w_bseg-fis_period = sy-datum+4(2).

w_bseg-stat_con = 'S'.

INSERT w_bseg INTO TABLE t_bseg.

CLEAR: w_bseg.

w_bseg-itemno_acc = 2.

w_bseg-gl_account = '0000790500'.

w_bseg-comp_code = '1000'.

w_bseg-pstng_date = sy-datum.

w_bseg-doc_type = 'DC'.

w_bseg-fisc_year = sy-datum+0(4).

w_bseg-fis_period = sy-datum+4(2).

w_bseg-stat_con = 'H'.

INSERT w_bseg INTO TABLE t_bseg.

CLEAR: w_value.

w_value-itemno_acc = 1.

w_value-currency_iso = 'EUR'.

w_value-amt_doccur = 1000.

w_value-amt_base = 1000.

INSERT w_value INTO TABLE t_value.

CLEAR: w_value.

w_value-itemno_acc = 2.

w_value-currency_iso = 'EUR'.

w_value-amt_doccur = 1000.

w_value-amt_base = 1000.

INSERT w_value INTO TABLE t_value.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = l_bkpf

IMPORTING

obj_type = l_obj_type

obj_key = l_obj_key

obj_sys = l_obj_sys

TABLES

accountgl = t_bseg

currencyamount = t_value

return = t_return.

LOOP AT t_return INTO w_return.

WRITE : /1 w_return-message.

ENDLOOP.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ' '.

[/code]

The message printed on the screen look promissing :

[code]Document correct posted: BKPFF 000120001610002005 DEV101

[/code]

But when I look in the BKPF or VBKPF table there is no entry created. I know there are many items in the forum about the BAPI's to create financial postings, but I have not been able to find a good solution.

So if someone can help me with a solution I'll be happy.

Kind regards,

Ronald Groennou.