


I am not sure that I understand your objective but below is a simple set of code that reads though the combined file presenting every record,
If you want to read the records in the order they are sequenced then read from the file - the access path for file test has a single pointer -- not one for each record. So when you say that you want to read from test2 the file reads forward to the next record of the right record type. When you ask for the next record of any type it's from that point.
Ftestjoin if e k disk -> my LF, it has two PF(TESTA, TESTB) Froughdsp cf e workstn -> my display file C dow *in03=*off c exfmt tworead -> display file record format name C read testjoin C exfmt tworead C Do while not %EOF(testjoin) and not *in03 03 is screen exit key C read testjoin C exfmt tworead C Enddo C Eval *inlr = *on C Return
here we can’t change the order of record display. because
It’s taking all of the records in the two files and sorting (ascending or descending) them depend upon records on key fields….


Do you mean multi record format Logical FIle?
Phil
yes, i want to read record from multi record logical file…
(here, how to change or edit my question)?
No problem using an F-Spec to define the file and native rpg statements – READ, CHAIN etc. When you READ, you will default to getting records from whichever file has the next record based on key.
If you want to know what Record you have just acquired you will need to get the record name from a file data structure associated with the F-spec.
If you do not want records from one or more Formats use the F spec keyword Exclude.
Phil
i coded this concept, but i am getting the output some what i can’t get the accurate output..
i am sharing my code. please find out the logic and help me to correct the logic..
here, i got output, but repeatedly shown second PF records..
how to read both PF at a same time…
sorry, i typed wrongly in my previous discus message..
if *in40 = *on
C leave
C eval *inlr = *off
please don’t consider this line….
Mr. Phil, i got the answer from your code.
but first read record from second pf (TESTA) in lf. when second pf will reach the last record, after control will go to read record from first pf (TESTB) in lf…
i want to change the order (first read record in first PF, after read second PF)
otherwise, can i read record one by one in both PF…
is it possible please give me a suggestion…
Records are going to appear as if they are sorted based on key, you may need to change the logical to add one additonal key field to the key list of the file you want to be last.
We may have said this before but we will say it again.
Multi-format logicals are an old approach and would not be an approach I would use for new development since it cannot be used by SQL.
Want data from two files, I would use two access paths.
Phil
Mr. Phil, i don’t want to change order of record… i want to change the order of file in LF.
i want to read record from first PF(testa) in first time. but my code read record from second PF in first..
so i want change that…………. is it possible…………
i don’t want to change order of record… i want to change the order of file in LF — but the order of data in the logical file isn’t based on records it’s based on keys. It’s taking all of the records in the two files and sorting them on the keys.
That requires a change to the keys in the logical file
file 1
Key 1.1
Key 1.2
file 2
Key 2.1
Key 2.2
Key 2.3 <– add another key
if key 1.1 = 2.1 and 1.2 = 2.2 the record from file1 will be before record from file2 because key 2.3 > nothing
At least that’s the way i remember it, you can research it and tell me how it goes.
Phil
R test1
K KEYFLD1
K KEYFLD2
K *NOKEY
R TEST2
K KFLD1
K KFLD2
K KFLD3
If this doesn’t work for you show use some sample data in the order you want it marking each rows source and field names.
Just show us the samle data and the logical file code.
It’s taking all of the records in the two files and sorting them on the keys
Mr. Phil, your are correct… i understood your point… i got the perfect answer..
i have another one question.. i have 2 field in PF1 and 2 field in PF2.. totally 4 field in LF..
can we read record from 4 fields at a time…..
You can use the logical file, do two reads then show screen.
Since you want data from both files at the same time, you might be better off with a join logical file. Issue – Join files are not updatable.
Phil
Thank Mr. Phil, i got clear idea about this… i fully learned and research about this…
i got perfect answer from your hint….
one more thanks for you…
Join files are not updatable.
…until V5R4 with INSTEAD OF triggers. (At least, I think it was V5R4.)
Tom
What I meant to say was I don’t update Join files Tom does.