cancel
Showing results for 
Search instead for 
Did you mean: 

Get file name from SAP Data service

Former Member
0 Kudos

Hi, I'm unable to read file name from data services which contain date_time format, I can read date but time can be variable, I've tried with *.csv on file name(s) property for flat file, but this for static file name.

Example of files: File_20180520_200003.csv, File_20180519_192503.csv, etc.

My script:

$Filename= 'File_'|| to_char(sysdate()-1, 'YYYYMMDD')|| '_'|| '*.csv'; 

I want to find a solution to read the 6 digits (any number) *.

Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank you for testing my issue.

Finally, I've found a solution by using

$Csv = word(exec('cmd','dir /b [$Filename]*.csv',8),2) ;

on the flat file (file name property), I've added $Csv

It works fine.

0 Kudos

Hello,

Using your example I created a test job with a global variable called $Filename. The script in the beginning of my job set the variable:

$Filename= 'File_'|| to_char(sysdate()-1, 'YYYYMMDD')|| '_'|| '*.txt';

print($Filename);

I then created a file format and pointed to the local file on my machine named File_20180519_192503.txt so I could import the schema. Note that after I imported the schema then I could really put anything for the filename here like File_111_1.txt. I could have built the schema manually as well.

I added a dataflow after my script and used the file format I just created as the source > double click to open it > change the filename to my global variable $Filename > run the job > completes successfully and loads data to my target temp table.

Best,

Christa