Blog Archive

RPGLE free format Call program example - AS400 (iSeries)

Free-format RPGLE does not support CALL. The only call possible in free-format is the prototype call, CALLP. Prototype call can be dynamic call or a bound call. If the keyword EXTPGM is specified on the prototype, the call will be a dynamic external call; otherwise it will be a bound procedure call.

A prototype for the program or procedure being called must be included in the definition specifications preceding the CALLP. Here is sample program A that calls another program B.

Sample RPGLE program to be called - PROGRAMB

d $name           s             30a                      
d $age            s              3s 0                    
d $message        s             52a                      
c     *entry        plist                                
c                   parm                    $name        
c                   parm                    $age         
    $message = 'My name is ' + %trim($name) + ', ' +     
              'age ' + %trim(%editc($age:'Z')) + ' years.';
    dsply $message;                                      
    eval *inlr = *on;                                    

Sample RPGLE calling program - PROGRAMA

d $name           s             30a   inz('as400')     
d $age            s              3s 0 inz(21)          
d ProgramB        PR                  Extpgm('PROGRAMB')
d $name_                        30a                    
d $age_                          3s 0                  
    eval *inlr = *on;                                  

Tip: You can omit CALLP, thats implicit!

No comments :

Post a Comment