Field function issue

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
xch2005
Participant
Posts: 85
Joined: Fri Apr 29, 2005 3:13 am
Location: India

Field function issue

Post by xch2005 »

Hi,

Basically we are trying to generate and extract when the run flag is "YES" and process type is "A" (or) "YES" and process type is "M" (or) "NO" and process type is "M".



Step 1 - An output text file is created with 2 columns and delimiter is comma (sample data in output file given below)

Sample file (first column is run flag and second is process type, manual or automatic):

NO,M

Step 2 - check the data in the output file from previous step. If the value in first column is "NO" and second has "A" then the execution should stop else continue

Step 3 - used a execute command activity in the job sequence as below , for the workflow to continue to next step

Code: Select all

	((Field(exc_run_or_no.$CommandOutput,",",1) = "YES" And Field(exc_run_or_no.$CommandOutput,",",2) = "A") Or 
	 (Field(exc_run_or_no.$CommandOutput,",",1) = "NO"  And Field(exc_run_or_no.$CommandOutput,",",2) = "M") Or 
  	 (Field(exc_run_or_no.$CommandOutput,",",1) = "YES" And Field(exc_run_or_no.$CommandOutput,",",2) = "M"))
Step 4 - given the below of the condition to stop the workflow (in another link of execute command stage in job sequence)

Code: Select all

(Field(exc_run_or_no.$CommandOutput,",",1) = "NO" And Field(exc_run_or_no.$CommandOutput,",",2) = "A")
Is there any issue with the FIELD function as the job does not continue even if the output file has NO,M in step 1?

Please let me know your thoughts, thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Your problem is not with the Field function, although to be honest I didn't look at your syntax all that closely. I'm wagering your issue is going to be the traditional one where $CommandOutput has a Field Mark (@FM) in it and you need to remove them from the output before you do your comparison because it is adversely affecting your Process Type check.

:idea: Probably best to do the manipulation in a User Variables Activity stage once and then refer to them multiple times afterwards rather than parse the command output over and over (and over) like that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What exactly does the Execute Command activity do? That is, what command does it execute?
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 »

I was wondering the same thing but guessing... cat.
-craig

"You can never have too many knives" -- Logan Nine Fingers
xch2005
Participant
Posts: 85
Joined: Fri Apr 29, 2005 3:13 am
Location: India

Post by xch2005 »

Thanks chulett and Ray.

In the execute command activity, it is just cat <filename> and text file is created in prior step with 2 columns delimited with comma.

So, do I need to add @FM for each column in the FIELD function?

Please advise.

Thank you.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

While perhaps you could do that, the standard approach would be to remove them from the output. Once. :wink:

Code: Select all

Convert(@FM,"",exc_run_or_no.$CommandOutput)
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply