cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if file exists or not in SAP MII

former_member229176
Participant
0 Kudos

Hello Friends,

As per my requirements, I am reading bunch of files via TextLoader action block giving SourceURL path as /../RootFolder/Folder/MachineName/File.csv

This MachineName is dynamic and I am passing it via Repeater Output. So my Source URL is: "/../RootFolder/Folder" & Repeater_0.Output{Rowsets/Rowset/Row[ID = '#some-value#']/MachineName} & "/File.csv"

This works fine. But sometimes it happens that for some of the machine numbers, there are no File.csv so textLoader gives exception.

To avoid it, I am first getting file list via GetFileList action block giving same URL. IF count of file(GetFileList.List) is > 0 then I am giving the path to TextLoader else doing nothing.

Problem is for some of the machine numbers, this path contains multiple File.csv with different timestamps postfix with File Name such as File20150728188500 , File20150728188790 etc. In this case, I am reading the last file in the TextLoader. But when there are multiple files, GetFileList takes much more time in processing, in generating XML and creating performance problems.

Except to check for file exists or not and to avoid textLoader exception, I have no use of GetFileList. So what will be the optimal way to check for file existence so that TextLoader does not error out?

Soham

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Try to read the contents of the folder first (read file list block). Then repeat on each of the files in the folder (results on the previous block) and check if it matches the required name .. if it matches, do the textload.

Nikhil_Makhija
Participant
0 Kudos

Hi Soham,

You can use exception handling in MII BLS , try to use Catch action action block in BLS so whwnever you have a exception if file not found , execution goes to that block and then execute the  logic you need to execute on exception.