2007 Aug 16 11:54 AM
Hi,
I have a requirement where in i have to split a URL
for ex: i have to split the below url into different variables
/thread/523646 [original link is broken]
but i have to split based on conditions:
1. split the url from the first '//' to '/'
2. split from '/irj/' to '?'
3. split at 'threadID=' till the end
Result should be like
//www.sdn.sap.com/
sdn/thread
523646&tstart=0
Regards,
Anil
2007 Aug 16 12:28 PM
Hi Anil,
Which release of SAP are you using, can you use the FIND statement?
You can specify first occurence and matching offsets with this.
Regards,
Chester
Respect is due to Tripat Pal Singh.
2007 Aug 16 12:28 PM
Hi Anil,
Which release of SAP are you using, can you use the FIND statement?
You can specify first occurence and matching offsets with this.
Regards,
Chester
2007 Aug 16 12:49 PM
2007 Aug 16 2:17 PM
Hi Anil,
Then you do have the FIND command, so you could try something like this:
data: lv_url type string value '/thread/523646 [original link is broken]'.
data: lv_url2 type string.
data: len type i.
data: pos1 type i.
data: pos2 type i.
data: pos3 type i.
find first occurrence of '//' in lv_url match offset pos1.
find first occurrence of '/irj/' in lv_url match offset pos2.
len = pos2 - pos1 + 1.
lv_url2 = lv_url+pos1(len).
write:/ lv_url2.
find first occurrence of '?' in lv_url match offset pos3.
len = pos3 - pos2.
add 5 to pos2.subtract 5 from len.
lv_url2 = lv_url+pos2(len).
write: / lv_url2.
Regards,
Chester
N.B. If you cannot guarantee "first occurrence" specify offset using pos fields.
2007 Aug 16 1:23 PM
try this.. i have done it upto the first 2 strings reqd... use the same logic for the last one
data: lv_url type string value '/thread/523646 <b>[original link is broken]</b>'.
data: lv_url2 type string.
data: lv_slash2(2).
data: lv_slashirj(5).
data: lv_quest.
data: len type i.
data: count type i value 0.
data: pos1 type i.
data: pos2 type i.
data: pos3 type i.
data: lv_times type i.
data: to1 type i.
data: to2 type i.
len = strlen( lv_url ).
do len times.
lv_slash2 = lv_url+count.
"write:/ lv_slash2.
if lv_slash2 = '//'.
pos1 = count.
endif.
count = count + 1.
enddo.
count = pos1 + 2. " start from that position
lv_times = len - count.
do lv_times times.
lv_slashirj = lv_url+count.
if lv_slashirj = '/irj/'.
pos2 = count.
exit.
endif.
count = count + 1.
enddo.
count = pos2 + 5.
lv_times = len - count.
do lv_times times.
lv_quest = lv_url+count.
if lv_quest = '?'.
pos3 = count.
exit.
endif.
* write:/ lv_quest.
count = count + 1.
enddo.
to1 = pos2 - pos1 + 1.
write:/ lv_url+pos1(to1).
to2 = pos3 - pos2 - 5.
pos2 = pos2 + 5.
write:/ lv_url+pos2(to2).
2007 Aug 16 3:13 PM
**Check the Example below, it serves your purpose
REPORT ZTRIP_TEST.
data:
url(255),
s1(255),
s2(255),
s3(255),
s4(255),
s5(255).
url = '/thread/523646 [original link is broken]'.
split url at '?threadID=' into S1 S2.
split s1 at 'irj/' into s3 s4.
split s3 at ':' into s1 s5.
write:/ s5,/ s4,/ s2.
**Reward points if useful, get back in case of query
2007 Aug 16 3:22 PM
2007 Aug 16 6:38 PM
Hi,
Thanks Kris...Chester and Tripat Praaji....ill try implementing using these examples....and will get back to this thread....
Regards,
Anil
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |