Hi I need to test a program with over 13 files that are being used. I know "seton LR" will close them all but I was wondering if there is a operation code that will allow me to close just one file. And if I chain to a file and latter on do a SETLL to the same file do I have to reset the pointer before I do the SETTLL? I appreciate any help Frank
Unconfigured Ad Widget
Collapse
Announcement
Collapse
No announcement yet.
how to close one file in RPGIII
Collapse
X
-
how to close one file in RPGIII
Frank - The best way control the opening and closing of files is to describe a file in your F specs with 'UC' in the file condition position (stands for user control). Then you have to remember to 'open' the file before doing a read or write. Use the opcode 'OPEN' followed by the name of the file in Factor 2. At the same time, set on an indicator to keep track that the file has been opened. If you return to this code more than once, test the indicator before you try to open the file again or you'll get an error.. The same goes for closing the file. Test the indicator to see if the file is open or you'll get an error trying to close it. If it is open, put 'CLOSE' in the opcode (followed by the name of the file in Factor 2). The program will close the file. Remember to turn off the indicator as well. With SETLL, if I'm reading from the first record, I automatically use *LOVAL as a pointer each time I open the file. It may be an extra line, but it's easier to read when others have to maintain my code.
-
how to close one file in RPGIII
I'm not sure why you are using the SETLL after you've chained to the file. Have you closed the file? If you haven't and you want the next record later on, you simply do a READ if you're reading records by key or arrival sequence. The first record you've chained to is still in the 'input handler' and the pointer to the file is 'set' to that first record. BTW, SETLL is a good way to check for the existance of a record without reading it into your program and possibly inadvertently updating file fields used in the program. Herb Kingsbury
Comment
Comment