Declare and read multiple logical files in RPGLE

1215 pts.
Tags:
AS/400
AS400 RPGLE
RPGLE
Is it possible to declare and read the Multiple logical files in RPGLE Programs? Why?

Answer Wiki

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

Hi,

Yes it is possible – you may need to use rename to rename the record formats.

As to why – maybe you need to read the file using a different key sequence – or a different select/omit criteria – there could be all sorts of reasons for why you need/want to do this.

Regards,

Martin Gilbert.

Discuss This Question: 8  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
    The answer is yes but I'm not sure about the question... " the Multiple logical files " It's the word "the" in your question that got me wondering if you were refering to: a. having F specs and operations on more than one logical file, perhaps over the same physical file. (answered above by Martin) or b. having an F spec and operations on a multi-format logical file, which allows access to records from more than one physical file. or c. having an F spec and operations on a logical over a physical file having more than one member. the asnwers to all three are yes. I don't think you were asking about 'c' but probably a or b. The reasons and methods are different for each of these questions. Phil
    49,940 pointsBadges:
    report
  • rajeshece
    Its a multi format logical file A R FMT1 PFILE(FILE1) A K EMPNO A R FMT2 PFILE(FILE2) A K EMPNO I want to use the multi format logical file in my rpgle program. How to use this. Can you please give me the example
    1,215 pointsBadges:
    report
  • Gilly400
    Hi, Why do you have 2 formats in your logical file which are identical? If it's not necessary, then you have your solution. If the 2 record formats are necessary, you should be able to chain, read, etc by using the record format name instead of the file name. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • Gilly400
    Hi, Now I see that the formats point to different physicals. So you can just refer to the format names instead of the file names. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • philpl1jb
    You make a single F spec If you want data from both f MyLF IF E K DISK The F spec keywords IGNORE or INCLUDE can be used if you want data from some but not all of the files mapped in the multirecord fiel The F spec keyword INFDS(data_structure_name) can be used to identify a data structure the file information data structure can provide the record name whenever a record is accessed so you can tell which file it comes from -- positions 38-45 or keyword *RECORD You can do SETLL, CHAIN, ReAD etc on the file - also updates and deletes (you will need the record name from the INFDS to do these. If you have no interest in which file the data is coming from this is the code. It will look just like a physical file to the program. *LOVAL SETLL MyLF Read MyLF dow not(%EOF(MyLOC)) do something ReadMyLF ENDDO Phil
    49,940 pointsBadges:
    report
  • rajeshece
    I got Run time Error while reading the Multi format logical file Code i have tried PF1 A R PF1R A NAME 20A PF2 A R PF2R A NUMBER 10A Multi Format Logical File - LF1 A R PF1R PFILE(PF1) A K Name A R PF2R PFILE(PF2) A K Number Program FLF1 IF E DISK C Read lf1 C Name Dsply C Eval *Inlr = *On While Executing the above code, i am getting the Error CPF4247 Can you help me to correct the code I tried the above example using USROPN also
    1,215 pointsBadges:
    report
  • Gilly400
    ` Hi, Try specifying that the file is Keyed on the F spec. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • philpl1jb
    The multi-format file LF1 actually compiled? The key structure looks all wrong. This isn't the one you showed us before with EMPNUM in both physicals I think that the key should be structurly the same or a skip (I'm not sure of the sintax.) Typeically these monsters are made for a case where the variaous physicals have similar keys IE: the order header, order detail, order comments, etc. Then reading should give the order header, followed by order comments, and then each order detail followed by it's comment. If you have an option, multi-formats would not be the prefered way to go. So why do they exist -- to simulate a system with one punched card reader. The cards would all be sorted in the order described using a card sorter and then loaded in the reader. Voila you have all the records you need in just the right order. .
    49,940 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