subprocedures


subprocedures

Important points:-

 1)In the calling procedure , we have to declare prototype of the returning value.

 2) if the procedure is not returning any value (void) then callp should be used.,and importantly
     length of the subprocedure need not be defined if the procedure is not returning any value.

Ex:-  callp ( opcode )  subpr1 parm(a b)

3) Procedure interface includes the return value , and the parameters like *entry plist. It is receiving values from outside procedure.

TYPE1 :- MAIN PROCEDURE CALLING SUBPROCEDURE

   SUB PROCEDURE WHEN NOT RETURNING ANY VALUE
  ( since not returning any value  callp should be used  && length
    of subprocedure need not be specified ).

PRA1/QRPGLESRC
MODULE3
0001.00 DSUBPR1           PR                                                    
0002.00 C     'RAVI'        DSPLY                                              
0003.00 C                   callp     subpr1                                   
0004.00 C                   EVAL      *INLR=*ON                                 
0005.00 C                   RETURN                                             
0006.00                                                                        
0007.00 PSUBPR1           B                                                     
0008.00 DSUBPR1           PI                                                   
0009.00 C     'KUMAR'       DSPLY                                              
0010.00 PSUBPR1           E                  

NOTE:-

Therz no p spec  but subprocedure should be informed  as subpr1 b (while beginning)
 abd subpr1 e  ( while ending) so first insert I mean  write I and press enter, then write p in column 1
and press <f4> then u can  view like this


 Procedure Name                Begin/End                                        
 subpr1                                 e                                           

                                                                         
output is :-

DSPLY  RAVI  
 DSPLY  KUMAR                                    

 

How to see output:-


1) Here in subprocedures we should not compile directly I mean 14 option should not be used.
First use crtrpgmod then press <f4> and enter module name if u write crtrpgmod and press enter then default module will be created in qgpl library with the module name as proof.

2) then crtpgm <f4> and write the programs name (any name) .

3) to see output  type on the command line as call <program name> . [ here call module3 ].


No comments