Skip to Content
0
Former Member
Sep 02, 2006 at 02:03 AM

Error when using functions BAPI_ACC_DOCUMENT_POST

123 Views

Hello,

When I used BAPI_ACC_DOCUMENT_POST function, the message: Document posted successfully appears, but really not documens are created, and the FI number range are modified.

See the example code:

&----


*& Report ZPBA_PC *

*& *

&----


*& *

*& *

&----


REPORT zpba_pc MESSAGE-ID m3.

***

DATA: obj_type LIKE bapiache09-obj_type,

obj_key LIKE bapiache09-obj_key,

obj_sys LIKE bapiache09-obj_sys.

DATA: it_hdr LIKE bapiache09,

it_gl LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,

it_curr LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,

t_result LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

  • Header Data

it_hdr-obj_type = 'BKPFF'.

it_hdr-obj_key = '$'.

it_hdr-obj_sys = 'LA122D'.

it_hdr-bus_act = 'RFBU'.

it_hdr-comp_code = 'VEZS'.

it_hdr-fisc_year = '2004'.

it_hdr-fis_period = '12'.

it_hdr-doc_date = '20041218'..

it_hdr-pstng_date = '20041218'.

it_hdr-doc_type = 'ZI'.

it_hdr-header_txt = 'TEXTO CAB'.

it_hdr-username = sy-uname.

it_hdr-compo_acc = 'GL'.

it_hdr-ref_doc_no_long = 'REFERENCIA'.

  • First Item

  • Account number

it_gl-itemno_acc = '1'.

it_gl-gl_account = '0014401001'.

it_gl-item_text = 'PRUEBA TEXTO 1'.

it_gl-profit_ctr = 'VE2020'.

APPEND it_gl.

  • Second Item

  • Account number

it_gl-itemno_acc = '2'.

it_gl-gl_account = '0014401001'.

it_gl-item_text = 'PRUEBA TEXTO 2'.

it_gl-profit_ctr = 'VE2020'.

APPEND it_gl.

  • Set amount

it_curr-itemno_acc = '1'.

it_curr-currency = 'VEB'.

it_curr-amt_doccur = '10'.

APPEND it_curr.

it_curr-itemno_acc = '2'.

it_curr-currency = 'VEB'.

it_curr-amt_doccur = '-10'.

APPEND it_curr.

  • check posting

CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'

EXPORTING

documentheader = it_hdr

TABLES

accountgl = it_gl

currencyamount = it_curr

return = t_result.

LOOP AT t_result WHERE ( type = 'E' OR type = 'A' ).

EXIT.

ENDLOOP.

if sy-subrc ne 0.

REFRESH t_result.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = it_hdr

IMPORTING

obj_type = obj_type

obj_key = obj_key

obj_sys = obj_sys

TABLES

accountgl = it_gl

currencyamount = it_curr

return = t_result.

*

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

COMMIT WORK.

WRITE: obj_key.

endif.

I appreciated your help to solve that error.

Regards,

Piero Cimule.

<b></b>