Using outfiles in CL |
What is Outfile in CL?
Outfile is used to retain the output information in a file.
Display Program (DSPPGM) Type choices, press Enter. Program . . . . . . . . . . . . PGM CLPGM4 Library . . . . . . . . . . . EASYCLASS1 Output . . . . . . . . . . . . . OUTPUT * Detail . . . . . . . . . . . . . DETAIL *ALL + for more values
Specify Value for Parameter OUTPUT Type choice, press Enter. Output . . . . . . . . . . . . . * * *PRINT
Display Object Descrioption (DSPOBJD) Type choices, press Enter. Object . . . . . . . . . . . . . OBJ > CLPF1 Library . . . . . . . . . . . > EASYCLASS1 Object type . . . . . . . . . . OBJTYPE > *FILE + for more values Detail . . . . . . . . . . . . . DETAIL *BASIC ASP device: ASPDEV Device . . . . . . . . . . . . * Search type . . . . . . . . . Output . . . . . . . . . . . . . OUTPUT > *OUTFILE File to receive output . . . . . OUTFILE ABC Library . . . . . . . . . . . QTEMP Output member options: OUTMBR Member to receive output . . . *FIRST Replace or add records . . . . *REPLACE
CL program using outfile
PGM DCLF FILE(ALLOBJPF) DSPOBJD OBJ(EASYCLASS1/*ALL) OBJTYPE(*ALL) + OUTPUT(*OUTFILE) OUTFILE(QTEMP/ALLOBJPF) OVRDBF FILE(ALLOBJPF) TOFILE(QTEMP/ALLOBJPF) DOWHILE (1=1) RCVF MONMSG MSGID(CPF0864) EXEC(LEAVE) IF COND(&ODOBTP = '*FILE' *AND &ODOBNM = + 'CLPF1') THEN(DO) SNDPGMMSG MSG(FOUND) RETURN ENDDO ENDDO ENDPGM
Explanation of the above code
DCLF FILE(ALLOBJPF)
This DCLF command is used to declare file named ALLOBJPF in cl program.
DSPOBJD OBJ(EASYCLASS1/*ALL) OBJTYPE(*ALL) + OUTPUT(*OUTFILE) OUTFILE(QTEMP/ALLOBJPF)
This DSPOBJD command will create the outfile named ALLOBJPF in QTEMP library containing all the objects information from library EASYCLASS1.
OVRDBF FILE(ALLOBJPF) TOFILE(QTEMP/ALLOBJPF)
This OVRDBF command will override the file ALLOBJPF from QTEMP library.
DOWHILE (1=1) RCVF MONMSG MSGID(CPF0864) EXEC(LEAVE) IF COND(&ODOBTP = '*FILE' *AND &ODOBNM = + 'CLPF1') THEN(DO) SNDPGMMSG MSG(FOUND) RETURN ENDDO ENDDO
Program compilation steps
DSPOBJD OBJ(EASYCLASS1/*ALL) OBJTYPE(*ALL) + OUTPUT(*OUTFILE) OUTFILE(EASYCLASS1/ALLOBJPF)