TechTalk: Outfile Processing

CL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: