CHAIN operation in nutshell
In RPGLE, if you CHAIN to any file and try to evaluate the values of the file fields in debug (using 'Eval' on command prompt of STRDBG), only the fields that are used in the program will get populated by the CHAIN operation. Either the remaining fields will be zeros or blanks depending upon there file attributes.
In RPGLE, if you CHAIN to any file and try to evaluate the values of the file fields in debug (using 'Eval' on command prompt of STRDBG), only the fields that are used in the program will get populated by the CHAIN operation. Either the remaining fields will be zeros or blanks depending upon there file attributes.
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 **************