as400 interview questions and answers-Part 29


1. Explain TEST opcode in rpgle.

 

Ans:

 

TEST (Test Date/Time/Timestamp)

·         Test opcode is used to validate a date, time or timestamp.

·         The low level indicator is set on if the date is not valid or set off if the date is a valid one.

·         Test will be given with operator extender like test (d), test (t), test (z) for date, time and time stamp.

·         Test without extended factor default to date (z).

Factor 1

Op-code

Factor 2

Result Field

Resulting Indicators

       HI                            LO                      EQ

TEST(E)

date, time or timestamp

Target string

Error Indicator

 

Example


Columns . . . :    6  80                       Edit                           AMINEM/QRPGLESRC
SEU==>                                                                              DATE_TIME4
FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
*************** Beginning of data ************************************************************
0001.00 DDATE0            S             10A   INZ('2013-01-01')                         130124
0002.00 DDATE1            S             10A   INZ('2013-21-01')                         130124
0003.00 DFLAG             S              1N                                             130124
0004.00  *                                                                              130124
0005.00 C                   TEST (D)                DATE0                  90           130124
0006.00 C                   EVAL      FLAG=*IN90                                        130124
0007.00 C                   EXSR      CHECKDATE                                         130124
0008.00 C                   TEST (D)                DATE1                  80           130124
0009.00 C                   EVAL      FLAG=*IN80                                        130124
0010.00 C                   EXSR      CHECKDATE                                         130124
0011.00 C                   SETON                                            LR         130124
0012.00  *                                                                              130124
0013.00 C     CHECKDATE     BEGSR                                                       130124
0014.00 C                   IF        FLAG=*ON                                          130124
0015.00 C     'INVALID DATE'DSPLY                                                       130124
0016.00 C                   ELSE                                                        130124
0017.00 C     'VALID DATE'  DSPLY                                                       130124
0018.00 C                   ENDIF                                                       130124
0019.00 C                   ENDSR                                                       130124
      ****************** End of data *********************************************************

 

OUTPUT

VALID DATE          

INVALID DATE        

 

 

 

                                   

2. Explain XFOOT, SORTA, LOOKUP opcode in rpgle.

Ans:

XFOOT (sum-up the array element)

·         Lookup: It is used to look for an element in the array.

·         Sorta: It is used to sort the array element

·         Xfoot: It is used to sum-up the array element.

 

Example


Columns . . . :    1 100                                      Browse
SEU==>
FMT D  .....DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++++++++
*************** Beginning of data *******************************************
0001.00      darr2             s              3P 0 dim(5) ctdata perrcd(1)
0002.00      dn                s              2p 0 inz(1)
0003.00      C     n             do        5
0004.00      C     arr2(n)       dsply
0005.00      C                   eval      n=n+1
0006.00      C                   enddo
0007.00      C                   sorta     arr2
0008.00      C                   eval      n=1
0009.00      C     n             do        5
0010.00      C     arr2(n)       dsply
0011.00      C                   eval      n=n+1
0012.00      C                   enddo
0013.00      C     204           lookup    arr2                                   81
0014.00      C                   if        *in81=*on
0015.00      C     'found'       dsply
0016.00      C                   endif
0017.00      C                   xfoot     arr2          sum               4 0
0018.00      C     sum           dsply
0019.00      c                   seton                                        lr
0020.00 ** CTDATA arr2
0021.00 201
0022.00 205
0023.00 203
0024.00 202
0025.00 204
****************** End of data ************************************************

 

 

OUTPUT

 

DSPLY  201   
DSPLY  205   
DSPLY  203   
DSPLY  202   
DSPLY  204   
DSPLY  201   
DSPLY  202   
DSPLY  203   
DSPLY  204   
DSPLY  205   
DSPLY  found 
DSPLY  1015  

 

 





 

 







User Comments:



Subscribe

  Email:



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