I know I've run into this the past, but I can't remember the fix. I am using V5R4 and trying to use CALLSUBR in my CLLE. I end my mainline with a RETURN, then I have a SUBR/ENDSUBR... and a 2nd SUBR/ENDSUBR.. then a ENDPGM. When the compiler hits the 2nd SUBR I get a CPD0304 and it rejects any commands following. The QCPFMSG message file shows this for CPD0304
Message . . . . : SUBR command not allowed. Cause . . . . . : A SUBR command was specified inside a subroutine. Recovery . . . : Either remove the SUBR command, or add an ENDSUBR command to close the previous subroutine before the SUBR command, and then try compiling the CL procedure again.
Software/Hardware used:
iSeries, V5R4, CLLE
ASKED:
October 27, 2009 4:10 PM
UPDATED:
October 28, 2009 9:08 PM
I checked out the link… no help.
Here are snipets of the code:
ENDPROC: RETURN /* ================================== SUBR SUBR(FTP) ENDSUBR /* ======================================== SUBR SUBR(SWAPLIBL)ENDSUBR
/* =========================================
ENDPGM: ENDPGM
What statements immediately precede the ENDSUBRs?
Tom
I am doing pretty much the same thing you are. Here is my code.
/*********************************************************************/ /* STOP THE SUBROUTINES FROM BEING EXECUTED AT PROGRAM END. */ /*********************************************************************/ GOTO CMDLBL(ENDCLPGM2) /*********************************************************************/ /* SUBROUTINE TO SUBTRACT A NUMBER OF DAYS FROM THE DATE. */ /*********************************************************************/ SUBR SUBR(GETDATE) CALLPRC PRC(SUBDAYSR) PARM((&DATE#) (&DAYSTOSUB)) + RTNVAL(&DATE#) ENDSUBR /*********************************************************************/ /* SUBROUTINE TO CONVERT DATE TO B&L FILE FORMAT. */ /*********************************************************************/ SUBR SUBR(CONVRTDATE) CALLPRC PRC(RTVBLFILDT) PARM((&DATE#)) + RTNVAL(&CHKDATE#) ENDSUBR ENDCLPGM2: ENDPGMThe only thing I can see different between yours and mine is the Return statement. What happens if you take it out?
When I take out the RETURN statement I get the same error.
Tom… look at my last post… you will see I have a TAG and a RETURN.
JamesR:
In the code that I can see, there are no statements shown between the two SUBR and ENDSUBR sections — the subroutine statements are snipped out. What statements immediately precede the two ENDSUBRs?
Tom
As I posted earlier:
ENDPROC:
RETURN
/* ==================================
SUBR SUBR(FTP)
…
ENDSUBR
/* ========================================
SUBR SUBR(SWAPLIBL)
…
ENDSUBR
/* =========================================
ENDPGM: ENDPGM
I FOUND IT! It was caused by an unmatch DO statement in the SUBR before the SUBR it failed on…. this is what I had in SUBR FTP:
RTVMBRD FILE(RVUXCEL) NBRCURRCD(&RCDCNT) MONMSG MSGID(CPF0000) EXEC(DO) IF COND(&RCDCNT *EQ 0) THEN(DO) CHGVAR VAR(&MSG60) VALUE('The uploaded file is empty') CHGVAR VAR(&ERRCODE) VALUE('1002') RTNSUBR ENDDOThere was an error message about it but it was buried in all the other error message it caused. Thanks for your help all!
I’m glad you found it because you still didn’t show what was immediately before the two ENDSUBRs. Without knowing the code that comes before the ENDSUBRs, it’s difficult to see something like a missing ENDDO.
Another possiblity is that MONMSG might have been before the ENDSUBR. IBM released a PTF for that one.
/* ================================== SUBR SUBR(FTP) <-- here is immediately before ENDSUBR ENDSUBRUsually, just the single command before the ENDSUBR is enough to know the solution. BTW, was there no “mismatched DO-ENDDO” error message? What severity was on the message if one was sent?
Tom