5 Replies Latest reply: Jun 2, 2011 9:38 AM by Erick Vavretchek RSS

BAPI_ACC_DOCUMENT_POST with two currencies

Cárdenas Erasmo
Currently Being Moderated

Posting a document using BAPI_ACC_DOCUMENT_POST, I had used de BAPIACAP09 structure - ACCOUNTPAYABLE - to make an employee payment.

This structure forces a different payment currency to the one used in the document.

Could you tell me how can I program the system to use only one type of currency, I mean, how I can use this function and this structure so it allows me to use the same type of currency?

Thanks!!

  • Re: BAPI_ACC_DOCUMENT_POST with two currencies
    Srinivas Adavi
    Currently Being Moderated

    Hi,

     

    If you read the documentation, it clearly mentions that the currency type has to be defined for each line item seperately through another parameter CURRENCYAMOUNT structure BAPIACCR09.

     

    Are you passing this structure?

     

    Please see the documentation of this parameter and the ACCOUNTPAYABLE parameter.

     

    Srinivas

  • Re: BAPI_ACC_DOCUMENT_POST with two currencies
    Cárdenas Erasmo
    Currently Being Moderated

    This is part of a sample program

     

    • Document header.

    dochdr-header_txt = 'Nomina prueba'.

    dochdr-comp_code = 'ASTO'.

    dochdr-doc_date = '20050504'.

    dochdr-doc_type = 'NM'. " Clase de documento.

    dochdr-obj_type = 'FKKSU'. " Operacion de referencia.

    dochdr-obj_key = '$'.

    dochdr-OBJ_SYS = 'ASTO240'.

    dochdr-pstng_date = '20050504'.

    dochdr-bus_act = 'RFBU'.

    dochdr-username = sy-uname.

    dochdr-fis_period = '05'.

    APPEND dochdr.

     

    • First value

    curamnt-itemno_acc = 1. " Posicion

    curamnt-curr_type = '00'.

    curamnt-currency = 'COP'. " Clave moneda

    curamnt-amt_doccur = 50000.

    APPEND curamnt.

     

    acntgl-itemno_acc = 1. " Posicion en documento

    acntgl-gl_account = '5105030100'. " Cuenta de mayor

    acntgl-item_text = 'Centros Nomina'. " Texto de posicion

    acntgl-comp_code = 'ASTO'. " Compañia

    acntgl-vendor_no = '0016613119'.

    acntgl-costcenter = '0000051311'.

    acntgl-doc_type = 'NM'.

    acntgl-pstng_date = '20050504'.

    acntgl-acct_key = ''. "Clave de operación

    acntgl-cond_type = 'AS02'.

    APPEND acntgl.

    CLEAR acntgl.

     

    *Contrapartida

     

    • Second value

    curamnt-itemno_acc = 2. " Posicion

    curamnt-curr_type = '00'.

    curamnt-currency = 'COP'. " Clave moneda

    curamnt-amt_doccur = -50000.

    APPEND curamnt.

     

    • Employee payment

    • Here I had used 'COP' as the pymt_cur parameter.

    • The function guives an error message.

    • It works guiving another currency like 'USD', the BSEG table still with 'USD' in the PYCUR field.

    *

    w_paymnt-itemno_acc = 2. " posicion

    w_paymnt-pymt_meth = 'C'.

    w_paymnt-vendor_no = '0016613119'. " Cliente

    w_paymnt-comp_code = 'ASTO'. " Compañia

    w_paymnt-pymt_amt = -50000.

    w_paymnt-pymt_cur = 'COP'.

    w_paymnt-PYMT_METH = 'C'.

    w_paymnt-sp_gl_ind = ''. " Indicador CME

    w_paymnt-pmnttrms = 'AS02'.

    APPEND w_paymnt TO paymnt.

    CLEAR w_paymnt.

     

    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

      EXPORTING

        documentheader          = dochdr

      TABLES

        accountgl               = acntgl

        accountpayable          = paymnt

        currencyamount          = curamnt

        return                  = return.

     

     

    This is the message:

    <<Enter a payment currency different to COP>>

     

    Regards!.

     

    • Re: BAPI_ACC_DOCUMENT_POST with two currencies
      Srinivas Adavi
      Currently Being Moderated

      The error is coming out of this function module FI_PAYMENT_CURRENCY_CHECK. Here is the flow. Try debugging it and see why.

      Function module FI_DOCUMENT_CHECK
        -->form CHECK_ACCIT
            --> form CHECK_PAYMENT_AMOUNT
                -->Function module FI_PAYMENT_CURRENCY_CHECK

       

      Somehow the function module FI_DOCUMENT_CHECK is getting called dynamically from the BAPI. If you put a break point in this function module and run your BAPI, you should be able to see.

       

      Srinivas

  • Re: BAPI_ACC_DOCUMENT_POST with two currencies
    Cárdenas Erasmo
    Currently Being Moderated

    Yes!, I did it previously.

     

    The first abap sentence of the function FI_PAYMENT_CURRENCY_CHECK is:

      IF I_PYCUR = SPACE

      OR I_PYCUR = I_WAERS.

        MESSAGE E873 WITH I_WAERS.

      ENDIF.

     

    The above sentence generates the error.

    I would like to know which is the theory about the use of the CURR_TYPE parameter in the BAPIACCR09 structure. Because when the default value is 00, it generates the error that we just mentioned. But, when the value is 10, it intent to look for the exchange rate between a null currency and the COP value.(/COP).

    The result that I will expect is to know under which conditions I could use this function with just (only) one currency (COP).

    I noticed that you have a good knowledge about this function, that´s why I wonder if you could guide me through the flow so I can see the result.

    If this function allows to compare two currency types (values), the document currency and the payment currency, why it doesn´t allow me to receive same values, anyway the condition will give me a result if is the same or different.

     

  • Re: BAPI_ACC_DOCUMENT_POST with two currencies
    Erick Vavretchek
    Currently Being Moderated

    Hi,

     

    Just in case you found this thread with the same problem.

    At least in my case what was happening is that I wanted to leave the currency fields blank (the same currency as payment value) but I was filling in ACCOUNTPAYABLE-PYMT_AMT, so was receiving error telling me that currency fields could not be empty. And if I set them to the same as payment, I would receive a message telling me that currency must be different.

     

    If you want to use only one currency you don't need to fill in these 3 fields:

     

     

    ACCOUNTPAYABLE-PYMT_AMT

    ACCOUNTPAYABLE-PYMT_CUR

    ACCOUNTPAYABLE-PYMT_CUR_ISO

     

    The same probably applies for the ACCOUNTRECEIVABLE table.

     

    Cheers,

    Erick

     

    Ps.

     

    Some extra text so you can find this thread by searching for error messages:

    Required field CURRENCY was not transferred in parameter ACCOUNTPAYABLE

    For the ISO code  there is no unique SAP currency code for ALE

     

     

     

    For the ISO code  there is no unique SAP currency code for ALE

     

        Message no. B1888

     

    Diagnosis

     

        There are several entries in TCURC for this ISO code, but none with the

        primary flag set.

     

    Procedure

     

        In table TCURC set the primary flag for ISO codes used multiple times.

     

    Required field CURRENCY was not transferred in parameter ACCOUNTPAYABLE

     

        Message no. RW602

     

    Diagnosis

     

        Field CURRENCY is required in parameter ACCOUNTPAYABLE for processing

        the document. The document is incomplete without this field.

     

    System Response

     

        The document cannot be processed.

     

    Procedure

     

        Enter a valid value in field CURRENCY in parameter ACCOUNTPAYABLE.

Actions