Chain With KLIST

1420 pts.
Tags:
AS/400
RPG/400
Hi all, I have two files F1 anf F2. F1 is Having a Unique key. But F2 is having a Composite key. I need to perform CHAIN operation with unique key K1 of F1 on both the files. For that i did defined a KLIST for F2 at the RPG level to perform chain with KLIST. Now my question is how to pass the value of K1 to the KLIST. Please help me find the way. Thanks!

Software/Hardware used:
AS400,RPG400,

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: 7  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
  • TomLiotta

    Show us your data and KLIST definitions, and also show the key definitions for the two files. If we can't see the definitions, we can't tell you how to do it.

    If you defined everything appropriately, you don't have to do anything. It will happen automatically. But anything you defined yourself for any single piece could change how it should be done in your code.

    Tom

    125,585 pointsBadges:
    report
  • Sai4AS400
    Hi Tom,
    Thanks for the reply.
    My first file F1 is having a Unique key KF size 11 0
    My second  file F2 is having a two key fields KFA(not unique) size 11 0 
                                                                        KFB                            2
    Combination of KFA and KFB is  Unique for F2.Note that attribute of KF and KFA are same 
    I need to chain F1 First then need to pass the value to  F2.
    Also my code is written in such a way that for every record found in F1 has to get some data from F2 on match, and we are papulating that data to some other file --> F3. I think now you got my Requirement.

    Please let me know then...Thanks!

    1,420 pointsBadges:
    report
  • TomLiotta

    With a single key value, you don't need a KLIST for either file. You can use one if you want, and you can use the same one for both files if you want. Since the key lists will be the same for both files, I'd use a single KLIST if a KLIST was needed.

    But a value for KF and KFA is the only key value you need to use. A "list" isn't meaningful for single key values. Just define a variable LIKE(KF) or LIKE(KFA), assign a value to it and use it to CHAIN to both files.

    For F2, after its CHAIN, you can then use READE in a loop to read each record that matches the key value.

    Tom

    125,585 pointsBadges:
    report
  • Sai4AS400
    Hi Tom,
    Actually I tried  exactly the same way u specified, But i was told to use CHAIN on F2 with both fields(KFA+KFB) using KLIST, which will fetch the Unique records. Even though KF and KF1 attributes are same, KF is defined as Unique key in F1. so there is no KLIST for F1...So, can u please tell me how to pass the value of KF to KLIST  in this case?..Thanks! 
    1,420 pointsBadges:
    report
  • TomLiotta

    You can't use CHAIN with both fields unless you can assign the values to both fields. Where will you get the values for the KFB key?

    If you can get those values, then you'll be okay. However, the records that you get will be the exact same records if you use READE. It doesn't make any sense to use CHAIN unless you only want a single record from file F2 for each record from file F1. I can't help you do something that doesn't make sense because I can't figure it out.

    Tom

    125,585 pointsBadges:
    report
  • CharlieBrowne
    Is KFB a value you are extracting from F1?
    41,430 pointsBadges:
    report
  • TomLiotta
    If KFB can be taken from file F1 or if it can be assigned some other way, there's no problem. We haven't been told anything about KFB yet other than it's the low order key field for F2. -- Tom
    125,585 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