01-31-2008 5:04 AM
Hello Experts,
I have the data as follows:
"943/2764//00101/1000/11111/////121/3405\"
The above data is stored in a structure ITAB.
I want to get the characters between the last "/" (forward slash) and the "\" (back slash), that is the value 3405.
Could you let me know how to go about it? Points to be awarded for sure. Thanks
01-31-2008 5:16 AM
Hi,
Try as follows:
data: begin of itab,
text(20) type c,
end of itab.
str = '943/2764//00101/1000/11111/////121/3405\'.
SPLIT str AT '/' INTO TABLE itab.
describe itab lines l_f_lines.
read itab index l_f_lines.
len = strlen(itab-text).
len = len - 1.
val = itab-text+0(len).
Write : / val.
01-31-2008 5:09 AM
Hi,
You can do it by do end endo
use search and split at / and again split / till you wont new one
finally read the string only the required portin
Regards
shiva
01-31-2008 5:11 AM
hi Prasad
Assumptions: 3405 will be always 4 characters...
lv_total = strln (itab-field).
lv_buff = lv_total - 5.
lv_final = itab-field+lv_buff(4).
01-31-2008 5:16 AM
Hi,
Try as follows:
data: begin of itab,
text(20) type c,
end of itab.
str = '943/2764//00101/1000/11111/////121/3405\'.
SPLIT str AT '/' INTO TABLE itab.
describe itab lines l_f_lines.
read itab index l_f_lines.
len = strlen(itab-text).
len = len - 1.
val = itab-text+0(len).
Write : / val.
01-31-2008 5:40 AM
01-31-2008 5:46 AM
Hi Debaprasad,
try this.
DATA : test(200) TYPE c,
len TYPE i,
result(20) TYPE c,
flag_done type c.
test = '943/2764//00101/1000/11111/////121/3405\'.
condense test.
DESCRIBE FIELD test LENGTH len IN CHARACTER MODE.
len = len - 1.
DO.
IF test+len(1) = '\'.
DO.
len = len - 1.
If test+len(1) = '/'.
flag_done = 'X'.
exit.
endif.
IF result IS INITIAL.
result = test+len(1).
ELSE.
CONCATENATE test+len(1)
result
INTO result.
condense result.
ENDIF.
ENDDO.
ENDIF.
if flag_done = 'X'.
exit.
endif.
len = len - 1.
ENDDO.
write result.
Regards,
Mohaiyuddin