Sequence loop 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
dubuku_01
Participant
Posts: 79
Joined: Fri Nov 18, 2011 2:18 pm
Location: chennai

Sequence loop issue

Post by dubuku_01 »

Hi all,

Below code displays the filenames in the given directory separated by comma. The last filename will not have comma at the end. I call this code as batch program from execute command and next to ec command i have the start loop and in that I selected the list loop and given the ec_command.output as looping values and delimiter as comma. For example if i have three files in the directory, the loop should run for three times. but the loop iteration 3 fails and only two files gets processed.

Code: Select all

@echo off
setlocal EnableDelayedExpansion
set line=
cd %1
for %%a in (*.csv) do set "line=!line!,%%a"
echo !line:~1!

Code: Select all

09:10:16: MOVE_TO_SOURCE (COMMAND move D:\Data\Projects_DEV\CAR_Reporting\Inbox\*.* D:\Data\Projects_DEV\CAR_Reporting\Source\) started
09:10:16: MOVE_TO_SOURCE finished, reply=0
09:10:16: LIST_OF_FILES_to_text_file (COMMAND D:\Data\Projects_DEV\CAR_Reporting\Batch\List_of_Files.bat) started
09:10:16: LIST_OF_FILES_to_text_file finished, reply=0
09:10:16: START_LOOP loop iteration 1 started
09:10:16: CAR_XLS_SSEQ (JOB CAR_XLS_SSEQ) started
09:10:35: CAR_XLS_SSEQ (JOB CAR_XLS_SSEQ) finished, status=2 [Finished with warnings]
09:10:35: START_LOOP loop iteration 2 started
09:10:35: CAR_XLS_SSEQ (JOB CAR_XLS_SSEQ) started
09:11:00: CAR_XLS_SSEQ (JOB CAR_XLS_SSEQ) finished, status=2 [Finished with warnings]
09:11:00: START_LOOP loop iteration 3 started
09:11:00: CAR_XLS_SSEQ (JOB CAR_XLS_SSEQ) started
09:11:00: Exception raised: @CAR_XLS_SSEQ, Error calling DSSetParam(env_filename), code=-4 [ParamValue/Limitvalue is not appropriate]
This shows the director results. Please advise.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

First suggestion would be to do an exact search on "ParamValue/Limitvalue is not appropriate" which should give you an idea what is going on.
-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 »

Why not just use DIR /B *.CSV to get a list of the file names? Then convert the line terminators to commas (maybe in a User Variables activity) and make sure that no empty lines occur. I suspect that the empty value (the last line, which has no file name) is the culprit.
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 »

Field Mark at the end of the string, me thinks.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dubuku_01
Participant
Posts: 79
Joined: Fri Nov 18, 2011 2:18 pm
Location: chennai

Post by dubuku_01 »

Hi All,

I tried with Convert(@FM,'',commandoutput) but still the same issue. i tried by giving a new line in the file. Currently I tried by having two file names in a sample file.

file1,file2

Above is the content of the file which i process.I use ec command activity and the command is "type filepath" In the trigger I remove the fieldmark and after execute command stage i have the start loop. First it takes file1 in the loop and processes perfectly. But for the sacond file am getting the error.

Please advise.

Sorry Ray, As am not a privileged user, am not able to see your comments. But thanks for giving your valuable inputs.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Still think it is the Field Mark. What happens when you try using array notation $CommandOutput<1> rather than the Convert() function?
-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 »

If not the field mark then it's the empty last line. "" is not a valid pathname. You have to program around that.
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 »

Right, except they've said repeatedly that it fails attempting to process the last filename, not that it tries to do one too many. So when they have two names it fails on the second iteration of the loop. :?
-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 »

That may be them not reading the log correctly.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
satishmailbox
Participant
Posts: 3
Joined: Thu May 17, 2007 4:47 pm

Post by satishmailbox »

dubuku_01 wrote:I tried with Convert(@FM,'',commandoutput) but still the same issue. i tried by giving a new line in the file. Currently I tried by having two file names in a sample file.
probably command output have new line at end
do this in user variable stage after command stage and read this value as input to loop:

Code: Select all

Trim(Convert(@FM,',',MOVE_TO_SOURCE.$CommandOutput),',','T')
above will convert all new lines to comma and remove the last comma.
Post Reply