How does KLIST work?

735 pts.
Tags:
KFLD
KLIST
RPG Program
Hi, I'm debugging an RPG program and came across a 'KLIST ' with 'KFLDS'. What I know so far is that a KLIST is used as a search argument and KFLDS make up the argument, but what I want to know is how does this actually work? Are the KFLDS concentrated to make up one search argument or does a KLIST search a file with each KFLD one at a time? And finally what is a scenario in which I will need to use a KLIST?

Software/Hardware used:
RPG

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb
    A physical or logical file can have a composite key --
    
    k OrdType
    
    k CustNum
    
    k OrdNum
    
    Using this access path it's possible to access the file using
    
    OrdTyp
    
    OrdTyp-CusNum
    
    OrdType-CusNum-OrdNum
    
    The key can be used in RPG code using the SETLL, READE, CHAIN, READPE
    
    The way to present the composite key to the Operation is through a klist.
    
    MyKey1   Klist
                   Kfld       MyOrdTyp
    
    MyKey2   Klist
                   Kfld       MyOrdTyp
                   Kfld        MoCusNum
               
    MyKey3   Klist
                   Kfld       MyOrdTyp
                   Kfld        MyCusNum
                   Kfld        MyOrdfNum
    
    With these three klists the file can be accessed by the first, first and second, first second and third keys.  
    
                       MyOrdTyp = 'A'
                        MyCusNum = '12345'
                         MyOrdfNum = 512
    
    MyKey3      Chain   Myfile
    would find the record that matched all three values
    
    MyKey2      Chain   Myfile
    Would find the first record that matched the two values
    
    MyKey1      Chain   Myfile
    Would find the first record that matched the single field
    
    
    
    RPGLE provides some alternatives to klist but the concept remains the same.
    
    
    
    
    51,365 pointsBadges:
    report
  • jailall101
    Thanks a lot philp. It makes sense now.
    735 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following