CHAIN operation in nutshell

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.

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

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts including news, tips, and advice to help you do your job more efficiently and effectively. Stay informed on the hottest topics and biggest challenges faced by IT professionals working with iSeries products and services.

    By submitting your registration information to Search400.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of Search400.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

= 'Sandy' C EndIf C Seton Lr ************** End of Code **************

This was first published in August 2005

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.