Ü  RETURN (H | M | R)    (Return to Caller)                     

·                  Return ends the program and gives the control to the calling program.

·                  Return doesn’t release the resources.

·                  RETURN returns control to the calling program immediately and doesn’t process anything after this.

e.g.       

return;

write REC1

*inlr=*on; (The statement after return will not get processed.)

 

·                  When PGMA calls PGMB for the first time PGMB executes the *INZSR, PGMB uses the RETURN operation to return to PGMA. When PGMA calls PGMB the second time is the*INZSR is not executed as it hasn’t released the resources yet.

·                  If you specify RETRN in called program, the *INZSR will not execute again as the resource was not freed in the first call.

·                  RETURN can be used to return a value from the called program to the calling program.

 


Example – I : To return single value to the calling program

Calling program calling CALLP1 which return some value to it


Columns . . . :    6  80                 Browse                               AMITCC/QRPGLESRC
SEU==>                                                                             OP_EVAL_PR
FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
*************** Beginning of data ****************************************************
0001.00 DCALLP1           PR             2  0                                           130201
0002.00 Dp                               2  0                                           130125
0003.00 Dq                               2  0                                           130125
0004.00  *                                                                              130125
0005.00 C                   Z-ADD     11            a                 2 0               130125
0006.00 C                   Z-ADD     22            b                 2 0               130125
0007.00 C                   Z-ADD     *zeros        c                 2 0               130125
0008.00 C                   EVAL      c=CALLP1(a:b)                                     130201
0009.00 C     c             DSPLY                                                       130125
0010.00 C                   SETON                                        LR             130125
0011.00  *                                                                              130125
        ****************** End of data *******************************************************

                                       

 

 

 

 


Columns . . . :    6  80               Browse                                AMITCC/QRPGLESRC
SEU==>                                                                             OP_EVAL_P1
FMT H  HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*************** Beginning of data ****************************************************
0001.00 HNOMAIN                                                                         130125
0002.00 DCALLP1           PR             2  0                                           130201
0003.00 Dp                               2  0                                           130201
0004.00 Dq                               2  0                                           130201
0005.00 PCALLP1           B                   EXPORT                                    130201
0006.00 DCALLP1           PI             2  0                                           130201
0007.00 Dp                               2  0                                           130201
0008.00 Dq                               2  0                                           130201
0009.00 Dr                S              2  0 INZ(*ZEROS)                               130201
0010.00 C                   EVAL      r=p+q                                             130201
0011.00 C                   RETURN    r                                                 130201
0012.00 PCALLP1           E                                                             130201
       ****************** End of data *******************************************************

 

 


 

OUTPUT

 

DSPLY  33

 

 

 

 


Example – II : Return multiple values by subprocedure

 

 

(1) We can use the below keyword to return the value

 

§  DIM(N)

The return value is an array with N elements.

 

§  LIKE(name)

The return value is defined like the item specified by the keyword.

 

§  LIKEDS(name)

The return value is a data structure defined like the data structure specified by the keyword.

 

§  LIKEREC(name{,type})

The return value is a data structure defined like the record name specified by the keyword.

 

 

 


Columns . . . :    6  80                Browse                               AMITCC/QRPGLESRC
SEU==>                                                                             OP_EVAL_P2
FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
        *************** Beginning of data ****************************************************
0001.00 DCALLP1           PR                  LIKEDS(DS0)                               130201
0002.00 Dp                               2  0                                           130125
0003.00 Dq                               2  0                                           130125
0004.00 DDS0              DS                                                            130201
0005.00 DFLD1                            2  0                                           130201
0006.00 DFLD2                            2  0                                           130201
0007.00  *                                                                              130125
0008.00 C                   Z-ADD     11            a                 2 0               130125
0009.00 C                   Z-ADD     22            b                 2 0               130125
0010.00 C                   Z-ADD     *zeros        c                 2 0               130125
0011.00 C                   EVAL      DS0=CALLP1(a:b)                                   130201
0012.00 C     DS0           DSPLY                                                       130201
0013.00 C                   SETON                                        LR             130125
0014.00  *                                                                              130125
        ****************** End of data ********************************************************



 


Columns . . . :    6  80                  Browse                            AMITCC/QRPGLESRC
SEU==>                                                                            OP_EVAL_P3
FMT H  HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        *************** Beginning of data ****************************************************
0001.00 HNOMAIN                                                                         130125
0002.00 DCALLP1           PR                  LIKEDS(DS1)                               130201
0003.00 Dp                               2  0                                           130201
0004.00 Dq                               2  0                                           130201
0005.00                                                                                 130201
0006.00 DDS1              DS                                                            130201
0007.00 DFLD1                            2  0                                           130201
0008.00 DFLD2                            2  0                                           130201
0009.00                                                                                 130201
0010.00 PCALLP1           B                   EXPORT                                    130201
0011.00 DCALLP1           PI                  LIKEDS(DS1)                               130201
0012.00 Dp                               2  0                                           130201
0013.00 Dq                               2  0                                           130201
0014.00 C                   EVAL      FLD1=p                                            130201
0015.00 C                   EVAL      FLD2=q                                            130201
0016.00 C                   RETURN    DS1                                               130201
0017.00 PCALLP1           E                                                             130201
        ****************** End of data *******************************************************


 

 

 

OUTPUT

 

DSPLY  1122

 

 











User Comments:



Subscribe

.  


Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy