Ü  %EQUAL

 

·    %EQUAL is used along with two operation codes SETLL and LOOKUP.

·    It is used by the SETLL operation to indicate that it detected a record in the file with a key equal to that of the value specified in Factor 1. Hence we can use SETLL along with %EQUAL to check the existence of the record.

·    For the SETLL operation, this function returns '1' if a record is present whose key or relative record number is mentioned in factor-1.

·    For the LOOKUP operation, this function returns '1' if an element is found that exactly matches the element in factor-1.

 

Example – I –%equal built-in function in rpgle

%EQUAL for SETLL operation


0138.00 C     FILLWND       BEGSR
0139.00 C                   EVAL      RRN1=0
0140.00 C     S_PNUM        SETLL     REC5
0141.00 C                   IF        %EQUAL()
0142.00 C                   DOU       %EOF(ACCSUBPF) //If record related to S_PNUM is found then
0143.00 C                   READE     REC5              only these operations will be performed.
0144.00 C                   IF        %FOUND()
0145.00 C                   EVAL      RRN1=RRN1+1
0146.00 C                   EVAL      A_ORG=ORG
0147.00 C                   EVAL      A_ACCNO=ACC
0148.00 C                   EVAL      A_CCY=CCY
0149.00 C                   EVAL      A_ACCMNG=ACCMNGR
0150.00 C                   EVAL      A_CNTRY=COUNTRY
0151.00 C                   WRITE     ACC_SFL
0152.00 C                   ENDIF
0153.00 C                   ENDDO
0154.00 C                   ENDIF
0155.00 C                   SETON                                        26
0156.00 C                   ENDSR

 

 

Example – II –%equal built-in function in rpgle

%EQUAL for LOOKUP operation


Columns . . . :    1 100                                
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
0014.00      C                   if        %equal()
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 ************************************************

 











User Comments:



Subscribe

.  


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