READE

491 Views


READE (Read Equal Key)
The READE operation retrieves the next record from the file FILEA and compares its key to the search argument, KEYFLD.
The %EOF built-in function is set to return '1' if KEYFLD is  not equal to the key of the record read or if end of file  is encountered.

READE (KEYFLD) FILEA;

The READE operation retrieves the next record of the type REC1 from an externally described file and compares the key of the record read to the search argument, KEYFLD. (REC1 is a record  format name.)

READE (KEYFLD) REC1;

 
With No Factor 1 Specified, the READE operation retrieves the next record in the access path from the file FILEA if the key value is equal to the key value of the record at the current cursor position.
If the key values are not equal, %EOF is set to return '1'.

READE     FILEA;

The READE operation retrieves the next record in the access path from the file FILEA if the key value equals the key value of the record at the current position. REC1 is a record format name.

READE(N)  REC1;

Simple Reade usage:

SetLL (Flag) FileA01 ;      
ReadE (Flag) FileA01 ;      
   DoW Not%EOF (FileA01 ) ;          
       
     //Retrieve field values and write some logic to use fields and then read again in a loop
                              
     ReadE (Flag) FileA01 ;    
   EndDo;                          

Using Reade with data structures:

Dcl-Ds FILER01_DS                             
                    Extname('FILER01')       
                    Template                         
                    Qualified 
					Inz     
					ALIAS ; 
					
Dcl-Ds ds_FILER01_IO Qualified Inz;                          
       Dcl-Subf R01   LikeRec( FILER01.R01_Record : *Input ); 
       Dcl-Subf Data  LikeDS (FILER01_DS) Overlay(R01 : 1); 
End-Ds;                                                        

Setll   %kds(File_KeyDS:nbr_of_Keys)  FILER01 ;                                 
if %Equal (FILER01);     
   Reade  %kds(File_KeyDS:nbr_of_Keys)  FILER01 ds_FILER01_IO.R01;                              
                                                       
	Dow not %eof(FILER01);                                
        
		count = count + 1;		
		local_ds_FILER01.array(count) = ds_FILER01_IO.Data;												
    Reade  %kds(File_KeyDS:nbr_of_Keys)  FILER01 ds_FILER01_IO.R01;                                     
                                                       
	EndDo;      
EndIf;	

Reade IBM:

Post Comments