Hi,
I am working on a program and it goes like below:-
1) It will read a definition file which have library name/file name in it ( around 50 different files)
2) Now based on the data received from external application i have to populate one of the file from step 1)
3) Now once i figure out which file to populate can i use EXTFILE(variable name) and populate that file name in variable in EXTFILE keyword using usropn and then open and close. and do the same step again and again with different file names?
I do understand i have to declare a dummy file in rpgle, is there any other better way of handling above case?
EXTFILE Use
Re: EXTFILE Use
As I said on the Code400 list the answer is Yes. See that post for more comments.
-
- Site Admin
- Posts: 674
- Joined: Sun Jul 04, 2021 5:12 am
Re: EXTFILE Use
Yes, that should work fine, provided that they have the same record layout.kathan.p@gmail.com wrote: ↑Tue Dec 28, 2021 6:07 pm 3) Now once i figure out which file to populate can i use EXTFILE(variable name) and populate that file name in variable in EXTFILE keyword using usropn and then open and close. and do the same step again and again with different file names?
If you wanted to handle different layouts (but still use external definitions) you'd need to use dynamic SQL, or API calls instead.
I don't understand the "dummy file" comment. What do you mean by "dummy file"?kathan.p@gmail.com wrote: ↑Tue Dec 28, 2021 6:07 pm I do understand i have to declare a dummy file in rpgle, is there any other better way of handling above case?
Re: EXTFILE Use
I'm guessing he means the file declared on the DCL-F (F-pec) Scott - "dummy" in the sense that the file itself will never be used for data.I don't understand the "dummy file" comment. What do you mean by "dummy file"?
-
- Site Admin
- Posts: 674
- Joined: Sun Jul 04, 2021 5:12 am
Re: EXTFILE Use
That's not a requirement. His EXTDESC could reference one of the files he plans to switch between. Or he could temporarily build a file in QTEMP, compile the program using its external definition, then remove it. Or he could use program described files. Or he could use dynamic SQL. Or....
The way he said it, it sounded like he was positive we'd tell him it was a requirement and wanted to save us the trouble.