2008 Apr 15 9:32 AM
Hi
Currency S_WAERS is in my selection screen.
If i enter USD For S_waers the amount should convert to USD.
If i leave blank it should take local currency.
Any one pls give me the coding for this.
Thanks
Kumar
2008 Apr 16 1:45 AM
Just search SE37 with CONVERTCURRENCY* or the CURRENCYCONVERT* you will find lots of FM.
Regards,
Atish
Hi
Currency S_WAERS is in my selection screen.
If i enter USD For S_waers the amount should convert to USD.
If i leave blank it should take local currency.
Any one pls give me the coding for this.
Thanks
Kumar
2008 Apr 15 9:35 AM
2008 Apr 16 1:25 AM
Hi
what are the mandatory fields for this FM. I tried this. But it is not working properly
2008 Apr 16 1:45 AM
Just search SE37 with CONVERTCURRENCY* or the CURRENCYCONVERT* you will find lots of FM.
Regards,
Atish
2008 Apr 16 4:08 AM
Hi,
First, you should judge the amount's reference currency.
I take other currency as example, that is, the amount stores as neither USD nor local currency.
Functions will be used:
get local currency's FM:
1) LOCAL_CURRENCY_GET:
(this function returns the local currency by sales organization and distribution chanel or plant )
CALL FUNCTION 'LOCAL_CURRENCY_GET'
EXPORTING
PI_VKORG = ??sales organization
PI_VTWEG = ? distribution chanel
PI_WERKS = ? Plant
IMPORTING
PE_HWAER = ? local currency
EXCEPTIONS
INVALID_INPUT = 1
CURRENCY_NOT_DETERMINED = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2) FMR3_GET_LOCAL_CURRENCY:
(this function returns the local currency by company code)
CALL FUNCTION 'FMR3_GET_LOCAL_CURRENCY'
EXPORTING
I_BUKRS = ? company code
IMPORTING
E_HWAER = ? local currency
E_FIKRS =
E_KOKRS =
EXCEPTIONS
INVALID_WAERS = 1
WRONG_BUKRS = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
convert the amount to the target currency amont:
CONVERT_TO_LOCAL_CURRENCY
(this function returns the target amount)
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
DATE = SY-DATUM
FOREIGN_AMOUNT = ? amount
FOREIGN_CURRENCY = ? currency the amount stores
LOCAL_CURRENCY = ? target currency
IMPORTING
LOCAL_AMOUNT = ? target amount
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Therefore, the logic is :
if usd, CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY' set the target currency as USD then you'll get target amount
if blank, call the get local currency's FM and CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY' ,set the target currency as the local currency you get.
Hope it can help you.
regards
vincent.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |