Convert From One Currency to Another

Your rating: None Average: 2.5 (2 votes)

Always return to Peoplebooks when you are about to write a new function. A quick search might save you a lot of time. This is what I've done when I was about to write a new function to convert currency from US dollar to any other currency on the PS_RT_RATE_TBL (rate table).

PeopleSoft already delivers such a function for you to use. The function is ConvertCurrency.

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;

Please return to PeopleBooks > PeopleCode Reference for more details on the ConvertCurrency function.

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!