SETLL and READ

1300 pts.
Tags:
AS/400 commands
RPGLE Program
SETLL
Hi, I have the following problem: I need to make SETLL and READE for several LF based on 1 PF by selection. Is it any smart way to do it without to duplicate the READE and %eof() for each LF? Thank you.

Software/Hardware used:
OS V5.3 / RPGLE AS/400

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,
When you are using Different LFs of the same file in one program, There will be a problem of duplication while compiling.

To avoid this we can use RENAME & PREFIX Keyword at the time of LF Declaration in F – Spec.

And You can use SETLL & READE paralally on different LFs without duplicates.

RENAME: we use this keyword for renaming the Record format of that particular file.
PREFIX: By using this keyword we can give the prefix for the field names in File.

Eg: We have TEST(Physical File) and 4 Logical files on the same TEST1, TEST2, TEST3 & TEST4 and considering all 5 having the same record format TESTR.

We can use these keywords like this.
FTEST1 UF A E K DISK PreFix(T1_)
F ReName(TESTR:TESTR1)

FTEST2 UF A E K DISK PreFix(T2_)
F ReName(TESTR:TESTR2)

By using the new record formats we can access the same PF paralally.

You can distinguish the fields of the logical files based on PreFix.
Like, T1_Field for TEST1 & T2_Field for TEST2.

Pradeep.

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
  • Mariodlg
    Good explanation, but I still thinking this is not exactly what YuVa47 wanted. Yuva, tell me if I wrong but you want to write some code and use it for the read loop regardless of the values selected, is this right? Have you tried to do it with SQLRPGLE ?, I think you can define a cursor and set the key values you need in every user selection. If you don't know about SQLRPGLE here is a good reference. Hope this help you.
    2,790 pointsBadges:
    report
  • TomLiotta
    There's seldom a reason to have a different LF in a single program unless the key-lists are different. Different LF names plus different key-list structures makes re-use of the same SETLL/READE instructions effectively impossible. When combined with the requirement for RENAMEs of record formats, I don't see much chance. I suppose you could use the _Ropen(), _Rlocate() and _Rreadk() C library functions; but I suspect that a SELECT group that simply breaks the SETLLs and READEs into their own WHEN clauses would be much easier. Tom
    125,585 pointsBadges:
    report
  • Trishaful
    Do all the LF are having the different sets of keys. If yes then you need to set and read the different logical files.
    70 pointsBadges:
    report
  • Bigmac46
    you might look at Fmyfile PF IF A E K DISK EXTFILE(WRKFILE) USROPN F EXTMBR(FIRST1) D WORKFILE S 21A INZ('*LIBL/yourfile') D FIRST1 S 10A INZ('*FIRST') D load1 S 21A INZ('*LIBL/file2') D load2 S 21A INZ('*LIBL/file2') D load3 S 21A INZ('*LIBL/file3') D load4 S 21A INZ('*LIBL/file4') D load5 S 21A INZ('*LIBL/file5') If condition close workfile eval WRKFILE = load2 (etc) open workfile user setll workfile then same subfile load is used for all sorts. I am using this to control which of 6 logicals is open, used, closed based sort needed. In My case all logicals have the same first key based on user and other keys as needed to get correct view. IF keys for logicals do not have the same keys for setll,/read or reade this will not help as all keys will need to match up at those lines.
    1,000 pointsBadges:
    report
  • YuVa47
    Thank you all for the answers. @Pradep - great answer and I agree with Mariodlg :) @Mariodlg - yes, SQLRPGLE was an option, but I wanted to make it in RPGLE only. You almost guessed correctly, I wanted to read, but according to the selection criteria. @Tom - the LFs have different key-lists and the record formats are renamed. I know that I need to have different SETLL and READE and actually I wanted to find out, if is possible to use the %eof() without the file name within the parentheses, so I could have only 1 test, but what I understanding is not possible.
    1,300 pointsBadges:
    report
  • YuVa47
    Thank you Bigmac46, I'll give your suggestion a try :)
    1,300 pointsBadges:
    report
  • TomLiotta
    if is possible to use the %eof() without the file name within the parentheses, so I could have only 1 test The %eof() BIF doesn't need to include a name. However, according to the ILE RPG Reference, if no name is supplied, then the EOF condition refers to the last subfile to reach EOF. Full-procedural files and primary and secondary files need a filename for %eof(). The approved answer works fine in current releases. Naturally, the extra OPENs and CLOSEs are an issue though only minor ones. If you don't need to use key-lists, there shouldn't be any big problem. The inclusion of SETLL in the question took things in a wrong direction -- you won't use SETLL in this case apparently. The key structures won't matter since you won't actually reference them in your code. 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