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

BAPI_ACC_GL_POSTING_POST

Hi,

I used the Bapi 'BAPI_ACC_GL_POSTING_POST'... with the following program...that I found here on SDN

&----


*& Report ZNAM_BAPI_TEST

*&----


REPORT ZNAM_BAPI_TEST .

TABLES: bapiache08, bapiacgl08,bapiaccr08, bapiret2.

DATA: t_bapiache08 LIKE TABLE OF bapiache08 WITH HEADER LINE,

t_bapiacgl08 LIKE TABLE OF bapiacgl08 WITH HEADER LINE,

t_bapiaccr08 LIKE TABLE OF bapiaccr08 WITH HEADER LINE,

t_bapiret2 LIKE TABLE OF bapiret2 WITH HEADER LINE,

ct_bapiret2 LIKE TABLE OF bapiret2 WITH HEADER LINE.

t_bapiache08-obj_type = 'BKPFF'. "BKPFF

t_bapiache08-obj_key = '000000001810052006'.

t_bapiache08-obj_sys = 'ID1CLNT800'. "T09CLNT800

t_bapiache08-username = 'NJAYAWAN'.

t_bapiache08-header_txt = 'DOCUMENT POSTING'.

t_bapiache08-comp_code = '1005'.

t_bapiache08-fisc_year = '2006'.

t_bapiache08-doc_date = '20060829'.

t_bapiache08-pstng_date = '20060829'.

t_bapiache08-fis_period = '08'.

t_bapiache08-doc_type = 'SA'.

t_bapiache08-compo_acc = 'FI'. "GL

APPEND t_bapiache08.

t_bapiacgl08-itemno_acc = '0000000001'.

t_bapiacgl08-gl_account = '220000'.

t_bapiacgl08-comp_code = '1005'.

t_bapiacgl08-pstng_date = '20060829'.

t_bapiacgl08-doc_type = 'SA'.

t_bapiacgl08-fisc_year = '2006'.

t_bapiacgl08-fis_period = '08'.

t_bapiacgl08-stat_con = 'X'.

t_bapiacgl08-vendor_no = '1920'. "ACCOUNTING NO.FOR VENDOR/CREDITOR.

t_bapiacgl08-item_text = 'LINE ITEM TEXT BY VIN'.

APPEND t_bapiacgl08.

t_bapiaccr08-itemno_acc = '0000000001'.

t_bapiaccr08-currency_iso = 'EUR'.

t_bapiaccr08-amt_doccur = '2000'.

APPEND t_bapiaccr08.

CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'

EXPORTING

documentheader = t_bapiache08

  • IMPORTING

  • OBJ_TYPE =

  • OBJ_KEY =

  • OBJ_SYS =

TABLES

accountgl = t_bapiacgl08

currencyamount = t_bapiaccr08

return = t_bapiret2

  • EXTENSION1 =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ' '

IMPORTING

return = ct_bapiret2.

LOOP AT t_bapiret2.

WRITE :/ t_bapiret2-type, t_bapiret2-id, t_bapiret2-number,

t_bapiret2-message,t_bapiret2-parameter,

t_bapiret2-row, t_bapiret2-field, t_bapiret2-system.

ENDLOOP.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ' '

IMPORTING

return = ct_bapiret2.

LOOP AT ct_bapiret2.

WRITE :/ ct_bapiret2-type, ct_bapiret2-id, ct_bapiret2-number,

ct_bapiret2-message,ct_bapiret2-log_no, ct_bapiret2-parameter,

ct_bapiret2-row, ct_bapiret2-field, ct_bapiret2-system.

ENDLOOP.

*&----


The output received was :

S RW 605

Document posted successfully: BKPFF 000000001810052006 ID1CLNT800

*&----


