Skip to Content
author's profile photo Former Member
Former Member

Error when using functions BAPI_ACC_DOCUMENT_POST

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>

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Sep 07, 2006 at 12:52 PM

    Hi Piero,

    check the below link.

    bapiaccglpostingpost

    regards

    Nagaraj

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • author's profile photo Former Member
    Former Member
    Posted on Sep 02, 2006 at 03: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 02, 2006 at 02: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.