‎2007 May 04 8:20 AM
I took a variable of type c
and another variable type i.
Now my question is :
I want to check the content in variable type c
either it is consisting of alphabets or numeric.
If it is numeric then i want to move it into type i variable.
‎2007 May 04 8:33 AM
Hi
use the FM C14W_CHAR_NUMBER_CONVERSION ,
if sy-subrc = 0 then it contains character field
Reward points if useful..
Regards
Nilesh
‎2007 May 04 8:28 AM
Hi.
You can say:
if var_c CO '0123456789'.
var_i = var_c.
endif.
Hope this helps.
‎2007 May 04 8:30 AM
Hi Srujan,
You can make use of 'CO'
Check help on 'log_exp - Comparison operators for character-type operands '
For 'CO'
Contains Only: True, if operand1 only contains characters from operand2. Upper/lower case and trailing blanks are taken into account for both operands. If operand2 is of type string and is initial, then the logical expression is false, unless operand1 is also of type string and is initial, in which case the logical expression is always true. If the result of the comparison is negative, sy-fdpos contains the offset of the first character in operand1, that is not contained in operand2. If the result of the comparison is positive, sy-fdpos contains the length of operand1.
Regards,
Suruchi
‎2007 May 04 8:31 AM
Hi again.
I forgot to include the comma (,) and the period (.)
There could be cases when these are also in the value of var_c.
Br!
‎2007 May 04 8:33 AM
Hi
use the FM C14W_CHAR_NUMBER_CONVERSION ,
if sy-subrc = 0 then it contains character field
Reward points if useful..
Regards
Nilesh
‎2007 May 04 8:36 AM
Hi Srujan ,
You can use the FM <b>CATS_NUMERIC_INPUT_CHECK</b> , this FM checks if the input is numeric or not , if not it raises an execption.
You can also use the FM <b>NUMERIC_CHECK</b>, this check the input and return the data type CHAR or Numeric .
Hope this helps.
Regards
Arun
‎2007 May 04 8:36 AM
‎2007 May 04 8:44 AM
data : text(10) type c value 'abc153f4a',
pos type i,
len type i,
v_text,
v_char(10),
v_chari(10),
v_int type i.
len = strlen( text ).
do len times.
v_text = text+pos(1).
if v_text ca sy-abcde.
concatenate v_cahr v_text into v_char.
condense v_char no-gap.
else.
concatenate v_cahri v_text into v_chari.
condense v_chari no-gap.
endif.
pos = pos + 1.
enddo.
v_int = v_chari.
write : / v_char, v_int.
regards
shiba dutta
‎2007 May 04 8:46 AM
Use the following , it will help u!
data : varc(5) type c VALUE '456re',
answer(5) type c ,
HTYPE LIKE DD01V-DATATYPE.
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
string_in = varc
IMPORTING
STRING_OUT = answer
HTYPE = HTYPE "--> returns numc in case of numeric else returns char
.
Regerds ,
Sooness