as400 interview questions and answers-Part 25


1. Explain READC opcode in rpgle with example.

Ans:

READC (E) (Read Next Changed Record)     

·         READC will cause our program to read subfile records that have been changed, keyed into, field exited.

·         Even we not making any change in the record but we are keying in some value (by mistake) or pressing the field exit key, the record is supposed to be changed. Hence, READC will detect these cases also.

For example, if we have a subfile records displayed on the screen with an input-capable field (e.g. 2=Edit, 4= Delete, 5=Display) and we enter option-3 here, then still the record is changed and READC will read this changed record, but 2nd time again after correcting the error, if we try to access the record it won’t be available. If 2nd time we want the same record first of all we need to  turn on the indicator associated with SFLNXTCHG and then update the subfile.

·         If we have an editable subfile screen then we can modify any subfile record, to identify which record have been modified, we can use READC on the subfile and can put a DOW NOT %EOF(), to read all the changed record of the subfile and then process each record one by one.

 

Factor 1

Op-code

Factor 2

Result Field

Resulting Indicators

       HI                            LO                      EQ

 

READC(E)

Subfile record format name

Data structure to hold the result

 

Error

End of file condition indicator

 

 

Example

 

 


0003.00 C                   DOW       *IN03=*OFF
0004.00 C                   EXSR      MAIN
0004.01 C                   EXSR      DSPLY
0004.02 C                   ENDDO
0005.00 C                   SETON                                        LR
0006.00  *______________________________________________
0007.00  *___MAIN SUBROUTINE BEGINGS HERE_______________
0008.00 C     MAIN          BEGSR
0008.01 C                   READC     EXPD_SFL      >>>>>>>>> READC to check if any option
0008.02 C                   DOW       NOT %EOF()                is taken on the option field.
0008.03 C                   SELECT
0008.04 C     S_OPT         WHENEQ    '1'
0008.05 C                   EXSR      OPTION1
0008.06 C     S_OPT         WHENEQ    '2'
0008.07 C                   EXSR      OPTION2
0008.08 C     S_OPT         WHENEQ    '4'
0008.09 C                   EXSR      OPTION4
0008.10 C     S_OPT         WHENEQ    '5'
0008.11 C                   EXSR      OPTION5
0008.12 C                   OTHER
0008.13 C                   EXSR      VALIDATE
0008.14 C                   ENDSL
0008.15 C                   READC     EXPD_SFL
0008.16 C                   ENDDO
0008.18 C                   EVAL      MODE='1'
0009.00 C                   ENDSR

 

 

 

 

2. Explain READE opcode in rpgle with example.

 

Ans:

 

READE(N | E) (Read Equal Key)     

·         READE reads the matching record for factor-1 and moves the pointer to the next record with the same matching criteria. If the same matching criteria is not found then it foes to EOF.

·         Factor-1 is used to place the search argument which can be the key, relative record number or field value or named constant or figurative constant used to retrieve the record.

·         SETLL with READE is best used when there can be more than one record found. For example, you can find multiple customer orders in your system for one unique customer while CHAIN is best used to locate a unique record (like a customer record).

·         Using READE, we can read all the records which match the records corresponding to search argument in factor-1. If there are no records with the specified criteria then the pointer will be set to EOF.

·         To handle READE exceptions (file status codes greater than 1000), either the operation code extender 'E' or an error indicator at LO level can be used.

·         If the data-structure is specified in result field then the result of the operation is filled in the data structure.

·         The Equal Indicator gets turned-on if the EOF condition is met else it will be off. Instead of using this indicator we can also go for %EOF().

Factor 1

Op-code

Factor 2

Result Field

Resulting Indicators

       HI                            LO                      EQ

Search argument

READE(N|E)

File or record format name

Data structure to hold the result

 

Error

End of file condition indicator

 

 

Example

Physical file used: ACCSUBPF

Below are the records from a file ACCSUBF for party no. = ‘P00000000001’

ORG CODE  ACC NUMBER    CURRENCY  ACCOUNT MNG  COUNTRY     PARTY
190    A00000000001    EUR     DFJASHN      NKDAHFJ     P00000000001
191    A00000000002    USD     DAJFK        DAJH        P00000000001
192    A00000000003    TRY     DAHB         BJDKFA      P00000000001
193    A00000000004    USD     KIRAN        NDKAL       P00000000001
194    A00000000005    KWR     DANK         NKD         P00000000001
195    A00000000006    TRY     APPRINA      SOUTN       P00000000001
195    A00000000007    USD     SONATNA      SOUTN       P00000000001
****** ********  End of report  ********

 

 

 

Below program find all the records related to party no=‘P00000000001’ 


Columns . . . :    6  80             Browse                                  AMITCC/QRPGLESRC
SEU==>                                                                               OP_READE
FMT FX FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++++++++++++++++
*************** Beginning of data ****************************************************
0001.00 FACCSUBPF  IF   E           K DISK                                              130211
0002.00 DP000001          S             12A                                             130211
0003.00 C                   EVAL      P000001='P00000000001'                            130211
0004.00 C     'P00000000001'READE     ACCSUBPF                                          130211
0005.00 C                   DOW       NOT %EOF()                                        130211
0006.00 C     ACC           DSPLY                                                       130211
0007.00 C     P000001       READE     ACCSUBPF                                          130211
0008.00 C                   ENDDO                                                       130211
0009.00 C                   SETON                                        LR             130211
****************** End of data *******************************************************

 

 

OUTPUT

 

A00000000001

A00000000002

A00000000003

A00000000004

A00000000005

A00000000006

A00000000006

 




 

 







User Comments:



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