Hi Ray
Many thanks for the reply, the SELECTINDEX is used to create a record list and then a loop is defined to iterate over all records in the list to get the record whose start and end dates happen to contain input date in their range.
The routine doesn't throw any error but we figured out that the record list wasn't getting created and the control never flowed inside the loop due to which the routine returns null value. (Routine code pasted at the bottom)
The hashed file was scp'ed from production and not created in this environment but guess that doesn't make much of a difference.
To take a loser look I ran the selectindex command using DSExecute and it's output when displayed said the verb not in VOC.
When the below SELECTINDEX is replaced with SELECT the routine returns correct results, does it indicate an issue with index ?
Code: Select all
SELECTINDEX 'NDC_CODE', INDEX.VALUE FROM FILE.VAR
Routine: Path, NdcCode and DataDate are input arguments
Code: Select all
COMMON /NDC_CODE/FILE.FLAG,FILE.VAR,HIGH.DATE
ENV = Path
NDC.CD = NdcCode
INPUT.DATE = DataDate
FILENAME=ENV:'/keyhash/NdcKeyLookup'
Ans= '0'
IF FILE.FLAG = 0 THEN
OPENPATH FILENAME TO FILE.VAR ELSE
Call DSLogFatal ('Cannot open file ':FILENAME, 'NdcKeyLookup')
END
FILE.FLAG=1
END
HIGH.DATE = '0001-01-01'
INDEX.VALUE = NDC.CD
SELECTINDEX 'NDC_CODE', INDEX.VALUE FROM FILE.VAR
LOOP
WHILE READNEXT ID DO
READ NDC.REC FROM FILE.VAR, ID ELSE
Call DSLogFatal ('Read Failed - NDC Code Hash File Corrupted ':FILENAME, 'NdcKeyLookup')
RETURN (NDC.REC)
END
EffDt = FIELD(ID,CHAR(251),2)
EndDt = NDC.REC<1>
IF EffDt<=INPUT.DATE and EndDt >= INPUT.DATE THEN
Ans = NDC.REC<2>
RETURN(Ans)
END
REPEAT
RETURN(Ans)