From: Charley Shanks To: All
I'm writing a CL program which will purge "backup members" from a physical file. My goal is to prohibit this particular file from having more than 10 members. Here's my approach: DSPFD to an outfile with *MBRLIST information, read the outfile, and delete the oldest members, keeping the 10 "newest" members. My question has two parts. Can a single CL program create and then read an outfile, and is there a better way to do this that I'm not seeing?
From: John Wagner To: Charley Shanks
You should be able to create and then read your outfile, no problem. Can't think of a better way to do it. Just open the file when you're ready to read it.
Since the compiler is going to want the file to exist for compilation purposes, the easiest way to handle this is to create your outfile manually (presumably in QTEMP) just prior to compiling, and then compile the program interactively.
While I'm normally dead-set against interactive compiles, this should be a short program and a once-in-a-while exception is acceptable.
From: Charley Shanks To: John Wagner
If your CL program has a DCLF statement, doesn't it try to open the file when the program starts? How is this possible if I haven't created the file yet? I can see that this is fairly easy if you have two programs: The first program creates the outfile and then calls the second program, which would open and process the file. Am I missing the forest here?
From: Ernie Malaga To: Charley Shanks
What you do is use IBM's model outfile in the DCLF command, and process a copy of that file in QTEMP. For example, let's suppose you want to read an outfile created by the Display Object Description (DSPOBJD) command. IBM's model outfile for this command is QADSPOBJ. (The Programming: Reference Summary manual, SX41-0028-01, contains a chapter that lists all model outfiles. Sometimes you get that information from the help text; press the Help key in the input field for the OUTFILE parameter while prompting for DSPOBJD.)
Your program would then look like the sample in 6.
Your program would then look like the sample in Figure 6.
You can compile this program because the model outfile, QADSP-OBJ, was declared without a qualifying library, and the file exists in QSYS. When you run DSPOBJD, the outfile name is QADSPOBJ in QTEMP. The next Override Database File (OVRDBF) command makes sure that the Receive File (RCVF) command that follows reads the QTEMP copy rather than the QSYS original.
I've been using outfiles for years, and I have yet to find a better way to process them. One program can do the whole job.
TechTalk: Outfile Processing
Figure 6 Processing Outfiles PGM
DCLF FILE(QADSPOBJ) : DSPOBJD OBJ(...) OBJTYPE(...) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/QADSPOBJ) OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/QADSPOBJ) LOOP: + RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END-LOOP)) : : GOTO CMDLBL(LOOP) END-LOOP: + : ENDPGM
LATEST COMMENTS
MC Press Online