Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Extracting data from data stream.

Former Member
0 Likes
1,119

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,017

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.

8 REPLIES 8
Read only

Former Member
0 Likes
1,016

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

Read only

Former Member
0 Likes
1,016

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

Read only

Former Member
0 Likes
1,016

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

Read only

Former Member
0 Likes
1,016

Hi,

Use thsi funtion module..to split the file name and the path...

SO_SPLIT_FILE_AND_PATH

Regards

Kiran

Read only

Former Member
0 Likes
1,016

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 .

Read only

Former Member
0 Likes
1,016

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

Read only

Former Member
0 Likes
1,016

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

Read only

Former Member
0 Likes
1,018

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.