Terance,
Your routine is exactly what I was looking for.
Using yourÂcode, I can adapt it for any size subfile.
Thanks,
Â
Jeff Young
Sr. Programmer Analyst
IBMÂ-e(logo) serverÂCertified Systems ExperÂ- iSeries Technical Solutions V5R2Â
IBMÂ Certified Specialist-Âe(logo)ÂserverÂi5Series Technical Solutions DesignerÂV5R3
IBMÂ Certified Specialist- e(logo)server i5Series Technical SolutionsÂImplementerÂV5R3
ÂÂ
Â
________________________________
From: Terrence Enger <tenger@xxxxxxxxxxxxxxxx>
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Sent: Thursday, September 17, 2009 1:18:54 PM
Subject: Re: Formula for loading subfile with multiple records across
On Wed, 2009-09-16 at 12:35 -0700, Jeff Young wrote:
I have a subfile with 15 lines per page and 3 records per line.
The normal way the system loads the subfile is down and then across.
I would like to load it across, then down.
Ex: Record 1 = RR# 1
   Record 2 = RR# 16
   Record 3 = RR# 31
   Record 4 = RR# 2
   Record 5 = RR# 17
   Record 6 = RR# 32
.....
Does anyone have a formula or method that will do this?
TIA
Jeff Young
Sr. Programmer Analyst
IBM -e(logo) server Certified Systems Exper - iSeries Technical Solutions V5R2
IBMÂ Certified Specialist- e(logo) server i5Series Technical Solutions Designer V5R3
IBMÂ Certified Specialist- e(logo)server i5Series Technical Solutions Implementer V5R3
Greetings,
Each of the solutions I have here uses an array. That is fine, of
course, but here is another way of doing it. The page size is
smaller, just because I did not read Jeff's question very carefully.
===== start dspf =====
  A     R LISTREC         SFL
  A                 4 2'Number:'
  A      NBR      3 0B  +1EDTCDE(Z)
  A                 4 20' '
  A
  A
  A     R CONTROL         SFLCTL(LISTREC)
  A 03                 SFLCLR
  A N03                 SFLDSPCTL
  A 02                 SFLDSP
  A                   SFLLIN(4)
  A
  A                   SFLSIZ(16) SFLPAG(15)
  A N01                 SFLEND(*MORE)
  A
  A                 3 2'Column headings would go +
  A                   here if +
  A                   I had anything to say'
  A                   COLOR(WHT)
===== start rpgle =====
  H dftactgrp(*no) actgrp('AA5614')
  H
  Faa5611  cf e      workstn sfile( listrec : recno )
  D recno     s       4 0
  D
  D flip      pr      3 0
  D colheight          3 0 value
  D rowwidth          3 0 value
  D seqnbr           3 0 value
  D
  D colheight   c         5
  D rowwidth    c         3
  D
  C/free
   *in03 = *on;
   write control;
   *in03 = *off;
   recno = *zero;
   for nbr = 1 to 31;
    recno = flip( colheight : rowwidth : nbr );
    write listrec;
   endfor;
   *in02 = *on;
   exfmt control;
   *inlr = *on;
   /end-free
  Pflip      b
  D flip      pi      3 0
  D colheight          3 0 value
  D rowwidth          3 0 value
  D seqnbr           3 0 value
  D
  D result     s         like(flip)
  D pagesize    s       3 0
  D nbrofs     s       3 0
  D pagofs     s       3 0
  D colofs     s       3 0
  D rowofs     s       3 0
  C/free
    pagesize = colheight * rowwidth;
ï    nbrofs = seqnbr - 1;
    pagofs = %int( nbrofs / pagesize );
    rowofs = %int( %rem( nbrofs : pagesize ) / rowwidth );
    colofs = %rem( nbrofs : rowwidth );
    result = 1 + pagofs * pagesize
           + colofs * colheight
           + rowofs;
   return result;
   /end-free
  Pflip      e
===== end source code ======
Cheers,
Terry.
As an Amazon Associate we earn from qualifying purchases.