Getting error in $CommandOutput

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
moupanja
Premium Member
Premium Member
Posts: 6
Joined: Thu Aug 31, 2006 6:25 am

Getting error in $CommandOutput

Post by moupanja »

Hi All,

I'm using execute command stage to read each line of a file at a time. The file looks like~
3,123
4,456
2,677

Now when the sequencer runs for the first time, exec command reads the first line i.e 3,123. The value 3 is then passed to one of the job parameter A and the value 123 is assigned to another job parameter B.
Again for 2nd run it will assign the values from 2nd line in similar manner...and so on .
I'm extracting the first value by
A=Field(Execute_Command_0.$CommandOutput, "," ,1, 1)
B=Field(Execute_Command_0.$CommandOutput, "," ,2, 1)
But its throwing the following error~
Controller problem: Error calling DSSetParam(Account_ID), code=-4
[ParamValue/Limitvalue is not appropriate]

Can anyone help me please?
Thanks
Moumita
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Actually, you should be able to help yourself. Do an exact search of the forums for "ParamValue/Limitvalue is not appropriate" and you'll find this has been discussed many times.
-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 »

Does your file have an empty last line?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
moupanja
Premium Member
Premium Member
Posts: 6
Joined: Thu Aug 31, 2006 6:25 am

Post by moupanja »

Hi Ray,

The file has no new line at the end.
I've also checked in the forum and it is recommended to use @FM, so I tried with this command~
Field(Execute_Command_0.$CommandOutput,@FM ,2, 1)
but even then I'm getting the same error!
Is it an incorrect command?
Also can you please explain me why do we use @FM?
Thanks
Moumita
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Line terminators are mapped to @FM. In your case you correctly (originally) specified comma as the delimiter.

The problem is probably with the line terminators in your file. Can you please share how you are implementing "read each line of a file at a time"?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
akshu.agni
Participant
Posts: 17
Joined: Tue Jan 25, 2011 5:24 am
Location: Bangalore

Post by akshu.agni »

Use

Ereplace(Execute_Command_0.$CommandOutput,@FM,'' )
Aks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:?
Why?
The file is being read one line at a time (allegedly).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
moupanja
Premium Member
Premium Member
Posts: 6
Joined: Thu Aug 31, 2006 6:25 am

Post by moupanja »

ray.wurlod wrote:Line terminators are mapped to @FM. In your case you correctly (originally) specified comma as the delimiter.

The problem is probably with the line terminators in your file. Can you please share how you are implementing "read each line of a file at a time"?
Hi Ray,

My design is like~

Start Loop-->Exec Command-->MyJob-->End Loop

In the Exec Command stage I'm giving this command to fetch each line at a time:
sed -n '#StartLoop_Activity_3.$Counter#p' <filename>
I have set the counter from 1 to 3 to read the three lines.
Thanks
Moumita
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try this approach. Read the entire file before the loop. Convert the line terminators into, say, pipe characters and use that to delimit your "list of things" loop. Within the loop use Field() functions to parse the comma-delimited lines.

Code: Select all

ExecuteCommand:  cat #filename# | tr '\n' '|'
StartLoop:  Delimiter = "|"
Parameter derivation 1:  Field(StartLoop.$Counter, ",", 1, 1)
Parameter derivation 2:  Field(StartLoop.$Counter, ",", 2, 1)
It's probably useful also to check that $Counter is not empty - perhaps a NestedCondition 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.
moupanja
Premium Member
Premium Member
Posts: 6
Joined: Thu Aug 31, 2006 6:25 am

Post by moupanja »

Hi Ray,

Thanks a lot for the workaround!
Although my job has finished successfully and generating the desired output but the sequencer is aborting with the same error for the 4th iteration.
Since the output of your Exec command is generating a '|' delimiter at the end of the last record too hence the loop is going for 4 iterations instead of 3.
Its throwing the error only for the 4th iteration~
seq_num_rec_1..JobControl (@StartLoop_Activity_3): Loop through list (4 items): iteration 4
seq_num_rec_1..JobControl (@Job_Activity_5): Controller problem: Error calling DSSetParam(No_of_Rec), code=-4
[ParamValue/Limitvalue is not appropriate]


I tried to write a script to eliminate the last '|' charecter from the output of the command cat #filename# | tr '\n' '|', but even then its giving the same error!
Any suggestions for this problem?
Thanks
Moumita
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

ray.wurlod wrote:It's probably useful also to check that $Counter is not empty - perhaps a NestedCondition activity.
Did you check this?
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or attempt again to remove the last delimiter. Not sure what you tried, but you should be able to simply substring what you need before it hits the Start Loop. Take everything from 1 through (length-1).
-craig

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