cancel
Showing results for 
Search instead for 
Did you mean: 

Reading the file name and need to pass to fields?

Former Member
0 Kudos

Hi,

Can we read the file name and can pass to column?

   

This is the file name
    
Month_Company_Brand_YYYYMMDD.txt

                   

                                          I
need to read this file name and need to  capture ‘Company’ and ‘Brand’   and need to pass
to another fileds .. we can do that right?

                              
Can you let me know how to do that pls

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member211387
Contributor
0 Kudos

Hi,

You can achieve this by using the Source Information section in the file format object. This will appear when you are using the file format object as the source in a dataflow. double click on the fileformat object and at the bottom you can see the "Source Information" section. The default option is set to "No". You can change it to "Yes" and include the filepath if necessary.

Below is an illustration.

You can map the field DI_FILENAME in the output schema mapping and apply string operations to retrieve the Company and Brand information.

kind regards

Raghu

Former Member
0 Kudos

Hi nagarjun s,

in order to include the file name as a column you have to switch to 'yes' in the FILE FORMAT SOURCE EDITOR on the place shown below

the formula for the new output column in the Query Transformation should look like:

word_ext(DI_FILENAME, 2, '_') ||' '|| word_ext(DI_FILENAME, 3, '_')

I hope its helpful

Best regards

Goran

Former Member
0 Kudos

1) Refer link below. It clearly mentions how to include the filename as a column name in your target table.

http://scn.sap.com/thread/3680832

2) To read the 'Company' and 'Brand', you can use the word_ext function.

word_ext(DI_FILENAME,2,'_') will give you the company and word_ext(DI_FILENAME,3,'_') will give you the brand,

-Chaitanya

pan_cheng
Participant
0 Kudos

When you are processing the file you have option to include File name as column name. Once you check the option to yes then you can store the file name. After that you can prase it to store the required info.

Thanks,

Pan