Unable to run CPYSPLF command multiple times to same output file in a single CL.
380 pts.
0
Q:
Unable to run CPYSPLF command multiple times to same output file in a single CL.
Iam running CPYSPLF command to an output file once, I process the resultant output file thereafter when i move on to the next spool file by again running the CPYSPLf Command on the same output file which required existing data to be cleared and overwritten with the data received from the second CPYSPLF command.

When i run the CPYSPLF command the second time i get a message CPF9845 error occured while opening the output file.  It asks me to use the MONMSG command.  However using MONMSG results in bypassing of the CPYSPLF command.

How can i overcome this error and still run the CPYSPLF command the second time.

 

 

ASKED: Nov 2 2009  7:09 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
6540 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
It would be helpf to see you code to determine for sure what the error is.
Is the splf being deleted?
Have you changed the parms on the CPYSPLF correctly?
Is the SPLF printed?
What is the message you need to MONMSG?
==
When you get the error, display the current spool files and change the parms against the ones in the CPYSPLF command
Last Answered: Nov 2 2009  1:03 PM GMT by CharlieBrowne   6540 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Sloopy   1940 pts.  |   Nov 2 2009  4:43PM GMT

It sounds rather as if the file is locked. It may be that the program you use to process the file does not end with *INLR = *ON.

 

JohnsonMumbai   380 pts.  |   Nov 3 2009  6:43AM GMT

When the error occurs if i run the command from command line the command works however within the program i get the error that the file is locked.

When i check the previous errors it shows that the file is locked.

Below is the pgm i am running.
PGM
DCLF FILE(QGPL/SPOOLED) OPNID(SPOOL)
DCLF FILE(QGPL/DLTOLDSPLF) OPNID(DISPLAY)
DCLF FILE(OPERATION/OPOUTQ) OPNID(OUTQ)

DCL VAR(&SPLF) TYPE(*CHAR) LEN(10)
DCL VAR(&SPOOLED) TYPE(*CHAR) LEN(132)
DCL &USER *CHAR 10
DCL &JOBN *CHAR 10
DCL &JOB# *CHAR 10
DCL &SPL# *CHAR 10
DCL &SPLDT *CHAR 8
DCL VAR(&SPLNO) TYPE(*DEC) LEN(5 0)
DCL &SPLD *CHAR 8
DCL &COFF *CHAR 8
DCL VAR(&INC) TYPE(*DEC) LEN(2 0) VALUE(1)
DCL VAR(&SPOOLED) TYPE(*CHAR) LEN(132)
DCL &USER *CHAR 10
DCL &JOBN *CHAR 10
DCL &JOB# *CHAR 10
DCL &SPL# *CHAR 10
DCL &SPLDT *CHAR 8
DCL VAR(&SPLNO) TYPE(*DEC) LEN(5 0)
DCL &SPLD *CHAR 8
DCL &COFF *CHAR 8
DCL VAR(&INC) TYPE(*DEC) LEN(2 0) VALUE(1)
SNDRCVF OPNID(DISPLAY)
IF COND(&DISPLAY_IN03 *EQ ‘1′) THEN(GOTO +
CMDLBL(EXIT))
POINT: RCVF OPNID(OUTQ)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(EXIT))
OVRPRTF FILE(QPRTSPLQ) MAXRCDS(300000) HOLD(*YES)
WRKOUTQ OUTQ(&OUTQ_ODLBNM/&OUTQ_ODOBNM) OUTPUT(*PRINT)
MONMSG MSGID(CPF9999)
SNDRCVF OPNID(DISPLAY)
IF COND(&DISPLAY_IN03 *EQ ‘1′) THEN(GOTO +
CMDLBL(EXIT))
POINT: RCVF OPNID(OUTQ)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(EXIT))
OVRPRTF FILE(QPRTSPLQ) MAXRCDS(300000) HOLD(*YES)
WRKOUTQ OUTQ(&OUTQ_ODLBNM/&OUTQ_ODOBNM) OUTPUT(*PRINT)
MONMSG MSGID(CPF9999)
CRTPF FILE(QTEMP/SPOOLED) RCDLEN(132) SIZE(*NOMAX)

CPYSPLF FILE(QPRTSPLQ) TOFILE(QGPL/SPOOLED) +
SPLNBR(*LAST)

DLTSPLF FILE(QPRTSPLQ) SPLNBR(*LAST)
DLTOVR QPRTSPLQ
LOOP: RCVF OPNID(SPOOL)
MONMSG MSGID(CPF0864) EXEC(DO)
RMVMSG PGMQ(*SAME) CLEAR(*ALL)
CRTPF FILE(QTEMP/SPOOLED) RCDLEN(132) SIZE(*NOMAX)

