reading sequential file
Moderators: chulett, rschirm, roy
reading sequential file
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
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
Re: reading sequential file
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.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).
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
"You can never have too many knives" -- Logan Nine Fingers
Re: reading sequential file
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
Ans = Convert(@VM,"0A",Ans)
Is above works?
TIA
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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
or, if svLF is a stage variable initialized to Char(10)
which means you only evaluate Char(10) once rather than once per row
What you need is
Code: Select all
Convert(@AM,Char(10),Ans)
Code: Select all
Convert(@AM,svLF,Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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
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 isor, if svLF is a stage variable initialized to Char(10)Code: Select all
Convert(@AM,Char(10),Ans)
which means you only evaluate Char(10) once rather than once per rowCode: Select all
Convert(@AM,svLF,Ans)
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,
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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
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 "".