Ü  CALLP (M | R | E) (Call a Program or Procedure) 

·         The CALLP operation is used to call prototyped procedures or programs.

·         It is a static call.

·         If the keyword EXTPGM is specified on the prototype, the call becomes a dynamic external call; otherwise it will be a bound procedure call.

·         If there is any error in this call operation then the error can be traced with operator extender ‘E’ and LO level indicator which turns on in case of any error.

·         If we don’t want to use error indicator with operator extender ‘E’ even then we can trace the error by using the built-in function %ERROR and %STATUS. For more information see chapter File and Program exception.

Factor 1

Op-code

Factor 2

Result Field

Resulting Indicators

HI                    LO                EQ                     

CALLP (M | R | E)

' procedure name'

parameter list

 

error

LR

 


Example

       I.            CALLP with called procedure defined in the main procedure itself

 


Columns . . . :    6  80                Browse                               AMINEM/QRPGLESRC
SEU==>                                                                               OP_CALLP
FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
*************** Beginning of data ****************************************************
0001.00 DCALL1            PR                                                            130125
0002.00 Dp                               2  0                                           130125
0003.00 Dq                               2  0                                           130125
0004.00 Dr                               2  0                                           130125
0005.00  *                                                                              130125
0006.00 C                   Z-ADD     11            a                 2 0               130125
0007.00 C                   Z-ADD     22            b                 2 0               130125
0008.00 C                   Z-ADD     *zeros        c                 2 0               130125
0009.00 C                   CALLP     CALL1(a:b:c)                                      130125
0010.00 C     c             DSPLY                                                       130125
0011.00 C                   SETON                                        LR             130125
0012.00  *                                                                              130125
0013.00 PCALL1            B                                                             130125
0014.00 DCALL1            PI                                                            130125
0015.00 Dp                               2  0                                           130125
0016.00 Dq                               2  0                                           130125
0017.00 Dr                               2  0                                           130125
0018.00 C                   EVAL      r=p+q                                             130125
0019.00 PCALL1            E                                                             130125
****************** End of data *******************************************************


 

OUTPUT

DSPLY  33                       

 



Example           

    II.            CALLP with called procedure defined outside main procedure

 


Columns . . . :    6  80               Browse                                AMINEM/QRPGLESRC
SEU==>                                                                              OP_CALLP0
FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
*************** Beginning of data ****************************************************
0001.00 DOP_CALLP1        PR                                                            130201
0002.00 Dp                               2  0                                           130125
0003.00 Dq                               2  0                                           130125
0004.00 Dr                               2  0                                           130125
0005.00  *                                                                              130125
0006.00 DOP_CALLP2        PR                                                            130201
0007.00 Dl                               2  0                                           130201
0008.00 Dm                               2  0                                           130201
0009.00 Dn                               2  0                                           130201
0010.00  *                                                                              130201
0011.00 C                   Z-ADD     11            a                 2 0               130125
0012.00 C                   Z-ADD     22            b                 2 0               130125
0013.00 C                   Z-ADD     *zeros        c                 2 0               130125
0014.00 C                   CALLP     OP_CALLP1(a:b:c)                                  130201
0015.00 C     c             DSPLY                                                       130125
0016.00 C                   CALLP     OP_CALLP2(a:b:c)                                  130201
0017.00 C     c             DSPLY                                                       130201
0018.00 C                   SETON                                        LR             130125
0019.00  *                                                                              130125
****************** End of data *******************************************************


 

 

>>>>> NOMAIN Module

You can code one or more subprocedures in a module without coding a main procedure. Such a module is called a NOMAIN module

 

Below is a NOMAIN module containing two subprocedures OP_CALLP1 and OP_CALLP2 which is called by above program.

 


Columns . . . :    6  80               Browse                                AMINEM/QRPGLESRC
SEU==>                                                                              OP_CALLP1
FMT H  HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*************** Beginning of data ****************************************************
0001.00 HNOMAIN                                                                         130125
0002.00 DOP_CALLP1        PR                                                            130201
0003.00 Dp                               2  0                                           130201
0004.00 Dq                               2  0                                           130201
0005.00 Dr                               2  0                                           130201
0006.00 DOP_CALLP2        PR                                                            130201
0007.00 Dl                               2  0                                           130201
0008.00 Dm                               2  0                                           130201
0009.00 Dn                               2  0                                           130201
0010.00 POP_CALLP1        B                   EXPORT                                    130201
0011.00 DOP_CALLP1        PI                                                            130201
0012.00 Dp                               2  0                                           130201
0013.00 Dq                               2  0                                           130201
0014.00 Dr                               2  0                                           130201
0015.00 C                   EVAL      r=p+q                                             130201
0016.00 POP_CALLP1        E                                                             130201
0017.00  * _____________________________________________                                130201
0018.00  *                                                                              130201
0019.00 POP_CALLP2        B                   EXPORT                                    130201
0020.00 DOP_CALLP2        PI                                                            130201
0021.00 Dl                               2  0                                           130201
0022.00 Dm                               2  0                                           130201
0023.00 Dn                               2  0                                           130201
0024.00 C                   EVAL      n=m-l                                             130201
0025.00 POP_CALLP2        E                                                             130201
****************** End of data *******************************************************


CRTRPGMOD MODULE(OP_CALLP0)     

CRTRPGMOD MODULE(OP_CALLP1)     

CRTPGM PGM(OP_CALLP0) MODULE(OP_CALLP0 OP_CALLP1)  

 

OUTPUT

DSPLY  33                     

DSPLY  11                     


 

>>>> EXPORT                         

In the NOMAIN modules we have used this keyword at procedure interface level. By using this keyword only, the procedures will be visible to the outside world so that it can be called using CALLP operation.       











User Comments:



Subscribe

  Email:



Copyright © www.go4as400.com, 2013-2017. Copyright notice