‎2007 Aug 16 1:20 PM
Hi,
My requirement is like this.
I read transfer in units into a character field.
Now i need to check whether it is Less Than 0 or contains any alphabet.
Please tell me how to move this char field to an integer field.
Thanks & regards,
Neeraja
‎2007 Aug 16 1:25 PM
HI,
You can directly move it.
DATA : LV_CHAR(4) TYPE C.
LV_CHAR = '10'.
DATA : LV_INT TYPE I.
check lv_char ca 'abcdefgh....z'. " To check if it conains any alphabets
LV_INT = LV_CHAR.
WRITE LV_INT.
Thanks,
Mahesh
‎2007 Aug 16 1:25 PM
HI,
You can directly move it.
DATA : LV_CHAR(4) TYPE C.
LV_CHAR = '10'.
DATA : LV_INT TYPE I.
check lv_char ca 'abcdefgh....z'. " To check if it conains any alphabets
LV_INT = LV_CHAR.
WRITE LV_INT.
Thanks,
Mahesh
‎2007 Aug 16 1:27 PM
Hi mahesh,
i tried this way, but i am getting run time error .
Can please clearify.
Thanks ,
Neeraja
‎2007 Aug 16 1:34 PM
Use this code.
data: lv_char(10), lv_int type i.
if lv_char co '0123456789'.
lv_int = lv_char.
endif.Please mark points if the solution was useful.
Regards,
Manoj
‎2007 Aug 16 1:34 PM
HI Neeraja,
You can try using the function module NUMERIC_CHECK for checking that ur char field contains an alphabet or not.
IF htype = 'NUMC'.
then the field doesn't have any alphabets.
elseif htype = 'CHAR'
then the field is containing alphabets.
if the field didn't have any alphabets u can then move it directly to int field.
Regards,
kasinath.
‎2007 Aug 16 1:35 PM
Move the field inside a TRY ENDTRY block with a CATCH for CONVERSION_ERRORS. If no error occurs, then check if less than zero. If an exception occurs, the code in the CATCH can issue relevant message.
Andrew
‎2007 Aug 16 1:35 PM
Hi Neeraja
data: a(10) type c,
b(10) type n.
a = '123'.
b = a.
write:/ b.
b = 0000000123.
reward points if helpful,
Use the standard function module MOVE_CHAR_TO_NUM