reading sequential file

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
pandu80
Participant
Posts: 50
Joined: Fri Apr 08, 2005 5:56 pm

reading sequential file

Post by pandu80 »

Hi,
i wrote a routine which reads the sequential file and gives the output in a array.In this routins i have used Ans<-1> so that it reads the each record in new line. I want to pass this routine output to Start loop activity which accepts a input as a Comma,Space or other delimited string.

My question is ,The output of the routine was in row by row format so can i use LF as new line character(as a delimiter). I have used this but it shows wrong no of iterations in the loop.


any clues pls

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

Re: reading sequential file

Post by chulett »

pandu80 wrote:My question is ,The output of the routine was in row by row format so can i use LF as new line character(as a delimiter).
Nope. Your sequential file has that as a delimiter but an array doesn't. I'm not sure an array will work in this situation, with these 'Loop' stages. :?

You could try setting it to 'Other delimited string' and telling it @VM is the delimiter (or is it @FM? @AM? Heck if I recall right now) - as long as it will take a System Variable like that there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandu80
Participant
Posts: 50
Joined: Fri Apr 08, 2005 5:56 pm

Re: reading sequential file

Post by pandu80 »

how do convert that array into a single string with some delimiter or new line as delimiter character?.

Ans = Convert(@VM,"0A",Ans)

Is above works?


TIA
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No. "0A" will not be interpreted as a hex number; each @AM will be converted to "0" (the first character of the second argument.
What you need is

Code: Select all

Convert(@AM,Char(10),Ans)
or, if svLF is a stage variable initialized to Char(10)

Code: Select all

Convert(@AM,svLF,Ans)
which means you only evaluate Char(10) once rather than once per row
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandu80
Participant
Posts: 50
Joined: Fri Apr 08, 2005 5:56 pm

Post by pandu80 »

Hi,
Ans = Convert(@AM,Char(10),Ans) wil return the whole array as a single string?. If it return a string, How do i specify a delimiter in Start Loop Activity?.(as 10 or 0A or char(10))

any help would be apreciated.

TIA

ray.wurlod wrote:No. "0A" will not be interpreted as a hex number; each @AM will be converted to "0" (the first character of the second argument.
What you need is

Code: Select all

Convert(@AM,Char(10),Ans)
or, if svLF is a stage variable initialized to Char(10)

Code: Select all

Convert(@AM,svLF,Ans)
which means you only evaluate Char(10) once rather than once per row
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
You can reverse the conversion again!
Though I have used arrays as a return value from routines with no problem.
If it is of any interest they can be passed as reference and besides the warning at compile time it works.

As you want to use this in a loop activity I recommend finding a suiteable delimiter if you can from the values mentioned in the stage instead of converting your @AM to the Char(10).

So if your data can't contain a comma or vertical bar "|" use them as your delimiters and your loop stage should work fine.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If that's the intended purpose then don't convert to Char(10). Instead convert to some delimiter character that does not appear in your data, for example "|" (as suggested) or "~" or "\".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandu80
Participant
Posts: 50
Joined: Fri Apr 08, 2005 5:56 pm

Post by pandu80 »

Hi,
If i convert to some delimiter like "|". How do i specify this delimiter in StartLoop Activity?.
It accepts Coma,Space and Other. In the other can i directly specify "|" as delmiter or should i specify the ascii char value?.

TIA
ray.wurlod wrote:If that's the intended purpose then don't convert to Char(10). Instead convert to some delimiter character that does not appear in your data, for example "|" (as suggested) or "~" or "".
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

pandu80 wrote:It accepts Coma,Space and Other. In the other can i directly specify "|" as delmiter
Yes.
-craig

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