CPYSPLF FILE(QPRTSPLQ) TOFILE(QGPL/SPOOLED) +
SPLNBR(*LAST)
/* MONMSG MSGID(CPF9845 CPF9999) */
DLTSPLF FILE(QPRTSPLQ) SPLNBR(*LAST)
DLTOVR QPRTSPLQ
LOOP: RCVF OPNID(SPOOL)
MONMSG MSGID(CPF0864) EXEC(DO)
RMVMSG PGMQ(*SAME) CLEAR(*ALL)
GOTO CMDLBL(QUIT)
ENDDO
QUIT:
CHGVAR VAR(&SPLF) VALUE(%SST(&SPOOL_SPOOLED 2 10))
CHGVAR VAR(&USER) VALUE(%SST(&SPOOL_SPOOLED 13 10))
CHGVAR VAR(&JOBN) VALUE(%SST(&SPOOL_SPOOLED 84 10))
CHGVAR VAR(&JOB#) VALUE(%SST(&SPOOL_SPOOLED 95 6))
CHGVAR VAR(&SPL#) VALUE(%SST(&SPOOL_SPOOLED 75 4))
CHGVAR VAR(&SPLDT) VALUE(%SST(&SPOOL_SPOOLED 102 8))
GOTO CMDLBL(QUIT)
ENDDO
QUIT:
CHGVAR VAR(&SPLF) VALUE(%SST(&SPOOL_SPOOLED 2 10))
CHGVAR VAR(&USER) VALUE(%SST(&SPOOL_SPOOLED 13 10))
CHGVAR VAR(&JOBN) VALUE(%SST(&SPOOL_SPOOLED 84 10))
CHGVAR VAR(&JOB#) VALUE(%SST(&SPOOL_SPOOLED 95 6))
CHGVAR VAR(&SPL#) VALUE(%SST(&SPOOL_SPOOLED 75 4))
CHGVAR VAR(&SPLDT) VALUE(%SST(&SPOOL_SPOOLED 102 8))
/* */
/* SEE IF THE SPOOL FILE IS PAST EXPIRATION */
/* */
IF COND(&SPLF = ‘5722SS1 V’) THEN(DO)
GOTO CMDLBL(LOOP)
ENDDO

IF COND(&SPLF = ‘File ‘) THEN(DO)
GOTO CMDLBL(LOOP)
ENDDO
IF COND(&SPLF = ‘ *’) THEN(DO)
IF COND(&SPLF = ‘5722SS1 V’) THEN(DO)
GOTO CMDLBL(LOOP)
ENDDO

IF COND(&SPLF = ‘File ‘) THEN(DO)
GOTO CMDLBL(LOOP)
ENDDO
IF COND(&SPLF = ‘ *’) THEN(DO)

DLTF FILE(QTEMP/SPOOLED)
GOTO CMDLBL(POINT)
ENDDO
CVTDAT DATE(&SPLDT) TOVAR(&SPLD) FROMFMT(*DMY) +
TOFMT(*YYMD) TOSEP(*NONE)
CVTDAT DATE(&DISPLAY_CUTOFF) TOVAR(&COFF) FROMFMT(*DMY+
) TOFMT(*YYMD) TOSEP(*NONE)

IF COND(&SPLD < &COFF) THEN(DO)
CHGVAR VAR(&SPLNO) VALUE(&SPL#)
DLTSPLF FILE(&SPLF) JOB(&JOB#/&USER/&JOBN) +
SPLNBR(&SPLNO)
MONMSG CPF0000
CHGVAR VAR(&INC) VALUE(2)
GOTO CMDLBL(LOOP)
ENDDO
EXIT:
ENDPGM

Pls help.

 

TomLiotta   8035 pts.  |   Nov 3 2009  8:31AM GMT

You opened the file in the same CL program by issuing RCVF OPNID(SPOOL) against it. Since you opened it in that program, you will have to end the program before you can copy another spooled file into it. As long as that same CL program keeps running, you won’t be able to replace its contents with a new spooled file.

Either stop reading it in CL or move the RCVF into a second CL program that you CALL from this program. There is no IBM-supported way to close this file in this program.

Tom

 

JohnsonMumbai   380 pts.  |   Nov 4 2009  7:28AM GMT

Thanks Tom,

It worked on moving the rcvf to the second cl pgm.

 
0