on 07-13-2015 9:59 AM
I have to schedule a job at 9am and it could run based on file event.That means, My bods job has to check wether file has arrived or not within 10 minutes like this it has to check 6 times every 10minutes if doesn't arrive then it has send an email,if its arrive it should run.
Iam completely novice to bods and it would be great if any one share complete logic detailly. However, I have found script on other post
which test file is arrived or not for ten minuts, but as per my requirement it has to verify 6 times for every ten minutes. please show your insight on it.
Wait for a file
$FileName= 'C:\\DIR\\FlatFile_' || to_char( sysdate( ), 'YYYYMMDD' ) || '.csv';
print ( $FileName );
While ( file_exists ( $FileName ) = 0 )
Begin
print( 'Waiting for File' );
Sleep(600);
End
print ( 'File Received Successfully' );
print ( 'File Processing Started' );
if (wait_for_file ( file_name_pattern, 3000000, 600000) <> 1) then
begin
smtp_to(.... ); # send mail
raise_exception('No valid file found');
end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1/. Simply add a line at the end of the script:
print('The file has arrived and job started');
2/. You don't have to "call" the data flow. Just include it after the script (connect the dots!) in the embedding job or work flow. When the file doesn't arrive, the job terminates as a result of the raise_exception function call; when it does, the script terminates with the print statement and the data flow will be started.
Hello Srinath,
Best practice is to Isolate such file wait activity from BODS jobs.
For an exact problem, we implemented VB-Script which take four parameters -
We dint implement "email upon no files" but instead, script returns error number which can be captured as a response in BODS exec function and take necessary actions.
When file arrival is complete, script will execute the batch file corresponding to BODS job.
Add "batch file name to execute upon file arrival" as 5th parameter to your script. It will be a perfect reusable artifact.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Chetan, Thanks for response and suggestion. However, as per my client everything has to be inside the BODS, if we go vb script or unix shell script its out of bods that which client doesn't wants to implement it. In fact, I too have shell script which checks every 10 minutes 6 times calls bods job(.sh) but client doesn't wants to go out of bods control.
Hi Srinath,
The script you quoted will wait indefinitely for file until it arrives.
Not sure if we can break loop using a incremental counter inside loop.
Or else, you will have to modify a bit. Instead of while loop, use "if else if block"
I dint check for syntax, script will be somewhat similar to the below:
$FileName= 'C:\\DIR\\FlatFile_' || to_char( sysdate( ), 'YYYYMMDD' ) || '.csv';
print ( $FileName );
IF ( file_exists ( $FileName ) = 0 )
Begin
print( 'Waiting for File - attempt 1' );
Sleep(600);
Else IF ( file_exists ( $FileName ) = 0 )
Begin
print( 'Waiting for File - attempt 2' );
Sleep(600);
Else IF ( file_exists ( $FileName ) = 0 )
Begin
print( 'Waiting for File - attempt 3' );
Sleep(600);
Else IF ( file_exists ( $FileName ) = 0 )
Begin
print( 'Waiting for File - attempt 4' );
Sleep(600);
Else IF ( file_exists ( $FileName ) = 0 )
Begin
print( 'Waiting for File - attempt 5' );
Sleep(600);
Else IF ( file_exists ( $FileName ) = 0 )
Begin
print( 'Waiting for File - attempt 6' );
Sleep(600);
Else
print( 'File wait failed' );
#<raise exception to kill the job if required>
End
print ( 'File Received Successfully' );
print ( 'File Processing Started' );
Try and let me know.
I think I did the stupid way,
Try this logic- correct the syntax
$FileName= 'C:\\DIR\\FlatFile_' || to_char( sysdate( ), 'YYYYMMDD' ) || '.csv';
print ( $FileName );
$attempt = 0
While ( file_exists ( $FileName ) = 0 AND $attempt < 6)
Begin
print( 'Waiting for File' );
Sleep(600);
$attempt = $attempt + 1;
End
If $attempt < 6
print ( 'File Received Successfully' );
Else
print ( 'no files' );
#<do other actions>
End
Selective Reading and Postprocessing - Enterprise Information Management - SCN Wiki
Refer to DS reference guide for the function wait_for_file()
wait_for_file ( file_name_pattern, timeout, poll_interval,max_match, file_name_list, list_size, list_separator)
You can specify the timeout and poll_interval to achieve the requirement
Regards
Arun Sasi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.