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

How to insert a name into a dynamic file name

Former Member
0 Likes
1,706

Hi Experts,

how do we need to insert a name into the dynamic file name.

For example we are getting the dynamic file name as

/zdata/G15/us/useiswtol1/glb/hroiswtl01/US16.USEISWTOL1.HROISWTL01.DAT'

so in between HROISWTL01 and .DAT we need to insert a name called FLAG.

Regards,

Harish Kasyap.

Hi Experts,

how do we need to insert a name into the dynamic file name.

For example we are getting the dynamic file name as

/zdata/G15/us/useiswtol1/glb/hroiswtl01/US16.USEISWTOL1.HROISWTL01.DAT'

so in between HROISWTL01 and .DAT we need to insert a name called FLAG.

Regards,

Harish Kasyap.

14 REPLIES 14
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,665

>

> For example we are getting the dynamic file name as

> /zdata/G15/us/useiswtol1/glb/hroiswtl01/US16.USEISWTOL1.HROISWTL01.DAT'

Where are you getting the dynamic filename from ?

Read only

Former Member
0 Likes
1,665

Hi Suhas,

we are getting the name from a functional module which is specific to our system and we cant change it.how to insert the name after retrieving the file name

Read only

Former Member
0 Likes
1,665

Which FM you are using to get dynamic file name ? is it FILE_GET_NAME or something else ? If you are using FM to get dynamic file name then check the parameter whether the FM returning only file name or not

Read only

Former Member
0 Likes
1,665

Yes, u can say we are using the Fm GET_FILE_NAME ...but after we get the FILE NAME we need to insert FLAG in the middle.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,665

Hi,

just usef fm /SAPDMC/LSM_PATH_FILE_SPLIT, it will split the file name and path name.

path = /zdata/G15/us/useiswtol1/glb/hroiswtl01/US16.USEISWTOL1.

filename = HROISWTL01.DAT

concatenate path 'FLAG' filename into path.

Read only

0 Likes
1,665

Hi Keshav,

if the file and path name is this

/ZDATA/G15/US/USEISWTOL1/GLB/HROISWTL01/US16.USEISWTOL1.HROISWTL01.000000000341.DAT

We need to replace the sequence number which we are getting at the end with a name called 'FLAG'

We cannot use " REPLACE" command as the sequence number changes dynamically

Regards,

Vishal'

Edited by: vishal_reddy786 on May 14, 2010 10:23 AM

Read only

0 Likes
1,665

We cannot use " REPLACE" command as the sequence number changes dynamically

Actually what do you want to replace.

is it the name of the file or anything else ?

Read only

0 Likes
1,665

Keshav,

As i said we are getting a sequence number in the end...... for example '000000000341'.

This sequence number should be replaced with a name called 'FLAG'.

Hope u got my point.'

Edited by: vishal_reddy786 on May 14, 2010 10:58 AM

Read only

0 Likes
1,665

Some more questions:

Is it always the same length , same position ?

After splitting the path and file how will the result look ( considering the path from your question ).

Read only

0 Likes
1,665

Yes Keshav,

The same lenght and same postion.

/ZDATA/G15/US/USEISWTOL1/GLB/HROISWTL01/US16.USEISWTOL1.HROISWTL01.000000000341.DAT

instead of above we need to get

/ZDATA/G15/US/USEISWTOL1/GLB/HROISWTL01/US16.USEISWTOL1.HROISWTL01.FLAG.DAT

Read only

0 Likes
1,665

so after splitting your file name will be 000000000341.DAT .


split filename at '.' into part1 part2.
concatenate path 'FLAG' '.' part2 into path.

or



if filename ca '.'.
sy-fdpos = sy-fdpos - 1.
filename+0(syfd-pos) = 'FLAG'.
clear path.
concatenate path filename into path.

Read only

Former Member
0 Likes
1,665

Hi Vishal,

Do this...

Split whole of your string into itab separated by '.'.

split <path> at '.' into table it_text.

Now, the second last record of your int tab would be the number you want to replace by "FLAG".

Just replace it with FLAG.

Now loop at it_text and merge the path into string again.

Regards,

Sumit

Read only

Former Member
0 Likes
1,665

Resolved

Read only

0 Likes
1,665

Please share the solution.

Sumit