Date in file name : Logic to abort.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
kumar444
Premium Member
Premium Member
Posts: 62
Joined: Wed Jan 12, 2011 10:01 am

Date in file name : Logic to abort.

Post by kumar444 »

Hi,
I need to determine a logic for the below scenario.
I have an input file name as file_mmddyyyy.txt. Also run time parameter DATE as YYYY-MM-DD . I need to abort the job with a fail status if the date in the input file name that is mmddyyyy is not equal to the DATE from input parameter i.e YYYY-MM-DD.
I think this can be implemented in Before Routine-ExecSH or else in transformer. Greatly appreciate if you can come up with a logic.
-------------------------------------------
Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Don't even start the job if your condition is not met. Test it in a sequence.
Where does the file name come from? Simply extract the date component from that, reformat the date appropriately and compare it to your criterion date in an Execute Command activity.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar444
Premium Member
Premium Member
Posts: 62
Joined: Wed Jan 12, 2011 10:01 am

Post by kumar444 »

Sorry Ray,
I have misinterpreted the requirement. I need to compare the incoming date field with the parameter date and if equal continue else abort the job and return the message with a failed status.
I think this can be implemented in transformer constraint.
Could you please suggest me an idea?
-------------------------------------------
Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Suddenly we're in a Transformer stage. So you intend to check the file name for every row you process? Where is the source of this "incoming date field"? Why do you want to abort the job?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar444
Premium Member
Premium Member
Posts: 62
Joined: Wed Jan 12, 2011 10:01 am

Post by kumar444 »

Actually the job has already been designed by somebody else.Now i have been asked to implement this logic. I have no other knowledge on this.
I know that input date field is coming from a flat file and parameter date is passed in a transformer using a scheduling tool at run time.
So I thought can establish a condition in the transformer for equality and when if not equal i have to abort the job with the failed message.
This is the only thing i have asked to do and gave me no other extra information.
-------------------------------------------
Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Constrain the output from the Transformer stage such that the incoming date field is equal to the parameter value.

Create an extra output from the Transformer stage. Mark this as Otherwise/Log and set a row limit on it of 1. The first mismatch will cause your job to abort.

I really don't like writing jobs that abort. I don't even like writing jobs that generate warnings.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar444
Premium Member
Premium Member
Posts: 62
Joined: Wed Jan 12, 2011 10:01 am

Post by kumar444 »

Thanks Ray.
You mean, to implement another output link and use otherwise/log and abort after rows as 1.

Can we do this without using an extra link?
-------------------------------------------
Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Not if you need the job to abort.

If you don't need the job to abort, but only to process rows for which the date matches, then go with the single output link.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
swapnilverma
Participant
Posts: 135
Joined: Tue Aug 14, 2007 4:27 am
Location: Mumbai

Post by swapnilverma »

Based on ur description ... you can handle this in unix itself ...


file_name=filenanme_ddmmyyyy
date=passed_date

grep $date $file_name

rc=?

if $rc = 0

rundsjob OR exit 0 and run the ds job separately from scheduling tool

else

print " wt ever "

exit 1




Additionally you can use cut command to manager ur date format ...

let me knw ur thoughts
Thanks
Swapnil

"Whenever you find whole world against you just turn around and Lead the world"
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

swapnilverma wrote:Based on ur description ... you can handle this in unix itself ...


file_name=filenanme_ddmmyyyy
date=passed_date

grep $date $file_name

rc=?

if $rc = 0

rundsjob OR exit 0 and run the ds job separately from scheduling tool

else

print " wt ever "

exit 1




Additionally you can use cut command to manager ur date format ...

let me knw ur thoughts
My thoughts? That you need to learn to spell. If you can, then you need to learn to write professionally when corresponding with others via DSXchange!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
swapnilverma
Participant
Posts: 135
Joined: Tue Aug 14, 2007 4:27 am
Location: Mumbai

Post by swapnilverma »

oho ho ho ...
some one look very upset ...

breath in breath out Ray ... I will keep in mind for future post ...
Thanks
Swapnil

"Whenever you find whole world against you just turn around and Lead the world"
Post Reply