i have a cl program with the cpysplf command that is executed within it. before executing, it retrieves all the spool file attributes from a declared file. when i debug the program all the attributes are correct but it doesn't copy to the physical file. the file is at the top of my library list and i've even qualified the library. also, when i execute the cpysplf from a command line and hardcode the exact same parameters it works fine. am i missing a parm in the crtclpgm or cpysplf command? thanks in advance.
Software/Hardware used:
iSeries
ASKED:
February 5, 2010 2:47 PM
UPDATED:
February 10, 2010 4:06 PM
When you run your CL, turn on full logging to get the CPF error code. With that you will see the error and possible resolution. If you can run the command manually but not in a CL, you may have some sort of authority issue.
Sorry it took so long. I couldn’t post a comment with IE 8. Anyway, I don’t receive any CPF error(s) and I’m not monitoring for any messages after the CPYSPLF and all other commands are executed with no problems. Below is the code. I create the CL program interactively from the command line (CRTCLPGM). Thanks for any input.
PGM PARM(&OUTQ)
DCLF FILE(QTEMP/QPRTSPLQDB)
DCL VAR(&OUTQ) TYPE(*CHAR) LEN(10)
DCL VAR(&CURJOB) TYPE(*CHAR) LEN(6)
DCL VAR(&DOC) TYPE(*CHAR) LEN(12)
DCL VAR(&JOB) TYPE(*CHAR) LEN(10)
DCL VAR(&JOBNO) TYPE(*CHAR) LEN(6)
DCL VAR(&SPLF) TYPE(*CHAR) LEN(10)
DCL VAR(&SPLFNBR) TYPE(*CHAR) LEN(4)
DCL VAR(&SPLFNB#) TYPE(*DEC) LEN(4 0)
DCL VAR(&USER) TYPE(*CHAR) LEN(10)
DCL VAR(&USRDTA) TYPE(*CHAR) LEN(10)
MONMSG MSGID(CPF0000)
WRKOUTQ OUTQ(&OUTQ) OUTPUT(*PRINT)
DLTF FILE(QTEMP/QPRTSPLQDB)
CRTPF FILE(QTEMP/QPRTSPLQDB) RCDLEN(132) LVLCHK(*NO)
CPYSPLF FILE(QPRTSPLQ) TOFILE(QTEMP/QPRTSPLQDB) +
SPLNBR(*LAST)
DLTF FILE(QTEMP/SPOOLFILES)
CRTPF FILE(QTEMP/SPOOLFILES) RCDLEN(378)
LOOP: RCVF
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDLOOP))
/* Search until a detail record is found */
IF COND(%SST(&QPRTSPLQDB 113 1) *NE ‘:’) +
THEN(GOTO CMDLBL(LOOP))
CHGVAR VAR(&SPLF) VALUE(%SST(&QPRTSPLQDB 2 10))
CHGVAR VAR(&USER) VALUE(%SST(&QPRTSPLQDB 13 10))
CHGVAR VAR(&USRDTA) VALUE(%SST(&QPRTSPLQDB 24 10))
CHGVAR VAR(&SPLFNBR) VALUE(%SST(&QPRTSPLQDB 75 4))
CHGVAR VAR(&JOB) VALUE(%SST(&QPRTSPLQDB 84 10))
CHGVAR VAR(&JOBNO) VALUE(%SST(&QPRTSPLQDB 95 6))
CHGVAR VAR(&SPLFNB#) VALUE(&SPLFNBR)
CPYSPLF FILE(&SPLF) TOFILE(PRT132) +
JOB(&JOB/&USER/&JOBNO) SPLNBR(&SPLFNB#) +
MBROPT(*REPLACE) CTLCHAR(*PRTCTL)
CPYSPLF FILE(&SPLF) TOFILE(QTEMP/SPOOLFILES) +
JOB(&JOB/&USER/&JOBNO) SPLNBR(&SPLFNB#) +
MBROPT(*ADD)
GOTO CMDLBL(LOOP)
ENDLOOP: RTVJOBA NBR(&CURJOB)
CHGVAR VAR(&DOC) VALUE(‘FB’ *TCAT &CURJOB *TCAT +
‘.TXT’)
CRTFLR FLR(SKF)
CPYTOPCD FROMFILE(QTEMP/SPOOLFILES) TOFLR(SKF) +
TODOC(&DOC) REPLACE(*YES)
SNDDST TYPE(*DOC) +
TOINTNET((‘myemail@emailaddress.com’)) +
DSTD(‘Multiple Spool Files’) +
MSG(‘Multiple Spool Files’) DOC(&DOC) +
FLR(SKF)
DLTF FILE(QTEMP/QPRTSPLQDB)
DLTF FILE(QTEMP/SPOOLFILES)
Is the CPYSPLF FILE(&SPLF) TOFILE(PRT132) JOB(&JOB/&USER/&JOBNO) SPLNBR(&SPLFNB#) MBROPT(*REPLACE) CTLCHAR(*PRTCTL) referring to a tofile created elsewhere? I don’t see it created in the program.
First thing I’d suggest is to change your logging level & when the program’s completed a run review that. You could also toss in a DMPCLPGM towards the end of the program to get an idea of what’s been going on.
If those don’t provide sufficient information, create the program with DBGVIEW(*ALL) & do a STRDBG to step through everthing.
I found the problem. i appreciate everyone’s input.
-Splat
I took your advice and dumped the CL program. I had the job and job number reversed. When I ran it interactively, it appeared I was doing it in the correct order…but no. Because I wasn’t getting any errors, I had no reason to dump it (I thought).
Thanks again-
MONMSG MSGID(CPF0000)
Note that that statement tells your program to ignore all errors with a “CPF” prefix. It is almost guaranteed that you were getting messages if you had JOB(&JOB/&USER/&JOBNO).
Tom
-Tom Liotta
I was always under the impression that MONMSG(CPF0000) was not a program level statement, but one that just monitored statements before it. Just curious.
Thanks.
Shawn
When you put the MONMSG MSGID(CPF0000) after the variable declares & not following any particular command it acts as a global monitor. If you don’t specify an action, the program will ignore any CPF messages that are generated.
That’s why the following is a standard feature of all my CL programs:
Dcl Var(&Msgid) Type(*CHAR) Len(7) Dcl Var(&Msgdta) Type(*CHAR) Len(256) Dcl Var(&Msgf) Type(*CHAR) Len(10) Dcl Var(&Msgflib) Type(*CHAR) Len(10) Monmsg Msgid(CPF0000 MCH0000 RPG0000) Exec(Goto + Cmdlbl(End)) . . . Return End: Rcvmsg Msgtype(*EXCP) Rmv(*YES) Msgdta(&Msgdta) + Msgid(&Msgid) Msgf(&Msgf) Msgflib(&Msgflib) Dmpclpgm Sndpgmmsg Msgid(&Msgid) Msgf(&Msgflib/&Msgf) + Msgdta(&Msgdta) Msgtype(*ESCAPE) Endpgm-Splat
Good idea. I’ll remember to not use MONMSG(CPF0000) without any “capture” routines.
Thanks for all your help.