Updating totals through code

SUGGESTED

Hi Guys

I'm quite new to how the development works in Sage X3 

Am trying to calculate totals based on a currency on the Purchase order Screens

Have added a new field to the Purchase Order table and POH3 screen

field: ZTTVORD

so based on the currency it needs to give me a total value of  field TOTLINATI / ***

it only works for the first currency in my code but not for the rest.

If anyone could please give me some more insight to this it would be great

Below is my code, current version of Sage is X3V11 

$ACTION
Case ACTION
When default
Endcase
Return

Subprog AV_ZTTVORD(VALEUR)
Variable Decimal VALEUR

If [M:POH1]CUR = 'ZAR'
VALEUR=[M:POH3]TOTLINATI/13.44322
EndIf
If [M:POH1]CUR = 'MZN'
VALUER=[M:POH3]TOTLINATI/58.53397
Endif
If [M:POH1]CUR = 'TZS'
VALUER=[M:POH3]TOTLINATI/2269.93850
Endif
If [M:POH1]CUR = 'GBP'
VALUER=[M:POH3]TOTLINATI/0.75807
Endif
If [M:POH1]CUR = 'EUR'
VALUER=[M:POH3]TOTLINATI/0.85515
Endif
If [M:POH1]CUR = 'USD'
VALUER=[M:POH3]TOTLINATI
Endif

End