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

BAPI FUNCTION MODULE BAPI_ACC_DOCUMENT_POST : How to give posting keys?

Hi ,

i am using BAPI_ACC_DOCUMENT_POST to post accounting document. This accounting document is used to post amount from reconcilation account to bank GL account.the table parameter am using is ACCOUNTGL (in the function module)Now i want to give posting keys to the function module parameter. can anyone please guide me how to give posting keys?

Edited by: Santhosh Kumar Cheekoti on Dec 18, 2008 7:48 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 07:02 AM

    Hi,

    refer the following thread:

    bapiaccdocumentpost--gl-account-problem

    Regards,

    Rahul

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      posting keys are mainly to determine credits and debits.

      In the corresponding SAP screens ,if u are giving posting key 40 for debit and 50 for credit accounts,u will see the same 40 and 50 in document generated by BAPI given the same other data as in SAP screens.so when done through bapi, u dont need to bother about posting keys.just give sign to amounts.

      if user want to enter posting keys,what we did is, we simply gave posting key fields in non SAP screens where user can enter and see the values just to simulate the same SAP environment.

      there is a way to actually pass posting keys and thereby make bapi to put -ve signs automatically to credit amounts through EXTENSION parameters in the BAPI.u can search for that in forums.there r lot of links.

      but that method demands more effort.

      regards

      Arjun

      Edited by: Arjun Subhash on Dec 18, 2008 12:49 PM

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 07:07 AM

    Hi,

    I hope the below code will help you.

    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

    EXPORTING

    documentheader = lw_docheader

    IMPORTING

    obj_type = lv_obj_type

    obj_key = lv_obj_key

    obj_sys = lv_obj_sys

    TABLES

    accountgl = it_accountgl

    currencyamount = it_currencyamount

    return = it_return.

    Thanks & Regards,

    Khushboo.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 18, 2008 at 07:07 AM

    Hi,

    No need to pass posting keys.BAPI will automatically determine the posting keys from accounts,credit,debit and doc types passed.

    the posting keys will be same as we do through SAP transaction.

    give -ve sign to credit amouts in 'amount' field of 'currencyamount' table.

    u can leave obj_KEY,OBJ_SYS,OBJ_TYPE fields blank.

    regards

    Arjun

    Edited by: Arjun Subhash on Dec 18, 2008 12:38 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 07:28 AM

    Thanks every one

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 07:31 AM

    Hi,

    As pointed out in one of the previous post, posting key will be decided by the BAPI depending on the sign of the amount. Have a look at bthe following code:-

    DATA: doc_header LIKE BAPIACHE09,
          criteria   LIKE BAPIACKEC9 OCCURS 0 WITH HEADER LINE,
          doc_item   LIKE BAPIACGL09 OCCURS 0 WITH HEADER LINE,
          doc_ar     LIKE BAPIACGL09 OCCURS 0 WITH HEADER LINE,
          doc_values LIKE BAPIACCR09 OCCURS 0 WITH HEADER LINE,
          return     LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
          extension1 like BAPIACEXTC occurs 0 with header line,
          obj_type   LIKE bapiache08-obj_type,
          obj_key    LIKE bapiache02-obj_key,
          obj_sys    LIKE bapiache02-obj_sys,
          docnum     LIKE bkpf-belnr.
    *
    *DATA:
    *       ITEMNO_ACC	POSNR_ACC
    *       FIELDNAME	FIELDNAME
    *       CHARACTER	ACPI_RKE_CRIGEN
    *
    * Fill Document Header
    doc_header-bus_act = 'RFBU'.
    doc_header-bus_act = 'RMRP'.
    *doc_header-bus_act = 'SD00'.
    doc_header-username = sy-uname.
    doc_header-header_txt = 'TEST BOC BAPI POSTING'.
    doc_header-comp_code = 'IN10'.
    *
    doc_header-compo_acc = 'FICA'.
    *
    doc_header-doc_date = '20060127'.
    doc_header-pstng_date = sy-datlo.
    doc_header-doc_type = 'SA'.
    ** Fill Line 1 of Document Item
    *doc_item-itemno_acc = '1'.
    *doc_item-gl_account = '0000500001'.
    *doc_item-pstng_date = sy-datum.
    *doc_item-item_text = 'TEST POSTING DEBIT ITEM'.
    *doc_item-costcenter = ''.
    *doc_item-quantity = '1'.
    *doc_item-base_uom = 'ST'.
    *APPEND doc_item.
    *CLEAR doc_item.
    ** Fill Line 2 of Document Item
    *doc_item-itemno_acc = '2'.
    *doc_item-customer = '0000000016'.
    *doc_item-gl_account = '0000000016'.
    *doc_item-pstng_date = sy-datlo.
    *doc_item-item_text = 'TEST POSTING CREDIT ITEM'.
    **_______________
    *APPEND doc_item.
    *CLEAR doc_item.
    doc_ar-itemno_acc = '1'.
    doc_ar-gl_account = '0000500001'.
    doc_ar-pstng_date = sy-datum.
    doc_ar-item_text = 'TEST POSTING DEBIT ITEM'.
    doc_ar-costcenter = ''.
    doc_ar-quantity = '1'.
    doc_ar-base_uom = 'ST'.
    APPEND doc_ar.
    CLEAR doc_ar.
    * Fill Line 2 of Document Item
    doc_ar-itemno_acc = '2'.
    doc_ar-customer = '0000000016'.
    doc_ar-gl_account = '0000000016'.
    doc_ar-pstng_date = sy-datlo.
    doc_ar-item_text = 'TEST POSTING CREDIT ITEM'.
    doc_ar-stat_con = ' '.
    doc_ar-costcenter = '0000201681'.
    APPEND doc_ar.
    CLEAR doc_ar.
    * Fill Line 1 of Document Value.
    doc_values-itemno_acc = '1'.
    doc_values-currency_iso = 'INR'.
    doc_values-amt_doccur = '200.00'.
    doc_values-currency = 'INR'.
    doc_values-CURR_TYPE = '00'.  "Doc currency
    APPEND doc_values.
    CLEAR doc_values.
    * Fill Line 2 of Document Value
    doc_values-itemno_acc = '2'.
    doc_values-currency_iso = 'INR'.
    doc_values-amt_doccur = '200.00-'.
    doc_values-currency = 'INR'.
    doc_values-curr_type = '00'.  "Doc currency
    APPEND doc_values.
    CLEAR doc_values.
    * Add tax code in extension1 table.
    extension1-field1 = 'BAPI CALL'.
    APPEND EXTENSION1.
    *
    * Fill CRITERIA for CO-PA
    *
    *refresh criteria.
    *criteria-ITEMNO_ACC = '1'.
    *criteria-FIELDNAME	= 'ARTNR'.
    *criteria-CHARACTER	= '000000000001312251'.
    *Append criteria.
    *criteria-ITEMNO_ACC = '1'.
    *criteria-FIELDNAME	= 'WERKS'.
    *criteria-CHARACTER	= 'IN91'.
    *Append criteria.
    *criteria-ITEMNO_ACC = '1'.
    *criteria-FIELDNAME	= 'KNDNR'.
    *criteria-CHARACTER	= '0000000016'.
    *Append criteria.
    *criteria-ITEMNO_ACC = '1'.
    *criteria-FIELDNAME	= 'FKART'.
    *criteria-CHARACTER	= 'ZIN2'.
    *Append criteria.
    *criteria-ITEMNO_ACC = '1'.
    *criteria-FIELDNAME	= 'KAUFN'.
    *criteria-CHARACTER	= '0000000633'.
    *Append criteria.
    *criteria-ITEMNO_ACC = '1'.
    *criteria-FIELDNAME	= 'KDPOS'.
    *criteria-CHARACTER	= '000010'.
    *Append criteria.
    *criteria-ITEMNO_ACC = '1'.
    *criteria-FIELDNAME	= 'VKGRP'.
    *criteria-CHARACTER	= '009'.
    **Append criteria.
    *
    * All tables filled - now call BAPI.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
      EXPORTING
        documentheader       = doc_header
      IMPORTING
        OBJ_TYPE             = doc_header-obj_type
        OBJ_KEY              = doc_header-obj_key
        OBJ_SYS              = doc_header-obj_sys
      TABLES
    *    criteria             = criteria
        accountgl            = doc_item
        ACCOUNTRECEIVABLE    = doc_ar
        currencyamount       = doc_values
        return               = return
        EXTENSION1           = EXTENSION1.
    *
    LOOP AT return WHERE type = 'E'.
      EXIT.
    ENDLOOP.
    *
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader       = doc_header
      IMPORTING
        OBJ_TYPE             = doc_header-obj_type
        OBJ_KEY              = doc_header-obj_key
        OBJ_SYS              = doc_header-obj_sys
      TABLES
    *    criteria             = criteria
        accountgl            = doc_item
        currencyamount       = doc_values
        return               = return
        EXTENSION1           = EXTENSION1.
    LOOP AT return WHERE type = 'E'.
      EXIT.
    ENDLOOP.
    IF sy-subrc EQ 0.
      WRITE: / 'BAPI call failed - debug and fix!'.
    ELSE.
      CLEAR return.
      REFRESH return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    * EXPORTING
    *   WAIT          =
       IMPORTING
         return        = return.
      WRITE: / 'BAPI call worked!!'.
      WRITE: / doc_header-obj_key, ' posted'.
    ENDIF.
    

    Regards

    Raju Chitale

    Edited by: Raju Chitale on Dec 18, 2008 8:31 AM

    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.