AS/400 question:
When normal handling of opening and closing is done in RPG...why do you need USROPN, OPEN & CLOSE commands?
As per my understanding, Say you have the below scenario:
You have file A and member A - After processing file A you wanted to process File B and its Member B. In this case you use extfile and extmbr declared in your RPG and you have to manually control the file open and close operations using USROPN.
Please correct me if this is wrong and can you please help me knowing more about the usage of USROPN in specific when we have the RPG handling the file open and close operations.
Also, another question which I would like to ask is about the usage of USROPN in Display file. Can you please state an example?
Thanks.
When normal handling of opening and closing is done in RPG why do you need USROPN , OPEN & CLOSE commands?
You use those when you want files opened and close at times other than when it would automatically be done. Your FileA and FileB example is a possible use.
Another example would be spooled output from a program I wrote a few years ago. The program might be called thousands of times per second, day after day for months. Under certain error conditions that might happen once in a couple years, or never, the program needed to print some records about what caused the error. I didn't want the printer file to be opened and closed every time the program was called, so it was a USROPN file.
...the interviewe specifically questioned about the usage of USROPN in Display file. Can you please state an example?
Yes.
But you should be able to think of circumstances when you do not want a display file opened.
Tom
Another reason for USROPN, OPEN and CLOSE is if you use the QCMDEXC command. We use this if we want to change spool attributes. Say a certain user want 2 copies of the spoolfile. You would close ther current, OVRSPLF, OPEN.. do job , then revert back to original spool file attributes. We have also used the feature when we developed some of our CGI apps. This was to control the proper OVRDBF commands within an RPG program to grab the correct data files.
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
Discuss This Question: 2  Replies