Hi experts,
My code processes all xls files in a specific folder & while processing per file if there is any validation failure it has to stop processing that file , however continue to process remaining files.
With below psuedo code of my original code , you would notice that objective 1 >Which is to stop processing the file as soon as there as an error is successfully met, however unable to meet objective 2 >which is that on an event file 1 errors out , continue to process file2 . I tried using checkfail but i m sure i did not use correctly because i was using checkfailed in place of throw error in catch block .
Could you please suggest a code/psuedo code fix to achieve objective# 2
Class myClass { public run() { System.IO.DirectoryInfo directory; System.IO.FileInfo[] files; System.IO.FileInfo file; InteropPermission permission; userid userid; MyTable myTable; counter filesCount; FilePath processedFilePath,processedFileCompletePath; Filename filename; Filename tmpFilePath = System.IO.Path::GetTempPath(); Filename tmpFileNameShort; Filename tmpFileExt; counter loop; str fileNameTemp,fileNameString; #FILE try { userid = curuserid(); if (userid != 'John Doe') { throw error ('You are not logged in as John Doe'); } select myTable; directory = new System.IO.DirectoryInfo(@myCustomTable.myPath); processedFilePath = @myCustomTable.myPath2; if ( directory == null || processedFilePath == '') { if (directory == null) { throw error ('myPath is null'); } else { throw error ('myPath2 is undefined'); } } files = directory.GetFiles('*.xls*'); filesCount = files.get_Length(); if (filesCount == 0) throw error('No file found' ,add the file & restart the process'); for (loop = 0; loop < filesCount; loop ) { file = files.GetValue(loop); fileNameTemp = file.get_FullName(); filename = fileNameTemp; if (strLen(fileNameTemp) > 0) { [tmpFilePath, tmpFileNameShort, tmpFileExt] = fileNameSplit(fileNameTemp); fileNameString= tmpFileNameShort tmpFileExt; info(strFmt('Import filename=%1', fileNameTemp)); if(tmpFilePath && tmpFileNameShort && tmpFileExt == #xls) { this.methodA(); } } }// for ends } // Try ends catch (Exception::CLRError) { throw error ('CLR ERROR Details ' CLRInterop::getLastException().ToString()); } catch { throw error(NON CLR ERROR); } } // run ends public methodA() { try { //Do somthing this.methodB() } catch { throw error ("Method A failed"); } }// method A ends public methodB(v1,v2,v3) { try { Do something if (v1 > 10) { throw error ("V1 geater than v1); } else if (v2 =='') { throw error ("V2 is blank"); } else { //do something } } catch { throw error ("Method b failed"); } } // method B ends }
Thanks
Mav