cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_ACC_DOCUMENT_POST , where to put the posting key

Former Member

Accepted Solutions (1)

Accepted Solutions (1)

kowong
Participant
0 Kudos

I have the same question to you,,,

have you solved your problem?

After refering to the source code of BAPI_ACC_DOCUMENT_POST ,,

i found out the posting key is determine by the ACCT_KEY of table ACCOUNTGL ...

to get what posting key it will retrieve, i refer to T030B ... i still cant solve my problem, how about you ?

Former Member
0 Kudos

Hi Kok Wei,

I have solved it. The posting key is determined by the GL's account type and CURRENCYAMOUNT-amt_doccur .

If the amount -ve it'll be posted as credit n vice versa.

You can check this program LACC9F20 and put debugger at line 1068. That program is part of BAPI's coding.

Clemenss
Active Contributor
0 Kudos

Hi,

I'm using BAPI_ACC_GL_POSTING_POST and I'm happy the posting keys are determined automatically and correct as 40 or 50 for debit/credit items regardsless of the entry order.

If you relly need user-defined posting keys use the extension table in combination with user exit.

regards,

Clemens

kowong
Participant
0 Kudos

what i need to do is to post a special G/L account, with posting key "09", on F-21 using BAPI_ACC_DOCUMENT_POST , special payment from the customer, GL account is the customer code.

still havent found the solution....

Message was edited by: Kokwei Wong

mrahhaoui
Participant
0 Kudos

Hi Clemens,

I use the same BAPI but I have one question. It is where you can in accountgl the receiving account (ZIELK)and the adjustment account (KORRK).

Thank in advance for your response.

Regards,

Mohamed.

Adi_Bathineni
Participant
0 Kudos

Mohammed,

If i'm not wrong you are asking about the posting key in the BAPI_ACC_DOCUMENT_POST.

In the above BAPI, we can pass the posting key only with in the EXtension2 strucutre, that will be useful in BADI implementation (BADI_ACC_DOCUMENT).

We can decide the posting keys by using the above BADI, otherwise the BAPI, it self decides the posting key based on the Amount.

if you still any doubts, please search sdn for my posts on this BAPI.

Thanks,

Adi.

Former Member
0 Kudos

Hello Kokwei Wong,

I once had the same problem and the only way out was to implement the BTE process RWBAPI01 which is called whenever you use the extension1 table of the BAPI_ACC_DOCUMENT_POST.

In my custom program I added this code

CONCATENATE 'PDR' 'BSCHL' INTO st_extension-field1  SEPARATED BY '-'.                              CONDENSE st_extension-field1 NO-GAPS.              

APPEND st_extension TO t_extension.                

and passed the t_extension table in the bapi tables extension1.

then I activated the BTE process RWBAPI01 (transaction FIBF) and in the function module I developed this code.

IF it_accit-blart = 'AI'.       "So that this would work only for this doc. type

    LOOP AT extension.

      SPLIT extension AT '-' INTO w_flusso w_campo.

      IF w_flusso = 'PDR' AND w_campo = 'BSCHL'.

        EXIT.

      ELSE.

        CLEAR: w_flusso, w_campo.

      ENDIF.

    ENDLOOP.

    IF w_flusso = 'PDR' AND w_campo = 'BSCHL'.

      LOOP AT it_accit WHERE koart = 'D'.

        IF it_accit-shkzg = 'H'.

          it_accit-bschl = '15'.

        ELSE.

          it_accit-bschl = '06'.

        ENDIF.

        MODIFY it_accit.

      ENDLOOP.

    ENDIF.

ENDIF.

of course this worked for my specific case but maybe this solution may be useful to you too.

let us know!

Answers (2)

Answers (2)

gaurab_banerji
Active Participant
0 Kudos

If you want to pass posting key then you have to enhance the BAPI and then use the extension / entension2. This is not a standard way to doing things.

My suggestion is to populate the accountsreceivable table when you want the customer to be credited. This is specially helpful for balancing out bad debts and clearing them.

In the example below, I have collated the data in such a way that the data is grouped together. There is a flag that a record is a customer record and if it is a customer then we will accounts receivable instead of glaccount.

 

  CLEAR lv_item.
  LOOP AT lt_collate INTO lwa_collate.
* Increment item number
    lv_item = lv_item + 1.
    IF lwa_collate-cust IS INITIAL.
* Fill Account GL if it is GL account
      CLEAR lwa_bapi_acctgl.
      lwa_bapi_acctgl-itemno_acc  = lv_item.
      lwa_bapi_acctgl-gl_account  = lwa_collate-hkont.
      lwa_bapi_acctgl-comp_code   = gv_bukrs.
      lwa_bapi_acctgl-pstng_date  = gv_bldat.
      lwa_bapi_acctgl-doc_type    = lco_doctype.
      lwa_bapi_acctgl-costcenter  = lwa_collate-kostl.
      lwa_bapi_acctgl-item_text   = lwa_collate-name1.
      lwa_bapi_acctgl-tax_code    = lco_tax_code.
      APPEND lwa_bapi_acctgl TO lt_bapi_acctgl.
    ELSE.
* Fill Account receivable if it is a customer
      CLEAR lwa_bapi_acctrcv.
      lwa_bapi_acctrcv-itemno_acc = lv_item.
      lwa_bapi_acctrcv-customer   = lwa_collate-kunnr.
      lwa_bapi_acctrcv-gl_account = lwa_collate-hkont.
      lwa_bapi_acctrcv-comp_code  = gv_bukrs.
      lwa_bapi_acctrcv-item_text  = lwa_collate-name1.
      APPEND lwa_bapi_acctrcv TO lt_bapi_acctrcv.
    ENDIF.
* Fill amounts
    CLEAR lwa_currencyamount.
    lwa_currencyamount-itemno_acc = lv_item.
    lwa_currencyamount-currency   = lwa_collate-waers.
    lwa_currencyamount-amt_doccur = lwa_collate-wrbtr.
    APPEND lwa_currencyamount TO lt_currencyamount.
  ENDLOOP.

  CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
    EXPORTING
      documentheader    = lwa_bapi_docheader
    TABLES
      accountgl         = lt_bapi_acctgl
      accountreceivable = lt_bapi_acctrcv
      currencyamount    = lt_currencyamount
      return            = lt_return.

* Check if the document is okay to post
  READ TABLE lt_return INTO lwa_return INDEX 1.
  IF lwa_return-type = lco_bapiret_s.
* Post the account document
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader    = lwa_bapi_docheader
      IMPORTING
        obj_key           = lv_objkey
      TABLES
        accountgl         = lt_bapi_acctgl
        accountreceivable = lt_bapi_acctrcv
        currencyamount    = lt_currencyamount
        return            = lt_return.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

If you use GLaccount only you will get results with posting key 40 and 50 for debit and credit accordingly. But if you use accountsreceivale instead for customers you will get debit and credit memos with pkey 1 / 11... you can check the generated document in fb03

hope this helps you.

Former Member
0 Kudos

somewhere i seen same posting , just search in this forum , and in sapfans.com.

and my suggesion is find out where-used list og that FM so u will come to know how to use this FM