How to move a record format to a data structure

Here is an example of how to move a file record format to a data structure. Furthermore, the code will show how to define two (actually three) data structures based on the same file without the need to use Prefixes.  This way you can have two sets of data that come from the same file.

File MyFile has record format MyRFile. Example file specification:

FMyFile    UF  A E                      K DISK

Example data structure specifications:

D SavRec      e ds                    extname(MyFile) inz
D SvBefore      ds                    likerec(MyRFile) inz
D SvAfter       ds                    likerec(MyRFile) inz

C                  read       MyFile
 * save the original image
C                  eval       SvBefore = SavRec        

... do some processing ...
C                  update     MyRFile

 * save the image again after update
C                  eval       SvAfter = SavRec

 * did something change?
C                  if         SvAfter <> SvBefore
... do write an audit record - something was changed

Note that the same file layout has been used in a couple of instances, SvBefore and SvAfter. However, PREFIX was not necessary. Prefixing field names is undesirable because it puts a burden on the programmer to remember to move renamed fields.