CPD0304 when using SUBR and ENDSUBR in CLLE

90 pts.
Tags:
CALLSUBR
CLLE
ENDSUBR
SUBR
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

Answer Wiki

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

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.

Discuss This Question: 9  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
  • JamesR
    I checked out the link... no help.
    90 pointsBadges:
    report
  • JamesR
    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!
    90 pointsBadges:
    report
  • TomLiotta
    What statements immediately precede the ENDSUBRs? Tom
    125,585 pointsBadges:
    report
  • Teandy
    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?
    5,860 pointsBadges:
    report
  • JamesR
    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.
    90 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • JamesR
    As I posted earlier: ENDPROC: RETURN /* ================================== SUBR SUBR(FTP) ... ENDSUBR /* ======================================== SUBR SUBR(SWAPLIBL) ... ENDSUBR /* ========================================= ENDPGM: ENDPGM
    90 pointsBadges:
    report
  • JamesR
    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!
    90 pointsBadges:
    report
  • TomLiotta
    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
    125,585 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