RPGLE free format *ENTRY parms prototype definition

All you need to do is create a prototype definition and a procedure interface. Any procedure interface found in the global definitions is assumed to be the procedure interface for the main procedure. The name is required for the procedure interface for the main procedure, and the prototype with the matching name must precede the procedure interface in the source. You do not need to code anything special to define the main procedure; it consists of everything before the first Procedure specification. Here is an example ...

Free format RPGLE example replacing *ENTRY with procedure

d MainRoutine     PR                  Extpgm('PROGRAMC')   
d                               30a                        
d                                3s 0                      
                                                           
d MainRoutine     PI                                       
d $name                         30a                        
d $age                           3s 0                      
                                                           
d $message        s             52a                        
                                                           
 /free                                                     
                                                           
    $message = 'My name is ' + %trim($name) + ', ' +       
              'age ' + %trim(%editc($age:'Z')) + ' years.'; 
    dsply $message;                                        
                                                           
    eval *inlr = *on;                                      
    return;                                                
                                                           
 /end-free   

Sample RPGLE program calling another program without *ENTRY

d $name           s             30a   inz('as400')      
d $age            s              3s 0 inz(21)           
                                                        
d ProgramC        PR                  Extpgm('PROGRAMC')
d $name_                        30a                     
d $age_                          3s 0                   
                                                        
 /free                                                  
                                                        
    ProgramC($name:$age);                               
                                                        
    eval *inlr = *on;                                   
    return;                                             
                                                        
 /end-free    

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.