But there was no document created in BKPF or BSEG table.. Please ignore the use of 'BAPI_TRANSACTION_COMMIT' 2 times. It was done to check various possiblities.. Please advise.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2006 at 12:53 PM

    Hi Namita,

    data : g_bapiwait like bapita-wait.

    in the Functionmodule 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    wait = g_bapiwait

    IMPORTING

    return = ct_bapiret2.

    Try like this.I think it will solve ur problem.

    Regards,

    Nagaraj

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      The BAPi seems to wok with the following code:

      REPORT znam_bapi_test_2 .

      DATA: g_documentheader TYPE bapiache08,

      g_bapi_wait LIKE bapita-wait,

      ta_accountgl TYPE STANDARD TABLE OF bapiacgl08,

      ta_currencyamount TYPE STANDARD TABLE OF bapiaccr08,

      ta_return TYPE STANDARD TABLE OF bapiret2,

      ta_extension1 TYPE STANDARD TABLE OF bapiextc,

      wa_accountgl TYPE bapiacgl08,

      wa_currencyamount TYPE bapiaccr08,

      wa_extension1 TYPE bapiextc,

      wa_return TYPE bapiret2.

      Parameters:

      • c1_item LIKE wa_currencyamount-itemno_acc DEFAULT '0000000001',

      • c1_type LIKE wa_currencyamount-curr_type DEFAULT '00',

      • c1_curr LIKE wa_currencyamount-currency DEFAULT 'EUR',

      c1_amt LIKE wa_currencyamount-amt_doccur DEFAULT '1',

      c1_sign TYPE char1 DEFAULT '-',

      • c2_item LIKE wa_currencyamount-itemno_acc DEFAULT '0000000002',

      • c2_type LIKE wa_currencyamount-curr_type DEFAULT '00',

      • c2_curr LIKE wa_currencyamount-currency DEFAULT 'EUR',

      c2_amt LIKE wa_currencyamount-amt_doccur DEFAULT '1',

      c2_sign TYPE char1 DEFAULT '+',

      field1 LIKE wa_extension1-field1 DEFAULT '1'.

      g_documentheader-username = 'LKS'.

      g_documentheader-header_txt = 'Default text in header'.

      g_documentheader-comp_code = '1005'.

      g_documentheader-ac_doc_no = ' '.

      g_documentheader-fisc_year = '2006'.

      g_documentheader-doc_date = '20060818'.

      g_documentheader-pstng_date = '20060818'.

      g_documentheader-doc_type = 'SA'.

      g_documentheader-ref_doc_no = ' '.

      wa_accountgl-itemno_acc = '0000000001'.

      wa_accountgl-gl_account = '0000220000'.

      wa_accountgl-item_text = 'ITEM TEXT Default 1'.

      APPEND wa_accountgl TO ta_accountgl.

      wa_accountgl-itemno_acc = '0000000002'.

      wa_accountgl-gl_account = '0000220000'.

      wa_accountgl-item_text = 'ITEM TEXT Default 2'.

      APPEND wa_accountgl TO ta_accountgl.

      wa_currencyamount-itemno_acc = '0000000001'.

      wa_currencyamount-curr_type = '00'.

      wa_currencyamount-currency = 'EUR'.

      IF c1_sign = '-'.

      wa_currencyamount-amt_doccur = c1_amt * -1.

      ELSE.

      wa_currencyamount-amt_doccur = c1_amt.

      ENDIF.

      APPEND wa_currencyamount TO ta_currencyamount.

      wa_currencyamount-itemno_acc = '0000000002'.

      wa_currencyamount-curr_type = '00'.

      wa_currencyamount-currency = 'EUR'.

      wa_currencyamount-amt_doccur = c2_amt.

      IF c2_sign = '-'.

      wa_currencyamount-amt_doccur = c1_amt * -1.

      ELSE.

      wa_currencyamount-amt_doccur = c1_amt.

      ENDIF.

      APPEND wa_currencyamount TO ta_currencyamount.

      IF field1 IS NOT INITIAL.

      wa_extension1-field1 = field1.

      APPEND wa_extension1 TO ta_extension1.

      ENDIF.

      CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'

      EXPORTING

      documentheader = g_documentheader

      • IMPORTING

      • OBJ_TYPE =

      • OBJ_KEY =

      • OBJ_SYS =

      TABLES

      accountgl = ta_accountgl

      currencyamount = ta_currencyamount

      return = ta_return

      extension1 = ta_extension1.

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

      EXPORTING

      wait = g_bapi_wait

      IMPORTING

      return = wa_return.

      LOOP AT ta_return INTO wa_return.

      WRITE: / wa_return-type, wa_return-id, wa_return-number,

      wa_return-message.

      ENDLOOP.

      -


      Thanks to all those u replied

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2006 at 08:54 AM

    Hi ,

    after the Posting , justc check the same thing in Tcode : FBL3N : select all items or FB03.

    are seeing the same client where u posted the Document?

    000000001810052006.---->Check what Number Range u are maintaing for Account documents ? here 2006 is for year ,
    181005 is for Document Number.

    Regards

    Prabhu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2006 at 09:17 AM

    Hi,

    You can use the BAPI "BAPI_ACC_DOCUMENT_POST" to post

    the Accounting documents.

    It works successfully.

    With regards,

    Akriti

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2006 at 01:07 PM

    Hi,

    Look at the example code for that.......

    bapi-----points-guarenteed-

    ********************************

    loop at podoc_it.

    clear: offset_it, it_hdr, it_gl, it_curr.

    refresh: it_hdr, it_gl, it_curr.

    read table offset_it with key bukrs = podoc_it-bukrs

    saknr = podoc_it-hkont.

    • Header Data

    it_hdr-comp_code = podoc_it-bukrs.

    it_hdr-doc_date = sy-datum.

    it_hdr-pstng_date = sy-datum.

    it_hdr-doc_type = podoc_it-blart.

    it_hdr-ref_doc_no = bkpf_it-xblnr.

    it_hdr-username = sy-uname.

    it_hdr-bus_act = 'RFBU'.

    IF podoc_it-shkzg = 'S'.

    • First Item

    • Account number

    it_gl-itemno_acc = '1'.

    it_gl-gl_account = podoc_it-hkont.

    it_gl-item_text = podoc_it-sgtxt.

    it_gl-fis_period = v_monat.

    it_gl-fisc_year = v_gjahr.

    it_gl-acct_key = 'A00'.

    APPEND it_gl.

    • Second Item

    • Account number

    it_gl-itemno_acc = '2'.

    it_gl-gl_account = offset_it-osaknr.

    it_gl-item_text = podoc_it-sgtxt.

    it_gl-fis_period = v_monat.

    it_gl-fisc_year = v_gjahr.

    it_gl-acct_key = 'A00'.

    APPEND it_gl.

    • Set amount

    it_curr-itemno_acc = '1'.

    it_curr-currency = podoc_it-waers.

    it_curr-amt_doccur = podoc_it-wrbtr.

    APPEND it_curr.

    it_curr-itemno_acc = '2'.

    it_curr-currency = podoc_it-waers.

    it_curr-amt_doccur = podoc_it-wrbtr.

    it_curr-amt_doccur = it_curr-amt_doccur * -1.

    APPEND it_curr.

    ELSE.

    • First Item

    • Account number

    it_gl-itemno_acc = '1'.

    it_gl-gl_account = podoc_it-hkont.

    it_gl-item_text = podoc_it-sgtxt.

    it_gl-fis_period = v_monat.

    it_gl-fisc_year = v_gjahr.

    it_gl-acct_key = 'A00'.

    APPEND it_gl.

    • Second Item

    • Account number

    it_gl-itemno_acc = '2'.

    it_gl-gl_account = offset_it-osaknr.

    it_gl-item_text = podoc_it-sgtxt.

    it_gl-fis_period = v_monat.

    it_gl-fisc_year = v_gjahr.

    it_gl-acct_key = 'A00'.

    APPEND it_gl.

    • Set amount

    it_curr-itemno_acc = '1'.

    it_curr-currency = podoc_it-waers.

    it_curr-amt_doccur = podoc_it-wrbtr.

    it_curr-amt_doccur = it_curr-amt_doccur * -1.

    APPEND it_curr.

    it_curr-itemno_acc = '2'.

    it_curr-currency = podoc_it-waers.

    it_curr-amt_doccur = podoc_it-wrbtr.

    APPEND it_curr.

    ENDIF.

    • 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 <> 0.

    REFRESH t_result.

    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

    EXPORTING

    documentheader = it_hdr

    TABLES

    accountgl = it_gl

    currencyamount = it_curr

    return = t_result.

    *

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

    move: podoc_it-bukrs to doc_it-bukrs,

    podoc_it-belnr to doc_it-belnr,

    podoc_it-gjahr to doc_it-gjahr,

    podoc_it-shkzg to doc_it-shkzg,

    podoc_it-hkont to doc_it-hkont,

    offset_it-osaknr to doc_it-osaknr.

    ENDIF.

    • Print Message

    LOOP AT t_result.

    • WRITE: t_result-message.

    • Get Number

    IF t_result-id = 'RW' AND

    t_result-number = '605'.

    belnr = t_result-message_v2(10).

    gjahr = t_result-message_v2+14(4).

    ENDIF.

    move: belnr to doc_it-obelnr,

    gjahr to doc_it-ogjahr.

    ENDLOOP.

    append doc_it.

    clear: doc_it, podoc_it.

    endloop.

    loop at doc_it.

    write:/ doc_it-bukrs,

    doc_it-belnr,

    doc_it-gjahr,

    doc_it-shkzg,

    doc_it-hkont,

    doc_it-osaknr,

    doc_it-obelnr,

    doc_it-ogjahr.

    endloop.

    Thanks.

    If this helps you reward with points.

    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.