‎2006 Mar 29 7:01 AM
Hi All,
In smartforms a variable is defined as;
v_gamng(13) type c
A query put's the following value in this variable;
v_gamng = 1,000.000
When I goto do a calculation it throws a error message;
The program attempted to interpret the value "1,000.000 " as a number, but
since the value contravenes the rules for correct number formats, this was not possible.
Then I declared the following variable;
v_gamng_n like afko-gamng
This is a numeric when I went to assign;
v_gamng_n = v_gamng.
Yet it thows the same above error message.
Thanks,
Kishan
‎2006 Mar 29 7:04 AM
Kishan,
I am not sure why you have declared V_GAMNG as C. Shouldn't it be of TYPE I / P?
Regards,
Ravi
‎2006 Mar 29 7:04 AM
Kishan,
I am not sure why you have declared V_GAMNG as C. Shouldn't it be of TYPE I / P?
Regards,
Ravi
‎2006 Mar 29 7:07 AM
Hi Ravikumar,
Assume it has to be declared as V_GAMNG Type C. How could I convert this to numeric?
Thanks,
Kishan
‎2006 Mar 29 7:15 AM
See if you can use this function - CONVERT_FROM_CHAR_SORT_RFW
Regards,
Ravi
‎2006 Mar 29 7:31 AM
Points awarded accordingly.
If someone could give a example of using the FM CONVERT_FROM_CHAR_SORT_RFW. I would close the thread as solved.
Thanks,
Kishan
‎2006 Mar 29 7:49 AM
use this code.
data: amt(20) .
data: pamt(16) type p decimals 2 .
amt = '1,2345678.80' .
CALL FUNCTION 'MOVE_CHAR_TO_NUM'
EXPORTING
chr = amt
IMPORTING
NUM = pamt
EXCEPTIONS
CONVT_NO_NUMBER = 1
CONVT_OVERFLOW = 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.
Raja
‎2006 Mar 29 7:11 AM
What is the requirement that is forcing you to populate the values first into a Char field and then into a Packed value??
‎2006 Mar 29 7:12 AM
if u use data type c then v_gamng = <b>'</b>1,000.000<b>'</b>.
otherwise use F,P,I with decimals.
U can use format which store in profile->own data
or OY01
regards
vinod
‎2006 Mar 29 7:14 AM
Hi,
Just try putting the value from query into v_gamng_n.
Use the same for calculation.
‎2006 Mar 29 7:19 AM
‎2006 Mar 29 7:20 AM
Hi,
DATA: v_gamng(13) type c,
v_gamng_n like afko-gamng.
v_gamng = '10'.
SHIFT v_gamng LEFT DELETING LEADING space.
TRANSLATE v_gamng USING ', '.
CONDENSE v_gamng NO-GAPS.
MOVE v_gamng TO v_gamng_n.
Thanks,
Pramod
‎2006 Mar 29 7:23 AM
Hi,
Here is the sample code for converting the char into numeric.
data : v1(13),
v2 type afko-gamng.
v1 = '10,000.00'.
replace all occurrences of ',' in v1 with ''.
v2 = v1.
write v2.
‎2006 Dec 04 3:43 PM
Hi Kishnan,
"The program attempted to interpret the value "1,000.000 " as a number, but
since the value contravenes the rules for correct number formats, this was not possible. "
In my opinion the problem is that 1,000.000 is indeed no number. 1.000,000 would be a better way to use that. But you should try first to eliminate ',' and then try if '.' or ',' is recommended for correct number conversion.
If you solved that problem yet please let me know because i encountered another problem with packed numbers in smartforms.
Hope it helps,
Claus