Midrange Systems Design - IBM iSeries i5

Support Sales Home

RPGLE converting *entry parms to proto types


      * Converting Entry parms to proto types                                                 
     H DFTACTGRP(*NO)                                                           
a    D ToUpper         Pr          4000A                                        
b    D  xx                         4000A   Const                                
c    D City            S             30                                         
d     /Free                                                                     
e       City = 'Del City';                                                      
f       City = ToUpper(City);                                                   
g       *inLR = *on;                                                            
h     /End-Free                                                                 
                                                                                
i      // ToUpper Sub Procedure                                                 
j    P ToUpper         B                   EXPORT                               
k    D ToUpper         PI          4000A                                        
l    D  InString                   4000A   Const                                
m    D ReturnValue     S                   Like(InString)                       
n    D Lower           C                   Const('abcdefghijklmnopqrstuvwxyz')  
o    D Upper           C                   Const('ABCDEFGHIJKLMNOPQRSTUVWXYZ')  
p     /Free                                                                     
q       ReturnValue = %xlate(Lower:Upper:InString);                                                                                                     
r       Return ReturnValue;  
s     /End-Free              
t    P ToUpper         E     

Lets look at how this program works.

Line A, through H, defines the main program.  

Lines I through line T defines the To Upper routine, which is called by the main procedure.

On Line A, the 4000a says the To Upper procedure, will return a 4000 byte character variable.

Line B, defines one parameter is passed to the sub procedure with a length of 4000 bytes.  S E U requires a field name but the RPG compiler ignores this field name, so I use xx as a dummy field name.

Line F, calls the To Upper procedure passing the mixed case city and receives back the upper case city.

Line J, defines the beginning of the procedure.

Line K, and line L, define the parameters used in the called procedure.  Note, that line, A, and B, match line K, and L, except line, A, has P R and line K, has P I. The number of parameters, length and attributes must match in the calling and called procedures.

Since line K, has the length of 4000 defined, then the called program will return a parameter.

Line L, is the input parameter for the To Upper procedure.

Line M, is the output parameter definition.

line N, and O, are constants used in the upper to lower translation process.

Line Q, translate lower case characters to upper case.

Line R, returns the upper case city back to the main procedure.

And line T defines the end of the procedure