Sequence execution contrl based on file data value

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
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

Sequence execution contrl based on file data value

Post by mrvsr »

Hi,

Please help me creating a sequence that will execute based on the value of the file generated in the process.

We have 3 jobs. job1, job2 and job3.

Job1 will read source and write to a sequence file. sequence file will have one field called TYPE. It will containe 1 or 2 for all the records in the file.
It will be input for job2 and job3. We have to execute the job2 or job3 based on the TYPE fileld value in the file generated by job1.

---------- job2
:
Job1 -------------
:
----------- job3


Pleaes let me know how to design the sequence for this flow.
How to assign Type field value to job/sequence parameter in the job1.
or
Without using any unix script inbet ween sequences

Thanks
Thanks
MRVSR
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Create a routine to read/cat the file, use a Routine Activity stage to run and return this TYPE value. Then triggers or a Nested Condition stage can handle the branching based on the value returned.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

Post by mrvsr »

Hi Craig,

Thanks for the Solution.
Could you please tell me Is it possible to assign a value to the job parameter in job and use that parameter later in other job or sequence.
Also Please let me know is there any sample routine to read the file and return some value.
Thanks
MRVSR
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

For every record, you say?

Sounds like the easiest approach would be to use this file as the reference input to a Lookup stage at the start of Job2 and Job3 to determine whether to process that record. Run both Job2 and Job3 at the same time, if you have the resources.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ah, missed the "for every record" part. I'd suggest a Sequence job with a looping construct, in that case. Read the file into a UserVariables stage, feed that into a loop that runs one of the two jobs. Lather, rinse, repeat.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

Routine to read file and return value

Post by mrvsr »

Hi Craig,

Could you please tell me how to write a parallel routine to Read the below file \data\outfile.txt and "field 2" value of the first line.

outfile.txt file contents:
Craig,2,91883
Roy,2,909-88
john ckenix,2,23411
smith,2,12142
Thanks
MRVSR
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Parallel routine? Nope, not my bag baby. However, you don't need one - just some piped OS commands using DSExecute will work: "head -1" and "cut" for example.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

Post by mrvsr »

Hi Craig,

Thanks for solution.
I got one problem in comapring the script out put. The out put of th script is not matching with my condition though the output is same as I have given in the condition.

It is not executing the link with condition which should be true but executing other link(DSLink2).

I tried without UpCase and trim also.

Please see below the output of script and my condtions.

/data/TYPECHK.SH
Reply=0
Output from command ====>
xml

DSLink1:
UpCase(trim(Execute_Command_16.$CommandOutput)) = 'XML'

DSLink2
UpCase(trim(Execute_Command_16.$CommandOutput)) <> 'XML'


Please let me know if I need to do any other formating before checking the values.
Last edited by mrvsr on Tue Apr 15, 2008 10:35 am, edited 1 time in total.
Thanks
MRVSR
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Output like that is returned in a dynamic array, so you need to either remove any Field Marks (@FM) or just reference the first element. Try:

Code: Select all

UpCase(trim(Execute_Command_16.$CommandOutput<1>)) = 'XML' 
For example.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

Post by mrvsr »

Hi,

I tried In execute_command stage and Nested_condition stage.
giving below conditions but still its not working.

UpCase(Trim( Execute_Command_16.$CommandOutput[1]))="XML"
Execute_Command_16.$CommandOutput[1]="xml"
UpCase(Trim( Execute_Command_16.$CommandOutput[1]))='XML'
Execute_Command_16.$CommandOutput[1]='xml'
Execute_Command_16.$ReturnValue='xml'

Execute_Command_16.$ReturnValue=0

I dont understant why it is not able to compare the value which i am giving same as output from script.
Output from command ====>
xml
Thanks
MRVSR
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

Post by mrvsr »

Hi,

I tried In execute_command stage and Nested_condition stage.
giving below conditions but still its not working.

UpCase(Trim( Execute_Command_16.$CommandOutput[1]))="XML"
Execute_Command_16.$CommandOutput[1]="xml"
UpCase(Trim( Execute_Command_16.$CommandOutput[1]))='XML'
Execute_Command_16.$CommandOutput[1]='xml'
Execute_Command_16.$ReturnValue='xml'

Execute_Command_16.$ReturnValue=0

I dont understand why it is not able to compare the value which i am giving as same as output from script.
Output from command ====>
xml[/quote]
Thanks
MRVSR
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Check what I posted and what you implemented - they ain't the same.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

Post by mrvsr »

Hi Craig,

I tried this one also but its giving error at compile as Exprected:expression
Then I replaced <> with [] and compiled. ( I am using Version '8')

UpCase(trim(Execute_Command_16.$CommandOutput<1>)) = 'XML'

also tried

Substrings(UpCase(Trim(Execute_Command_0.$CommandOutput )),1,1)
= 'X'

Substrings(UpCase(Trim(Execute_Command_0.$CommandOutput[1])),1,1) = 'X'

Please let me know if I am still missing any thing.
or is there any way to print Execute_Command_0.$CommandOutput and see the contents
Thanks
MRVSR
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Odd, I do that here under 7.x. :? Try:

Code: Select all

Convert(@FM,"",Execute_Command_16.$CommandOutput)="xml"
and see if that works.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mrvsr
Premium Member
Premium Member
Posts: 40
Joined: Fri Aug 03, 2007 8:33 am

Post by mrvsr »

Thanks a lot Craig,

Its Worked :D You mentioned to remove @FM in your first reply only But concentrated more on [1] and troubled you.

Once again Thanks for your time and sharing your immense knowledge with us.
Thanks
MRVSR
Post Reply