2007 Sep 04 10:09 PM
I have a field which can have value as ABCD0123ef. Is there a function module which would return just the numeric part of it i.e 0123.
Please advise.
I have a field which can have value as ABCD0123ef. Is there a function module which would return just the numeric part of it i.e 0123.
Please advise.
2007 Sep 04 10:30 PM
Hi,
try this
data:v_type type char15 value 'ABCD0123e1f'.
data:v_num(10) type n.
v_num = v_type.
write:/ v_type,
v_num.
assign variable to a Numc type field.
Thanks,
Vamshi.
2007 Sep 04 11:09 PM
2007 Sep 04 11:13 PM
It's because the lenght of the string....You can use...
DATA: TEST(5) TYPE N.
That way, your going to have <b>01231</b> instead of <b>0000001231</b>
Greetings,
Blag.
2007 Sep 04 11:15 PM
That is not possible to define it before hand as numc(5). it could also be ABCD012334404ef.
2007 Sep 04 11:47 PM
Ok...It took me a while...But this code works -;)
DATA:v_type TYPE string VALUE 'ABCD012334404ef'.
DATA: regex TYPE string.
regex = 'D+'.
REPLACE REGEX regex IN v_type WITH space.
regex = 'D+'.
REPLACE REGEX regex IN v_type WITH space.
WRITE:/ v_type
Greetings,
Blag.
2007 Sep 04 11:51 PM
The code doesn't compile using the REGEX word as it is a reserved word.
2007 Sep 04 11:56 PM
Really? It compiled in my box...LOL
DATA:v_type TYPE string VALUE 'ABCD012334404ef'.
DATA: reg_ex TYPE string.
reg_ex = 'D+'.
REPLACE REGEX reg_ex IN v_type WITH space.
reg_ex = 'D+'.
REPLACE REGEX reg_ex IN v_type WITH space.
WRITE:/ v_type
This should works fine -;)
Greetings,
Blag.
2007 Sep 04 11:58 PM
2007 Sep 05 12:05 AM
Easy, simple way is something like this.
REPORT zrich_0002.
data: lv_str type string.
data: lv_str2 type string.
data: subset type string.
data: offset type i.
data: len type i.
lv_str = 'ABCD012334404ef'.
len = strlen( lv_str ).
do len times.
subset = lv_str+offset(1).
if subset CA '0123456789'.
concatenate lv_str2 subset into lv_str2.
endif.
offset = offset + 1.
enddo.
write:/ lv_str2.
Regards,
RIch Heilman
2007 Sep 04 10:54 PM
Hi Ankur,
Try this,
DATA : TEXT(100) TYPE C.
TRANSLATE TEXT USING 'A B C......X Y Z'.
Hopes it helps you.
Ali
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |