useropen

20 pts.
Tags:
RPG
RPGLE
USROPN
Hi, What is the purpose of USROPN keyword?

Answer Wiki

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

Hi,
a programmer can explicitly open the files defined in the file specs with this key word specified in the RPGLE program.
——————————————————————-
This is usually done so that your program can determine things like a specific member to override to before opening the file. Then when you open the file you can process that member.

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
  • WoodEngineer
    USROPN is only required if you need to control the initial opening of a file. Your program can close any open file and re-open it as needed without specifying USROPN. Notice the sequence . . . "close and re-open". If you specify USROPN, you must add code to your program to open the file.
    6,875 pointsBadges:
    report
  • Sloopy
    Woodengineer, I don't think you are correct. RPG will 'initially' open a file if USROPN is NOT specified. That file will stay open until the program ends with *INLR set *ON, or until that program is closed using FREE from a calling program, or until RCLRSC is used. Without USROPN, there is no way an RPG program can close the file and then re-open it. With USROPN, the RPG program will not open the file until an OPEN operation is executed for that file. You can then use CLOSE to close the file. You can do this as often as you want in the program. Regards, Sloopy
    2,195 pointsBadges:
    report
  • BigKat
    Not true Sloopy. I do that all the time for a system configuration file that is only read once during initialization. I let the program open the file (no USROPN), READ file, CLOSE file. If I wanted to I could re-OPEN file. USROPN only controls the initial automatic opening of the file Kevin Ketzler - Affiliated
    8,350 pointsBadges:
    report
  • GreenleeB
    I agree with Kevin, you can CLOSE a file opened by the cycle although I haven't tried to re-open one. I'll go with experience that you can, then. I would think that, for some clarity, why not then just add the USROPN and the first OPEN. There are those out there that have no experience with MR, Lx's, detail and total-time output and other cycle-related favorites of the older generation who actually have to see the code to understand what's going on. Those were the days...
    95 pointsBadges:
    report
  • WoodEngineer
    Sloopy, I stand by my answer. I've used the technique in my my programs. The following is copied directly from IBM's ILE RPG Reference manual for V5R3, page 285: "The USROPN keyword is required for programmer control of only the first file opening. For example, if a file is opened and later closed by the CLOSE operation, the programmer can reopen the file (using the OPEN operation) without having specified the USROPN keyword on the file description specification. See also “EXTIND(*INUx)” on page 277."
    6,875 pointsBadges:
    report
  • Gilly400
    Hi, This seems to be something that has been quietly added to RPG at some point. I'm 100% sure that in older versions of RPG/400 if you didn't have the UC on your file spec and tried to OPEN or CLOSE a file, your program wouldn't even compile. I've tried this as a test and a program will compile with OPEN and CLOSE and no USROPN for a file, but will not compile if you specify USROPN without an OPEN or CLOSE. Before you ask - yes, I was bored. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • Sloopy
    I stand corrected. Well, I lounge around corrected, anyway. As Martin says, this does appear to be something that crept in to RPG in the move between RPGIII and RPGIV - UC behaves as I described, and USROPN behaves as Woody describes. I just don't remember any notification of the change of function, but then, it was a long time ago now and there was so much to read! Regards, Sloopy
    2,195 pointsBadges:
    report
  • Gilly400
    Hi, UC now also works this way, it's not just for USROPN. I don't remember seeing this announced either. Regards, Martin.
    23,730 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