‎2009 Apr 07 11:41 AM
Hi,
I'm using FM DYNP_READ_VALUES to get actual values from the screen. The problem is, the fieldvalue component of the output structure is of type CHAR, but the dynpro field is of type DEC, and I'm getting exception CX_SY_CONVERSION_NO_NUMBER when I'm trying to move the dynpro value ie. '46,20' to global variable of type DEC. Any way how to solve this?
Thanks in advance,
Regards,
Tomas
‎2009 Apr 08 6:10 PM
Hi Tomas,
you can use the following code:
-
DATA: L_FIELDFALUE(5) TYPE C VALUE '46,20',
OUTPUT(5) TYPE P DECIMALS 2,
L_DCPFM TYPE USR01-DCPFM.
*select the number notation format
SELECT SINGLE DCPFM INTO L_DCPFM FROM USR01 WHERE
BNAME = SY-UNAME.
CALL FUNCTION 'AMOUNT_STRING_CONVERT'
EXPORTING
AMOUNT_STRING = L_FIELDFALUE
DCPFM = L_DCPFM
WAERS = 'INR' " pass your countrys' currency
IMPORTING
AMOUNT = OUTPUT.
-
You can also use following function modules for different type of conversion:
AMOUNT_STRING_CONVERT
DATE_STRING_CONVERT
PERIOD_STRING_CONVERT
PRICE_STRING_CONVERT
UNITS_STRING_CONVERT
‎2009 Apr 07 11:50 AM
HI,
You can do this way..
DATA l_val type i.
DATA l_fieldvalue(10) type c value '45,20'. " values as returned from th FM
Replace ',' in l_fieldvalue with space.
Condense l_fieldvalue.
l_val = l_fieldvalue.
l_paramenter = l_val / 100. " l_parameter is the screen field and now you have 45.20 as value
" you can change 100 as per the number of decimals
‎2009 Apr 07 12:01 PM
Hi,
thanks for fast reply.
Yes I know I could "hack" it this way, but I was thinking of a more generic way, which would be suitable for other data types as well, ie. QUAN etc, independently of my language environment (Czech in my case, that's why numeric format is like '45,20').
Thanks again.
Regards,
Tomas
‎2009 Apr 08 6:19 PM
HI,
Then check this FM HRCM_STRING_TO_AMOUNT_CONVERT this will solve the problem.
DATA: l_char TYPE char10 VALUE '10,000.54'.
DATA l_betrg TYPE betrg.
CALL FUNCTION 'HRCM_STRING_TO_AMOUNT_CONVERT'
EXPORTING
string = l_char
decimal_separator = '.'
thousands_separator = ','
waers = 'INR'
IMPORTING
betrg = l_betrg
EXCEPTIONS
convert_error = 1.
WRITE l_betrg.
‎2009 Apr 08 6:10 PM
Hi Tomas,
you can use the following code:
-
DATA: L_FIELDFALUE(5) TYPE C VALUE '46,20',
OUTPUT(5) TYPE P DECIMALS 2,
L_DCPFM TYPE USR01-DCPFM.
*select the number notation format
SELECT SINGLE DCPFM INTO L_DCPFM FROM USR01 WHERE
BNAME = SY-UNAME.
CALL FUNCTION 'AMOUNT_STRING_CONVERT'
EXPORTING
AMOUNT_STRING = L_FIELDFALUE
DCPFM = L_DCPFM
WAERS = 'INR' " pass your countrys' currency
IMPORTING
AMOUNT = OUTPUT.
-
You can also use following function modules for different type of conversion:
AMOUNT_STRING_CONVERT
DATE_STRING_CONVERT
PERIOD_STRING_CONVERT
PRICE_STRING_CONVERT
UNITS_STRING_CONVERT
‎2009 Apr 08 6:38 PM
Venkatesan Nagiah,
FM you suggested are exactly what I need, thanks a lot. They work perfectly.
Thanks all others as well.
Regards,
Tomas
‎2009 Apr 08 6:21 PM
Hi,
Try the PACK statement.
[http://help.sap.com/saphelp_47x200/helpdata/EN/87/56d00722c011d2954a0000e8353423/content.htm]
regards,
Advait