Processing list of files in a Sequence job

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
arun_im4u
Premium Member
Premium Member
Posts: 104
Joined: Mon Nov 08, 2004 8:42 am

Processing list of files in a Sequence job

Post by arun_im4u »

Hello,

I have to process a list of files in a loop in the sequence and I am running into an issue. First I get the list of files by doing a ls -m(Execute Command Activity) and then use the start loop activity to process the files thorugh the sequence of jobs one after the other.

The issue is the last file in the list does not pass through properly and the sequence aborts saying [ParamValue/Limitvalue is not appropriate]. I see that the output from the ls -m command has put a new line feed at the end of the last file name. I tried removing it in Ereplace and Convert, but it still gives the same issue.

Any help would be great.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a User Variables activity to remove the final line terminator from the output.

Code: Select all

Left(CmdActivity.$CommandOutput, Len(CmdActivity.$CommandOutput)-1)
This will work on both UNIX and Windows environments because DataStage has translated either kind of line terminator to field mark by the time it gets into the User Variables activity.

You might also like to convert the field mark characters (@FM) to something more amenable as the separator character for the StartLoop activity, for example semi-colon.

Code: Select all

Convert(@FM, ";", Left(CmdActivity.$CommandOutput, Len(CmdActivity.$CommandOutput)-1))
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 »

You're not the first to see this problem or to post about it here and yes you need to remove the last delimiter from the delimited list. Not sure how EReplace or Convert would be helpful, I seem to recall using substring to accomplish this - basically:

DelimitedList[1,length(DelimitedList) - 1]
-craig

"You can never have too many knives" -- Logan Nine Fingers
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

Convert @FM to blank or Extract the first field from the field mark delimited value will both work
arun_im4u
Premium Member
Premium Member
Posts: 104
Joined: Mon Nov 08, 2004 8:42 am

Post by arun_im4u »

Thanks Ray. It worked. I did not realize it was putting @FM at the end. I thought it was putting a Unix new line at the end.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Both things are happening.

The ls command puts a newline at the end, so as to position the cursor on the next line when issued interactively.

DataStage converts all line terminators to @FM so that applications are portable across platforms.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply