Issue with Job sequencer

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
aladap12
Participant
Posts: 60
Joined: Fri Jul 20, 2007 1:15 pm
Location: NO

Issue with Job sequencer

Post by aladap12 »

Good Morning all and wish u happy new year

Secondly, we are using datastage server jobs with 7x release

I have issue with my job sequencer.

In my process i have job that writes data in flat file, in the next step we send that file to other server via FTP.
Some time we don't process any records, at that time empty file was sent to other server.

I have to change my job like if i don't have any data on the file, the i should not send this file to other server.

how would i achive this functonality in datastage

here in this job sequence i am using execute command activity. that will
fire the Ftp script and sends the file to other server

please let me know
krishna R
krishna.padalavkr@gmail.com
Morrisville, PA-19067
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In the Sequence job, before the FTP step, check the size of the file and don't trigger the FTP if the file is empty. Or check in your FTP script.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Use a execute command stage before your FTP stuff as Craig said.
So, your JOb sequencer design would be:

Code: Select all

ExtractJob --> ExecuteCommandStage --> FTP Job
In Executecommand stage use:
Command: awk
Parameters: '{print $1}' #TargetPath#/#FileName#

After extract job is completed, ExecuteCommandStage should invoke the Unix box to check the file content.
In the condition to FTP job use

Code: Select all

Trim(Convert(@FM, "", Execute_Command.$CommandOutput)) <> '' 
So, if file size is not equal to empty, the FTP job will trigger.
@FM is used to get rid of any linefeeds in the file.
Thanks and Regards!!
dspxlearn
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Rather than awk the entire file, a simple conditional expression could be used to check the file. For example:

Code: Select all

-s file        True if file exists and has size greater than zero.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Craig,

I was also checking the content of the file and if and blank spaces or line feeds, those will be converted to empty. Cause, with these stuff, the file size will be increased.

Code: Select all

Rather than awk the entire file, a simple conditional expression could be used to check the file. For example: 

Code: 
-s file        True if file exists and has size greater than zero.
Can you please let us know how this is used in the execute command stage?
Thanks and Regards!!
dspxlearn
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

With 'test'.

Code: Select all

test -s filename
Returns true if the file exists and is greater than zero bytes in size, otherwise it returns false. Reverse the check with the bang:

Code: Select all

test ! -s filename
Returns true if the file doesn't exist or exists and is zero bytes in size.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Craig,

Thank you very much!! New point noted. :D

aladap12 ,
If your issue is resolved please let us know the results and mark this thread as resolved. Manwhil, I will also test this.
Thanks and Regards!!
dspxlearn
aladap12
Participant
Posts: 60
Joined: Fri Jul 20, 2007 1:15 pm
Location: NO

Thanks a lot

Post by aladap12 »

Thanks for your valuble suggestions,

I will try this way and let u know if my prob is solveds

Thanks
Krishna :)
krishna R
krishna.padalavkr@gmail.com
Morrisville, PA-19067
Post Reply