Unable to run CPYSPLF command multiple times to same output file in a single CL.

1160 pts.
Tags:
AS/400
CL programming
CPYSPLF
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.

 

 

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Sloopy
    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.
    2,195 pointsBadges:
    report
  • JohnsonMumbai
    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.
    1,160 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • JohnsonMumbai
    Thanks Tom, It worked on moving the rcvf to the second cl pgm.
    1,160 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following