Skip to Content
avatar image
Former Member

Get file name from SAP Data service

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) *.


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • May 21, 2018 at 04:44 PM


    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';


    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.



    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 22, 2018 at 01:06 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded