‎2009 Feb 06 10:50 PM
Hello Gurus,
I have a data steram like following:
C:\XXXXXXXXXXXXXXXXXXXXXXXXXXX\XXXXXXXXXXX\123.YYY
C:\XXXX\345.ERCG
I want to extract the alphabates which come after dot i.e
C:\XXXXXXXXXXXXXXXXXXXXXXXXXXX\XXXXXXXXXXX\123.YYY -> YYY
C:\XXXX\345.ERCG -> ERCG
Regards,
Rajesh.
‎2009 Feb 07 9:24 AM
Hi,
this code would help..
data:
w_s1 type string value 'C:\XXXXXXXXXXXXXXXXXXXXX\XXXXXXXXXXX\123.YYY',
w_s2 type string value '.',
w_s3 type string,
w_s4 type string.
split w_s1 at w_s2 into w_s3 w_s4.
write:/ w_s4.
Regards,
Mdi.Deeba.
‎2009 Feb 07 3:48 AM
Hi,
You can split the data at the .(dot) and move charecters after the dot into a variable
and write that variable so that all the charecters after the dot will come
Regards,
jaya
‎2009 Feb 07 3:51 AM
Hi,
You can use SEARCH for "."(DOT) and you will get position from SY-FDPOS and then taking offset to that string you will get alphabates which come after dot.
Regards
Pinaki
‎2009 Feb 07 4:35 AM
Hi,
try this .
date str(50) type c.
str = 'C:\XXXXXXXXXXXXXXXXXXXXXXXXXXX\XXXXXXXXXXX\123.YYY'.
data w_pos type i.
search str for '.' .
if sy-subrc eq 0.
w_pos = sy-fdpos.
endif.
add 1 to w_pos.
write 😕 str+w_pos(5).
Hope this works
‎2009 Feb 07 4:35 AM
Hi,
Use thsi funtion module..to split the file name and the path...
SO_SPLIT_FILE_AND_PATH
Regards
Kiran
‎2009 Feb 07 4:37 AM
Hi Rajesh ,
You can use string operations like split or search like this
SPLIT STRING AT '.' INTO w_dot w_alpha .
Now if you want only alphabets and no other special characters you can use something like this
if w_alpha ca sy-abcde .
This will give only the alphabets and no other numbers or specila characters are included .
Or you can go with offset like
w_string+0(w_count)
Here search for each character and you can do it incrementing the counter variable .
Hope this helps!
Much Regards ,
Amuktha .
‎2009 Feb 07 6:09 AM
Hi Rajesh,
All the above posts will work,
but there may be a problem arising when the path is as follows...
w_path = c:\data.dict\text.txt
for this kind of cases its better to write the code as mentioned below...
data w_length type i.
w_length = strlen( w_path ) - 1.
while w_path+w_lenth(1) <> '.' and w_length > 0.
subtract 1 from w_length.
endwhile.
add 1 to w_length.
w_file_ext = w_path + w_length.
Hope this helps you out.
Regards,
Siddarth
‎2009 Feb 07 6:26 AM
Hi,
This is Kiran again...
Use this function module definitely you can split the file name and its extension...I worked on my system...its working...
SPLIT_FILENAME
It splits the file name and its extension i.e. c:\temp\hello.txt would return 'hello' & 'txt'
Regards
Kiran
Edited by: Kiran Saka on Feb 7, 2009 7:27 AM
‎2009 Feb 07 9:24 AM
Hi,
this code would help..
data:
w_s1 type string value 'C:\XXXXXXXXXXXXXXXXXXXXX\XXXXXXXXXXX\123.YYY',
w_s2 type string value '.',
w_s3 type string,
w_s4 type string.
split w_s1 at w_s2 into w_s3 w_s4.
write:/ w_s4.
Regards,
Mdi.Deeba.