Convert From One Currency to Another

时间:2022-09-24 19:04:46
The function is ConvertCurrency to convert currency from US dollar to any other currency on the PS_RT_RATE_TBL .
ConvertCurrency(amt, currency_cd, exchng_to_currency, exchng_rt_type, effdt, converted_amt [, error_process [, round] [, rt_index]])

The result of your conversion is placed in converted_amt. ConvertCurrency returns a Boolean value where True means a conversion rate was found and converted_amt calculated, and False means a conversion rate was not found and a value of one (1) was used.

 

Here is a sample code on how to use it:

/*get the max effective date from PS_RT_RATE_TBL to use in the function*/
 SQLExec ( "select %dateout(max(effdt)) from PS_RT_RATE_TBL where from_cur = :1 and to_cur = 'USD' and rt_type = :2", &TXN_CURRENCY_CD, &rt_type, &effdt );
                If ConvertCurrency (&AMOUNT, &TXN_CURRENCY_CD, "USD", &rt_type, &effdt, &AMOUNT_CONVERTED, "I" ) Then
                  &AMOUNT = &AMOUNT_CONVERTED;
               End- If;