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>
Check OSS note 306504. According to it:
Use of OBJ_TYPE (reference transaction) Enter your own value in field OBJ_TYPE (reference transaction). You must maintain this value in table TTYP. You can specify a function module that is then called if the user wants to navigate back to the source or sender document from an accounting document. This means that in the document navigation (audit), you can integrate documents that were posted via the BAPIs. The field TTYP- STRUC reflects the structure of the organizational units (for example, company code and fiscal year). If you use SAP values in field OBJ_TYPE, this can result in unwanted effects, for example, errors may occur during the processing of taxes, during the navigation to the source document, or a document number, which is derived from the reference document number of the sender may be assigned (reference transaction BKPFF). In the test phase, you can use the IDoc reference transaction. Define the FI and CO line item summarization separately for each reference transaction.
Rob
Message was edited by: Rob Burbank
Hi,
Please check the changes :
&----
*& 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,
<b>l_flag type c.</b>
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' ).
<b>l_flag = 'X'.</b>
EXIT.
ENDLOOP.
<b>if l_flag is initial.</b>
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.
<b>Clear l_flag.
LOOP AT t_result WHERE ( type = 'E' OR type = 'A' ).
l_flag = 'X'.
EXIT.
ENDLOOP.</b><b>if l_flag is initial.</b>
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
<b>COMMIT WORK AND WAIT.</b>
<b>endif.</b>
WRITE: obj_key.
endif.
Best regards,
Prashant
Add a comment