‎2009 Jan 09 2:52 PM
hi experts
i have a string like str_a = 'abc##123'
i try to : split str_a at '##' into r1 r2.
i wish r1 = abc, r2 = 123,but it doesn't work.
another question is i want to translate a char into a decimal, is there any fm?
pls help and thanks a lot!
‎2009 Jan 09 3:08 PM
Hi Ilu,
I dont find any problem with the SPLIT statement with your try. Anyways please check the below code which may helps you. If it is from file processing then use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB instead of '#'.
Data: str_a type string value 'abc##123',
r1 type string,
r2 type string.
START-OF-SELECTION.
split str_a at '##' into r1 r2.
write:/ r1,r2.
Use function module MOVE_CHAR_TO_NUM to convert character to numeric.
Thanks,
Vinay
‎2009 Jan 09 2:59 PM
This is working for me..
DATA wa_char(10) TYPE c value 'abc##123'.
DATA : wa_chr(4),
wa_chr1(4).
SPLIT wa_char AT '##' INTO wa_chr wa_chr1.
write : wa_chr, wa_chr1.For char to decimal you could check as below:
IF wa_char CO '0123456789'.
wa_decimal = wa_char.
ENDIF.
Edited by: Ankesh on Jan 9, 2009 8:29 PM
‎2009 Jan 09 3:01 PM
Hi Liu,
use this way.
data : abc type string value 'abc##123'.
data : r1(3) type c,
r2(3) type c.
split abc at '##' into r1 r2.
write : r1, r2.
bye...
‎2009 Jan 09 3:08 PM
Hi Ilu,
I dont find any problem with the SPLIT statement with your try. Anyways please check the below code which may helps you. If it is from file processing then use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB instead of '#'.
Data: str_a type string value 'abc##123',
r1 type string,
r2 type string.
START-OF-SELECTION.
split str_a at '##' into r1 r2.
write:/ r1,r2.
Use function module MOVE_CHAR_TO_NUM to convert character to numeric.
Thanks,
Vinay
‎2009 Jan 09 3:20 PM
Hi,
Do as Vinaykumar has mentioned for the split statment.
For converting character to decimal , you can also try the PACK command.
DATA num(10) TYPE c VALUE '11000'.
DATA num_p(13) TYPE p DECIMALS 2.
PACK num TO num_p.
write : num.
write / num_p.
regards,
Advait
Edited by: Advait Gode on Jan 9, 2009 4:23 PM