Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how BAPI recognize negative value amount?

Former Member
0 Likes
1,720

Hi!

I use BAPI_ACC_DOCUMENT_CHECK and have 3 tables:

gl_account, py_account and curr_amount.

I have a negative value amount, how to let this FM recognize the negative value amount?



FORM bapi_check . 
  CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
    EXPORTING
      DOCUMENTHEADER    = bapiache09
    TABLES
      ACCOUNTGL         = gl_account
      ACCOUNTPAYABLE    = py_account
      CURRENCYAMOUNT    = curr_amt
      RETURN            = ret_tab.
ENDFORM.                    " bapi_check

In the curr_amt table, I have 3 items with the amount:


itemno_acc      currency       amount        "the posting key is
001              RMB            324.14       " 40
002              RMB           6000.00       " 40
003              RMB           6324.14-      " 31

5 REPLIES 5
Read only

Former Member
0 Likes
1,014

The bapi has a inside functionality to handle -ve amounts...U just need to pass -ve amounts and it will be handled.

Read only

Former Member
0 Likes
1,014

Hi

It's easy you have to transfer you amount with sign, so if it's negative you have to transfer a negative number.

The BAPI simply check if the amount is greater or less than 0 by an IF statament.

IF amount is < 0, the Debit/credit indicator is H else S, so it can pick up from table T030B the correct posting key.

Anyway if you don't use a particolar transaction code the BAPI use only some posting key by default, you should consider:

- Account type is K (Vendor):

Debit/credit H (amount < 0) -> posting key 31

Debit/credit S (amount > 0) -> posting key 21

- Account type is S (G/L):

Debit/credit H (amount < 0) -> posting key 50

Debit/credit S (amount > 0) -> posting key 40

U can check the sign of posting key in table TBSL

Max

Read only

0 Likes
1,014

Hi,

I would like to make some correction on my question. Actually I have those values in excel file. And Posting Key <b>31</b> indicates the negative value.

I could find any field to fill in the posting key in curr_amt that will be exported to FM BAPI_ACC_DOCUMENT_CHECK.

How can I tell the FM that those values with posting key '31' are a negative values?

In the curr_amt table, I have 3 items with the amount:


itemno_acc      currency       amount        "the posting key is
001              RMB            324.14       " 40
002              RMB           6000.00       " 40
003              RMB           6324.14       " 31   is negative value

Read only

0 Likes
1,014

Hi,

the problem is solved by multiply the currency with -1.

Thanks for those answer. It's valuable and appreciated!


    IF wa_xcel-posting_key EQ '31'.
      wa_curr_amt-amt_doccur = wa_xcel-amount * ( -1 ).
    ELSE.
      wa_curr_amt-amt_doccur = wa_xcel-amount.
    ENDIF.

cheers,

ying ying

Read only

0 Likes
1,014

Hi

You can't do it, because you can indicate any posting key in the BAPI.

The BAPI decides automatically the posting key to be used.

Your question should be how the BAPI get the posting key.

Just as I said before, if the type of account of item is vendor and the amount is negative the posting key'll be 31 by default, if the account type is G/L and the amount is positive the posting key will be 40 by dafault.

I.e. the system'll use these posting key if the business transaction is <b>RFBU</b>

So you should fill the structure in this way:

- G/L Item 1:

BAPIACGL09-ITEMNO_ACC = '001'.

BAPIACGL09-ACCT_KEY = 'RFBU'.

....................................................

APPEND BAPIACGL09 TO ACCOUNTGL.

BAPIACCR09-ITEMNO_ACC = '001'.

BAPIACCR09-CURRENCY = 'RMB'.

MOVE '324.14' TO BAPIACCR09-AMT_DOCCUR.

APPEND BAPIACCR09 TO CURRENCYAMOUNT.

- G/L Item 2:

BAPIACGL09-ITEMNO_ACC = '002'.

BAPIACGL09-ACCT_KEY = 'RFBU'.

....................................................

APPEND BAPIACGL09 TO ACCOUNTGL.

BAPIACCR09-ITEMNO_ACC = '002'.

BAPIACCR09-CURRENCY = 'RMB'.

MOVE '6000.00' TO BAPIACCR09-AMT_DOCCUR.

APPEND BAPIACCR09 TO CURRENCYAMOUNT.

- Vendore Item 3:

BAPIACAP09-ITEMNO_ACC = '003'.

BAPIACAP09-ACCT_KEY = 'RFBU'.

....................................................

APPEND BAPIACAP09 TO ACCOUNTPAYABLE

BAPIACCR09-ITEMNO_ACC = '003'.

BAPIACCR09-CURRENCY = 'RMB'.

MOVE '6324.14-' TO BAPIACCR09-AMT_DOCCUR.

APPEND BAPIACCR09 TO CURRENCYAMOUNT.

In this way the system'll use those key, so the problem is if you need to use different posting key.

To indicate it needs to use different posting key it has to indicate a different <b>BUSINESS TRANSACTION</b> (see the fm FI_GET_POSTING_KEY).

Max