cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping of POSTING KEY in BAPI_ACC_DOCUMENT_POST

Former Member
0 Kudos

Hi,

can anybody help me how can I map / pass the following POSTING KEY in BAPI_ACC_DOCUMENT_POST?

Type Posting Key Positive or Negative

GL 40 +ve (debit)

GL 50 -ve (credit)

AP 21 +ve (debit)

AP 31 -ve (credit)

AR 01 +ve (debit)

AR 11 -ve (credit)

thank you in advance!!!

james evert lising

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi,

For passing the posting key you need to use the extention structure of BAPI_ACC_DOCUMENT_POST and then use BADI ACC_DOCUMENT

with the other parameters you have to populate the extension table of bapi



data : it_ bapiparex type table of bapiparex,
         wa_bapiparex  type bapiparex

*     Populate the Extension table
      wa_bapiparex-structure  = 'POSTING_KEY'.
      wa_bapiparex-valuepart1 = '10'.            " Item number
      wa_bapiparex-valuepart2 = '40'.            " Posting Key
      APPEND wa_bapiparex TO it_bapiparex.


*     Call the Bapi to post the document
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader          = wa_docheader
      TABLES
        accountgl                    = it_bapiacgl09
        accountpayable           = it_bapiacap09
        currencyamount          = it_bapiaccr09
        return                         = it_bapiret2
        extension2                  = it_bapiparex

Now create an implementation of BADI ACC_DOCUMENT in SE19 and

write the following code in method CHANGE of BADI



  DATA:  wa_extension  TYPE  bapiparex,
              wa_accit      TYPE  accit.

  LOOP AT c_extension2 INTO wa_extension.

*   Extend BAPI to have Posting Keys defined by user
    IF wa_extension-structure = 'POSTING_KEY'.
      CLEAR wa_accit.
      READ TABLE c_accit INTO wa_accit
                         WITH KEY posnr = wa_extension-valuepart1.
      IF sy-subrc = 0.
        wa_accit-bschl = wa_extension-valuepart2.
        MODIFY c_accit FROM wa_accit INDEX sy-tabix TRANSPORTING bschl.
      ENDIF.

    ENDIF.

  ENDLOOP.

Hope this solves your problem

Regards,

Gaurav

.

Former Member
0 Kudos

Thank you very much for your reply, helped me with the posting!

Former Member

Thank you very much Jagya, it's really worked out!

Answers (3)

Answers (3)

Kenber
Explorer
0 Kudos

DATA:

accountpayable LIKE bapiacap09 OCCURS 0 WITH HEADER LINE,

currencyamount LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE.

positive amount of currencyamount-amt_doccur will get a debit posting key: 21.

negative amount of currencyamount-amt_doccur will get a credit posting key: 31.

0 Kudos

Hi ,

No need to pass the posting key explicitly, since system will be determined automatically based on debit and credit data entries at item level.

IF ls_post-newbs = '40'.

ls_currency-amt_doccur = ls_post-dmbe2.

ELSEIF ls_post-newbs = '50'.

ls_currency-amt_doccur = ls_post-dmbe2 * -1.

ENDIF.

Thank you.

Former Member
0 Kudos

You do not need to pass a posting key to the BAPI - SAP knows the kind of line item by the table type (ACCOUNTGL, ACCOUNTRECEIVABLE etc.) and the sign on the dollar amount - credits are to be sent as negative dollar amounts in CURRENCYAMOUNT table. No need to make or use an entension.

rah3
Participant
0 Kudos

That is correct... but extension might be helpful if they want to override it.

You have any idea how to post with Posting Key 31 ?? I am facing this issue.