cancel
Showing results for 
Search instead for 
Did you mean: 

BODS - Multiple Flat Files - Selecting the Latest File

muthuram_shanmugavel2
Contributor
0 Kudos

Hi BODS Experts,

We have two requirements in our Project.

Please help us how to resolve this.

Question 1:

We have multiple flat files naming  --> Data_<uniquenumber>.csv


Now I have to load data from only one flat file which is created/modified at the latest.


So Please help us how can we write Data Services script language for this scenario.



Question 2:


Once data from the file is loaded, the file will be moved to Archive folder.


After 30 days, the file would be deleted in Archival folder.


So Please help us how can we write Data Services script language for this scenario.


Thanks & Regards,

Muthuram.

Accepted Solutions (1)

Accepted Solutions (1)

former_member187605
Active Contributor
0 Kudos

Write  a command file (.bat file or shell script) to manipulate your files and call these from DS with the exec built-in function. Assign the return value (e.g. the filename) to a global variable.

muthuram_shanmugavel2
Contributor
0 Kudos

Hi Dirk,

Thanks a lot

Can you please let me know How can I call batch file from Data services Script Language?

Former Member
0 Kudos

exec('cmd', 'batchFilePath');

former_member187605
Active Contributor
0 Kudos

Use the exec built-in function, fully docuented in the SAP Data Services Reference Guide.

Answers (1)

Answers (1)

Former Member
0 Kudos

I will assume you are doing this on Windows, if not it's even easier.

1. You can use something like this inside your batch script:


for /f %%i in ('dir *.xml /b /o-d') do copy %%i current.xml & goto :moveit

:moveit

next operation...

2. You can use this in your batch script to delete files in your archive directory older than 30 days


forfiles /p \path\to\archive /d -30 /m *.xml /c "cmd /c del @path" 2>nul

muthuram_shanmugavel2
Contributor
0 Kudos

Hi Brian,

Thanks a lot

naveen_vuppala2
Explorer
0 Kudos

Can you explain %%I is a variable and it hold file name .How to use in SAP BODS.