CPD0304 when using SUBR and ENDSUBR in CLLE
70 pts.
0
Q:
CPD0304 when using SUBR and ENDSUBR in CLLE
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: Oct 27 2009  4:10 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
6540 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Here is a link that should help you.
http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref2.doc/subrc.html

And here is the 2nd level text for your error
Message ID . . . . . . . . . : CPD0304
Message file . . . . . . . . : QCPFMSG
Library . . . . . . . . . : QSYS

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.
Last Answered: Oct 27 2009  4:46 PM GMT by CharlieBrowne   6540 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



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

JamesR   70 pts.  |   Oct 27 2009  5:55PM GMT

I checked out the link… no help.

 

JamesR   70 pts.  |   Oct 27 2009  5:58PM GMT

Here are snipets of the code:

ENDPROC:                             

             RETURN                  

/* ==================================
             SUBR       SUBR(FTP)    

             ENDSUBR
/* ========================================
             SUBR       SUBR(SWAPLIBL)

When it hits SWAPLIBL is fails

And I end with:

ENDSUBR
/* =========================================

ENDPGM: ENDPGM


Thanks!

 

TomLiotta   7990 pts.  |   Oct 27 2009  8:14PM GMT

What statements immediately precede the ENDSUBRs?

Tom

 

Teandy   3250 pts.  |   Oct 27 2009  8:15PM GMT

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:
ENDPGM                                                                  

The only thing I can see different between yours and mine is the Return statement. What happens if you take it out?

 

JamesR   70 pts.  |   Oct 27 2009  8:28PM GMT

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.

 

TomLiotta   7990 pts.  |   Oct 27 2009  8:37PM GMT

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

 

JamesR   70 pts.  |   Oct 28 2009  11:43AM GMT

As I posted earlier:

ENDPROC:

RETURN

/* ==================================
SUBR SUBR(FTP)

ENDSUBR
/* ========================================
SUBR SUBR(SWAPLIBL)

ENDSUBR
/* =========================================

ENDPGM: ENDPGM

 

JamesR   70 pts.  |   Oct 28 2009  11:50AM GMT

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
ENDDO                                                      

There was an error message about it but it was buried in all the other error message it caused. Thanks for your help all!

 

TomLiotta   7990 pts.  |   Oct 28 2009  9:08PM GMT

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
             ENDSUBR

Usually, 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

 
0