Hi again to everybody in DSXchange land,
Is it possible to 'filter' which fields are written to a sequential file output based on a list which contains the field names?
What I currently have is a job which creates a sequential output containing some 163 fields which is written to a fixed width file. (Simple) I have a request to make the output somewhat dynamic, to allow the fields written to that file be switched on or off, so either it writes a value to write to the file or leaves it blank and writes to the file to create the same fixed length output. (Not so simple?)
I am hoping that it is possible using a simple lookup somehow, as this will only be a temporary requirement (6 mths tops) before all fields will be just switched 'ON'?
Any suggestions? Thanks in advance.
Regards
Shane
Sequential File update based on field list
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You're right, not simple.
Where are you going to keep your flags? Does the on/off setting affect the location of a field in the text file record?
I'd probably consider a routine, with two arguments, one of them being a dynamic array of your column data values and the other being a 163-character string of flags. The return is the record ready to write to the text file as a single "column". (Or the routine itself could do the writing and return a success code.)
In combination with the above, a hashed file with 163 records, one for each field (key could be ordinal position of field or field name or anything else). Non-key columns are the start position and length of the field within the text file record. Use substring assignment to replace part of a string.
Something like this (apologies for the lack of documentation - it's already past my bedtime!):
Where are you going to keep your flags? Does the on/off setting affect the location of a field in the text file record?
I'd probably consider a routine, with two arguments, one of them being a dynamic array of your column data values and the other being a 163-character string of flags. The return is the record ready to write to the text file as a single "column". (Or the routine itself could do the writing and return a success code.)
In combination with the above, a hashed file with 163 records, one for each field (key could be ordinal position of field or field name or anything else). Non-key columns are the start position and length of the field within the text file record. Use substring assignment to replace part of a string.
Something like this (apologies for the lack of documentation - it's already past my bedtime!):
Code: Select all
FUNCTION ShaneText(Arg, Flags)
$INCLUDE UNIVERSE.INCLUDE FILEINFO.H
COMMON /ShaneText/Flags.fvar
If FileInfo(Flags.fvar, FINFO$IS.FILEVAR)
Else
Open "Flags" To Flags.fvar
Else
Call DSLogWarn('Cannot open "Flags" hashed file.', 'ShaneText')
End
End
Ans = @NULL
If FileInfo(Flags.fvar, FINFO$IS.FILEVAR)
Then
Ans = Space(800) ; * whatever your length is
ClearSelect 9
SSelect Flags.fvar To 9
ColumnNumber = 0
Loop
While ReadNext FlagKey From 9
ColumnNumber += 1
If Flags[ColumnNumber, 1] = "Y"
Then
Read FlagRecord From Flags.fvar, FlagKey
Then
StartPos = FlagRecord<2>
Length = FlagRecord<3>
Ans[StartPos, Length] = Arg<ColumnNumber>
End
End
Repeat
End
RETURN(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.
Re: Sequential File update based on field list
IMHO, if the seq file is defined as a stage , then it is static. means that you cannot conditionally remove a column from it. 1)try OpenSeq and create the file dymanically.ShaneMuir wrote:Hi again to everybody in DSXchange land,
Is it possible to 'filter' which fields are written to a sequential file output based on a list which contains the field names?
2) put some constant value(or keep it as the default null) for the colums you dont want to appear in the Seq file . connect the Seqfile to a transform and trim those fields having the constant value(or null), then create a new file.
at any cost option1 is best adviced.
all the best
Thanks for all your input guys it is most appreciated.
Thanks for the code Ray, it probably would work (after all its you ) for what i need - but the focus here was on simple. I was hoping to acheive it using standard stages and not coding.
My original thoughts were along the lines of Kim's, just create a new link and update as necessary, but was hoping there may have been a simple way to control it without having to alter the job every week.
Thanks again for all your help on this!
Shane
Thanks for the code Ray, it probably would work (after all its you ) for what i need - but the focus here was on simple. I was hoping to acheive it using standard stages and not coding.
My original thoughts were along the lines of Kim's, just create a new link and update as necessary, but was hoping there may have been a simple way to control it without having to alter the job every week.
Thanks again for all your help on this!
Shane