as400 interview questions and answers-Part 17


1. What is EXTPROC in rpgle? Explain EXTPROC with example.

Ans:

o   EXTPROC

If you've built modules with commands like CRTRPGMOD, CRTCLMOD, CRTCBLMOD, and CRTCMOD, you're accustomed to calling them with the CALLB op code. Just as you can with CALL, you can replace CALLB with CALLP.

 

ü Case1: Program without prototyping

Calling Program SENDPGM

 


Columns . . . :    1  71           Browse                       AMIT/QRPGLESRC
SEU==>                                                                SENDPGM
FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
 
* SEND MSG0001 FROM MESSAGE FILE CPF9898 TO PROGRAM MESSAGE QUEUE
C                   MOVEL     'MSG0001'     MSGID
C                   MOVEL     'AM_MSGF'     MSGF
C                   MOVE      'I'           MSGOPT
C                   EXSR      SEND
C     SEND          BEGSR
C                   CALLB     'MSGSFLCL'
C                   PARM                    MSGID             7
C                   PARM                    MSGF             10
C                   PARM                    MSGOPT            1
C                   ENDSR

**Here we have compiled the same CL using CRTCLMOD to make it a module.

Called module MSGSFLCL


Columns . . . :    1  71           Browse                       AMIT/QRPGLESRC
SEU==>                                                                MSGSFLCL
FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
0001.01    PGM        PARM(&MSGID &MSGF &MSGOPT)
0002.00    DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)
0003.00    DCL        VAR(&MSGF) TYPE(*CHAR) LEN(10)
0004.00    DCL        VAR(&MSGOPT) TYPE(*CHAR) LEN(1)
0006.00
0007.00
0008.00    IF         COND(&MSGOPT *EQ 'I') THEN(SNDPGMMSG +
0009.00               MSGID(&MSGID) MSGF(&MSGF))
0010.00
0011.00    IF         COND(&MSGOPT *EQ 'C') THEN(RMVMSG PGMQ(*PRV +
0012.00                 (*)) CLEAR(*ALL))
0013.00 ENDPGM
****************** End of data ****************************************

 

Now when we run the program we get the same run time error. To avoid this we will go for prototyping.

 

ü Case2: Program with prototyping


Columns . . . :    1  71           Browse                       AMIT/QRPGLESRC
SEU==>                                                                SENDPGM
FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
 
DMSGID            S              3    >>> Parm MSGID’s length changed from 7 to 3
DMSGF             S             10
DMSGOPT           S              1
DMSGSFLCL         PR                  EXTPROC('MSGSFLCL')
DMSGID                           7
DMSGF                           10
DMSGOPT                          1
* SEND MSG0001 FROM MESSAGE FILE CPF9898 TO PROGRAM MESSAGE QUEUE
C                   MOVEL     'MSG0001'     MSGID
C                   MOVEL     'AM_MSGF'     MSGF
C                   MOVE      'I'           MSGOPT
C                   EXSR      SEND
C     SEND          BEGSR
C                   CALLP     MSGSFLCL(MSGID:MSGF:MSGOPT)
C                   ENDSR

Using this we get the error at compile that we can correct and can easily avoid the situation of any run time error due to parameters wrong definition.

 

2. What are the resulting indicator HI, LO, EQ in RPGLE?

Ans:

 

o   HI

  This resulting indicator representing a condition found for greater than, high or no record found condition. 

 

  Possible values:


ü  Blank

Leave the field blank if no indicator is to be set on.


ü  01-99

Type any two-digit number to indicate general indicators.        


ü  KA-KN or KP-KY

Type a value from KA to KN or from KP to KY to indicate a function key indicator.


ü  LR

Type LR to indicate a last record indicator.


ü  OA-OG or OV

Type a value from OA to OG or OV to indicate any overflow indicator.

 

 

o   LO


  This resulting indicator representing a condition found for less than or an error condition

 

  Possible values:

 

ü  Blank

Leave the field blank if no indicator is to be set on.


ü  01-99

Type any two-digit number.


ü  KA-KN or KP-KY

Type a value from KA to KN or from KP to KY to indicate a function key indicator.


ü  OA-OG or OV

Type a value from OA to OG or OV to indicate an overflow indicator.


 


o   EQ


  This resulting indicator representing a condition found for equal, beginning-of-file, an end-of-file, or a search string-found condition. 

 

  Possible values:                  


ü  Blank

Leave the field blank if no indicator is to be set on.        


ü  01-99

Type any two-digit number.


ü  KA-KN or KP-KY

Type a value from KA to KN or from KP to KY to indicate a function key indicator.


ü  OA-OG or OV

Type a value from OA to OG or OV to indicate an overflow indicator.

 





 

 







User Comments:



Subscribe

  Email:



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