09-02-2006 3:03 AM
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>
09-07-2006 1:52 PM
09-02-2006 3:51 AM
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
09-02-2006 4:06 AM
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
09-06-2006 3:33 PM
Hello Rob,
I created that TTYP data according with OSS note 306504:
AWTYP BKPFB
STRUC BKPF_AWOBJ
FUNCTION BAPI_ACC_DOCUMENT_POST
REMOTE
OTEXT Contab. via Bapi
then I test the program, that created the document in the ledgers, but doesn't exits in BKPF.
Do you have other suggestion?
I appreciated your help.
Regards,
Piero.
09-06-2006 3:40 PM
09-07-2006 1:29 PM
Hello Rob,
I test the program with new values, that include BKPFB.
Regards,
Piero.
09-07-2006 1:52 PM
10-23-2006 4:35 PM
Hello,
The FI documents are posted, but when I check FB03 transaction and try to view:
Enviroment -> Document enviroment -> Accounting documents...
the transaction does not show the screen with related documents.
In addition, the GL documents relationship doesn't exist
Attached the header parametes:
it_hdr-obj_type = 'BKPFF'.
it_hdr-obj_key = '$'.
it_hdr-bus_act = 'RFBU'.
it_hdr-comp_code = sociedad.
it_hdr-fisc_year = ejercicio.
it_hdr-doc_date = f_documento.
it_hdr-pstng_date = f_contabilizacion.
it_hdr-fis_period = f_contabilizacion+4(2).
it_hdr-doc_type = clase_doc.
it_hdr-header_txt = texto_cab.
it_hdr-username = sy-uname.
it_hdr-compo_acc = 'FI'.
it_hdr-ref_doc_no_long = referencia.
I appreciated your help.
Regards,
Piero.