RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Reading and Writing using Data Structures Print E-mail
User Rating: / 2
Written by Chamara Withanachchi   
Reading and Writing using Data Structures

Using PREFIX you can relocate file fields memory in to a data structure. This can be achieve by enclosing prefixing name with single quotes and with a period(.) sign at the end of prefixing name.


FMYFILE        IF   E       K     DISK   Prefix('Ds.')

D Ds                    DS                  LikeRec(MYREC) Inz

      read myRec Ds;
      chain myKeyL myRec Ds;
      if %Found;
           Ds.myField = (tmpVar + 1000) / myRate;
           update myRec %fields(Ds.myField);

If you did not include data structure name on your I/O, data will be moved to input fields one field at a time.

When you include the data structure on I/O, data is read and moved to data structure in one operation and entire record is copied to data structure, also this method is good for I/O performance.

<Previous   Next>