with an OPEN statement if there exists a VOC entry for the hashed file
with an OPENPATH statement if there is no VOC entry for the hashed file
Every record in a hashed file has a key. The READ statement requires that a key value be given. Variants of the READ statement allow the record to be locked for updating (READU) or locked against others updating it (READL).
Key values can be obtained from active Select Lists.
Similarly, the WRITE statement and the DELETE statement require that the key value be given.
A hashed file that has been opened with either OPEN or OPENPATH should be closed with a CLOSE statement when you are finished with it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Another approach would be to query the hashed file using DataStage SQL (or RetrieVe) and direct the output into the required text file via either the DIVERT.OUT, the COMO, or the LPTR mechanism.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
OPEN '','VOC' TO VOCFilePtr ELSE STOP 'Unable to open VOC'
SELECT VOCFilePtr TO 1
READNEXT Key FROM 1 ELSE Key = ''
LOOP UNTIL Key=''
READ Record FROM VOCFilePtr, Key ELSE STOP 'Unable to read record "':Key:'" FROM VOC'
READNEXT Key FROM 1 ELSE Key = ''
REPEAT
CLOSE VOCFilePtr
Keep in mind the facts that Ray noted, Arnd's code needs a VOC entry to work. Meaning the hashed file needs to either live in a project or you've created one for it manually. If you've pathed the hashed file elsewhere, change the OPEN to OPENPATH appropriately.
-craig
"You can never have too many knives" -- Logan Nine Fingers
So your overall strategy has to include opening the hashed file, opening the sequential file, establishing a Select List on the hashed file, using a loop to process the records from the hashed file, for each of which you extract your required columns (fields), build the output line and write it to the text file. At the end you close both files.
In the following sample code, some error handling has been omitted for clarity.
Equate Tab To Char(9)
OpenPath '/pathname/of/HashedFile' To fptrIn
Then
OpenSeq '/pathname/of/TextFile' to fptrOut
Then
LineCount = 0 ; * number of lines written to output file
Select fptrIn To 1 ; * Select List #1 contains all keys from hashed file
Loop While ReadNext ID From 1
Read Record From fptrIn, ID
Then
* Output line consists of fields 2, 3 and 5 from the hashed file.
Field2 = Field(Record, @FM, 2)
Field3 = Field(Record, @FM, 3)
Field5 = Field(Record, @FM, 5)
Line = Field2 : Tab : Field3 : Tab : Field5
WriteSeq Line To fptrOut Then LineCount += 1
End
Repeat
Call DSLogInfo(LineCount : " lines written to file. ", 'ReadHashedFile')
End
CloseSeq fptrOut
Close fptrIn
End
Else
Call DSLogFatal('Unable to open hashed file.', 'ReadHashedFile')
End
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.