It's possible that you CHAIN to a file using Klist constructed with work variables and CHAIN will be successful. Even still, the Key field values of the file won't be populated if you haven't used those key fields in your program. This may lead to the false assumption that CHAIN operation is not successful, but actually, it does and has populated the file fields that are mentioned in the program at one place or another.
In below example, CHAIN to employee file for Emp ID# = 100002 and Emp Location = 'BGL' is successful, but if you try and eval the values of EMPID# and EMPLOC field of file on STRDGB prompt using 'Eval', you will find these equal to zero and blank respectively.
*********** Beginning of Code *********** FEMPLOYEE UF A E K DISK C K_IdLoc Klist C Kfld W_LOC 3 C Kfld W_EID# 10 0 C Eval W_Loc = 'BGL' C Eval W_EID# = 100003 C K_IdLoc Chain EMP01 C If %Found(EMPLOYEE) C Eval EMPNAME = 'Sandy' C EndIf C Seton Lr ************** End of Code **************
This was first published in August 2005