Reading into a Data Structure

This snippet demonstrates a method of reading from a file into a data structure. Create a pointer to reference the input data. Define a data structure or as many data structures as required to contain the data values. This allows you to reference multiple records simultaneously in the program.

FINPUT     IF   E             Disk                                      
D Prt_toData      S               *                                     
D Ds_Input      E DS                  extname(INPUT)                    
D                                     based(Ptr_toData)                 
D Ds_Input1     E DS                  extname(INPUT)                    
D                                     prefix(D1_)                       
D Ds_Input2     E DS                  extname(INPUT)                    
D                                     prefix(D2_)                       
C                   eval      Ptr_toData = %addr(Ds_Input1)             
C                   read      INPUT                                     
C                   eval      Ptr_toData = %addr(Ds_Input2)             
C                   read      INPUT                                     
C                   return              

This technique could be convenient if you need to compare field values from a previous record.