DEFFUN ReadRec(X) Calling "DSU.ReadRec"
COMMON /ReadRec/Initialized, HASH_RECURSIVE.fvar
If Not(Initialized) Then Gosub OpenHashedFile ;
Read Rec From Handle, Arg1
Then
Col2 = Rec<1>
Col3 = Rec<2>
If Col2 = 4
Then Ans = ReadRec(Col3) ; * recursive call
Else Ans = Col3
End
Else
Ans = ""
End
RETURN(Ans)
OpenHashedFile:
OPEN "HASH_RECURSIVE" TO Handle
THEN
Call DSLogInfo("NO Error in Open","Recursive LookUp")
END ELSE
ErrorCode = 1
Call DSLogInfo("Error in Open","Recursive LookUp")
GOTO MainExit
END
Return(0)
MainExit:
Hope this Helps
Warm Regards,
Amruta Bandekar
<b>If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. </b>
--Albert Einstein
DEFFUN ReadRec(X) Calling "DSU.ReadRec"
COMMON /ReadRec/Initialized, HASH_RECURSIVE.fvar
If Not(Initialized) Then Gosub OpenHashedFile ;
Read Rec From Handle, Arg1
Then
Col2 = Rec<1>
Col3 = Rec<2>
If Col2 = 4
Then Ans = ReadRec(Col3) ; * recursive call
Else Ans = Col3
End
Else
Ans = ""
End
RETURN(Ans)
OpenHashedFile:
OPEN "HASH_RECURSIVE" TO Handle
THEN
Call DSLogInfo("NO Error in Open","Recursive LookUp")
END ELSE
ErrorCode = 1
Call DSLogInfo("Error in Open","Recursive LookUp")
GOTO MainExit
END
Return(0)
MainExit:
naren6876 wrote:
My requirement is for my input record 'a' look for the value in reference data if it finds the key value , then it should check the col2 value=4 or not.
If the col2 value = 4 then take the value from the col3 which is 'b'.Then need to check the remang records in the refrence data for the 'b'.Here, we have the record with 'b' so take the value from the col3 which is 'c.
need to do this until col2<>4.
In the above scenario for input record 'a' i should get the output 'e'.
This requirement is met by the routine above.
Warm Regards,
Amruta Bandekar
<b>If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. </b>
--Albert Einstein
Hi Sunshine,
Yes. you are right.But my requirement is slightly changed and i need to get the 'Col1' value if col2<>4.
Thanks for your time.
Sunshine2323 wrote:
naren6876 wrote:
My requirement is for my input record 'a' look for the value in reference data if it finds the key value , then it should check the col2 value=4 or not.
If the col2 value = 4 then take the value from the col3 which is 'b'.Then need to check the remang records in the refrence data for the 'b'.Here, we have the record with 'b' so take the value from the col3 which is 'c.
need to do this until col2<>4.
In the above scenario for input record 'a' i should get the output 'e'.
DEFFUN ReadRec(X) Calling "DSU.ReadRec"
COMMON /ReadRec/Initialized, HASH_RECURSIVE
If Not(Initialized) Then Gosub OpenHashedFile ;
Read Rec From Handle, Arg1
Then
Col2 = Rec<1>
Col3 = Rec<2>
If Col2 = 4
Then Ans = ReadRec(Col3) ; * recursive call
Else Ans = Arg1
End
Else
Ans = ""
End
RETURN(Ans)
OpenHashedFile:
* Your code (standard Open/Openpath) here
OPEN "HASH_RECURSIVE" TO Handle
THEN
Call DSLogInfo("NO Error in Open","TransformationJobs")
END ELSE
ErrorCode = 1
Call DSLogInfo("Error in Open","TransformationJobs")
GOTO MainExit
END
Return(0)
MainExit:
Warm Regards,
Amruta Bandekar
<b>If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. </b>
--Albert Einstein