Register Login

BAPI for G/L postings

Updated May 18, 2018

REPORT gl_posting.

DATA:
* Structure for document header
g_docheader LIKE bapiache08,
* Table and header for G/L Account Line Items
gi_accountgl TYPE STANDARD TABLE OF bapiacgl08,
g_accountgl LIKE bapiacgl08,
* Table and header for Line Item Currency Fields
gi_amount TYPE STANDARD TABLE OF bapiaccr08,
g_amount LIKE bapiaccr08,
* Return
gi_return TYPE STANDARD TABLE OF bapiret2,
g_return LIKE bapiret2.


START-OF-SELECTION.
*---------------------------------------------------------
* HEADER DATA
*
* OBJ_TYPE Objekttypes can be found in table TTYP
* OBJ_KEY Seems that you can use any value
* OBJ_SYS Logical system. Logical ystems can be found in
* table TBDLS. If there is no logical system assigned

* to the client, assign it this way:
*
* Transaction: SPRO
* - Basis components
* - Application Link Enabling (ALE)
* - Sending and receiving systems
* - Logical systems
* - Define logical system
* - Assign client o logical system
*
*
*---------------------------------------------------------
g_docheader-obj_type = 'BKPFF'.
g_docheader-obj_key = '1'.
g_docheader-obj_sys = 'B3TCLNT800'.
g_docheader-username = sy-uname.
g_docheader-header_txt = 'BAPI test'.
g_docheader-comp_code = '1000'.
g_docheader-doc_date = sy-datum.

APPEND g_amount TO gi_amount.

*---------------------------------------------------------
* LINE ITEMS
*---------------------------------------------------------
* Item 1
g_accountgl-itemno_acc = '0000000001'.
g_accountgl-gl_account = '0000192600'.
g_accountgl-pstng_date = sy-datum.

APPEND g_accountgl TO gi_accountgl.


* Item 2
g_accountgl-itemno_acc = '0000000002'.
g_accountgl-gl_account = '0000192600'.
g_accountgl-pstng_date = sy-datum.

APPEND g_accountgl TO gi_accountgl.

*---------------------------------------------------------
* CURRENCY AND AMOUNT
*---------------------------------------------------------
* Item 1
g_amount-itemno_acc = '0000000001'.
g_amount-currency = 'EUR'.
g_amount-amt_doccur = 5000.

APPEND g_amount TO gi_amount.

* Item 2
g_amount-itemno_acc = '0000000002'.
g_amount-currency = 'EUR'.
g_amount-amt_doccur = -5000.

APPEND g_amount TO gi_amount.


END-OF-SELECTION.
* Call the BAPI function
CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
documentheader = g_docheader
* IMPORTING
* OBJ_TYPE =
* OBJ_KEY =
* OBJ_SYS =
TABLES
accountgl = gi_accountgl
currencyamount = gi_amount
return = gi_return

* EXTENSION1 =
.

LOOP AT gi_return INTO g_return.
WRITE: / g_return-message.
ENDLOOP.


Comments

  • 04 Feb 2009 12:59 pm Guest
    BKPFF is showing error in ecc6.0
  • 06 Feb 2009 12:49 pm Analyn
    There might be some fields not filled-up correctly or there might be some transaction errors that need to be corrected.

    Cheers,

    http://www.sap-knowledge.com

×