title: RPG III : how to redefine an array as seperate fields, as you can in COBOL
body: <p>in RPG III I need to store an huge array in a file. The maximum fieldlength is 256, thus I defined the file with 16 fields of 250 chars long each. Is there a way to put the 1000 values of the array into the 16 fields without moving? Just like the REDEFINES in COBOL?</p>
  
  <p>array in the program:</p>
  
  <pre><code> E                    MPDV     1000  4   
  </code></pre>
  
  <p>Specicifation of the file:</p>
  
  <pre><code> D000001                                           1   4 WRPMOD 
   D000002                                           5 254 W01PDV 
   ... etc. until     
   D000017                                        37554004 W16PDV   
  </code></pre>
  
  <p>In Cobol I would write:</p>
  
  <pre><code> 01 MPDV-TOP.
       03 MPDV-ARR OCCURS 1000.
          05 MPDV PIC X(4).
    01 WRPREC REDEFINES MPDV-TOP.
       03 W01PDV PIC X(250).
       .... ETC. UNTIL
       03 W16PDV PIC X(250).
  </code></pre>
  
  <p>Reading the file I get the array MPDV with it's values and with values in MPDV I can write the file.   </p>
  
  <p>my solution looks like this:
  an extra array</p>
  
  <pre><code>    E                    MPX        16250               MPDV REDEF   
  </code></pre>
  
  <p>and lots of moves:</p>
  
  <pre><code>C                     MOVELMMEMOD    WRPMOD    
  C                     MOVEAMPDV      MPX       
  C                     MOVELMPX,1     W01PDV    
  C                     MOVELMPX,2     W02PDV    
  .... etc until
  C                     MOVELMPX,16    W16PDV  
  C                     WRITEWRPASM         
  </code></pre>
  
  <p>and reverse for reading.     </p>