×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




First off...if your actual RRN field for the subfile is RRN...do NOT use
it for chains....create a "key" field.

If RRN IS your relative record number in the display file it is
associated with the currently displayed record.

WrkRRN    s Like(RRN)

 Write Heading;
WrkRrn=1;
Chain WrkRrn Kdsdata;
DoW %Found( Kdsdata );
   If Prtoverflow;
     Write Heading;
     Prtoverflow = *Off;
   Endif;
   Write detail;
   WrkRrn = WrkRrn + 1;
   Chain WrkRrn Kdsdata;
EndDo;
Write Footer;

or:

Write Heading
WrkRrn=1;
DoU %Found( Kdsdata );
   Chain WrkRrn Kdsdata;
   If %found( Kdsdatafilename );
      If Prtoverflow;
        Write heading;
        Prtoverflow = *Off;
      Endif;
      Write detail;
      WrkRrn = WrkRrn + 1;
   EndIf;
EndDo;
Write Footer;


Thanks,
Tommy Holden


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Brian Piotrowski
Sent: Monday, October 03, 2005 1:04 PM
To: RPG programming on the AS400 / iSeries
Subject: RE: Printing from a Subfile

Thanks to everyone who replied thus far.

Paul, I tried using the first routine you have written.  When I compile,
I get an RNF0394 error on the "DoW %found(kdsdata);" statement.

The kdsdata is the subfile record within my dmdpegd display file.  When
I put in the %found(dmdpegd), it compiles fine, but when I run the
program and print, it starts at the last record when it chains, and not
the first.

I would have thought that if I set RRN=1 then it would start at the
first record and read forward.  Is this not correct?

Thanks!

Brian.

-----Original Message-----
From: Paul Morgan [mailto:pmorgan@xxxxxxxxxxxxxx]
Sent: Monday, October 03, 2005 1:27 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Printing from a Subfile

Brian,

1) Use %found instead of %eof.
2) Your loop is broken.  The %found test on the DoW will be tested
before the subfile has ever been read.  You can either fix it by using
DoU and then inserting an If %found statement right after the chain in
the loop or by performing a chain just before the DoW loop and moving
the chain inside the loop to the bottom of the loop.

Your code would look like:

Write Heading;
Rrn=1;
Chain Rrn Kdsdata;
DoW %Found( Kdsdata );
   If Prtoverflow;
     Write Heading;
     Prtoverflow = *Off;
   Endif;
   Write detail;
   Rrn = Rrn + 1;
   Chain Rrn Kdsdata;
EndDo;
Write Footer;

or:

Write Heading
Rrn=1;
DoU %Found( Kdsdata );
   Chain Rrn Kdsdata;
   If %found( Kdsdatafilename );
      If Prtoverflow;
        Write heading;
        Prtoverflow = *Off;
      Endif;
      Write detail;
      Rrn = Rrn + 1;
   EndIf;
EndDo;
Write Footer;

Paul

--
Paul Morgan
Senior Programmer Analyst - Retail
J. Jill Group
100 Birch Pond Drive, PO Box 2009
Tilton, NH 03276-2009
Phone: (603) 266-2117
Fax:   (603) 266-2333

Brian wrote

>I'm having a brain-freeze today.... How do I print from a subfile?  So 
>far in my code I have (KDSDATA is the name of the subfile):

>Write heading;
>Rrn = 1;
>DoW not %eof(kdsdata);
>Chain Rrn Kdsdata;
>If prtoverflow;
>  Write heading;
>  Prtoverflow = *Off;
>Endif;
>Write detail;
>Rrn = Rrn + 1;
>Enddo;
>Write Footer;

>But the compiler is giving me grief with the %EOF() statement.  I now 
>know it is because the KDSDATA is not really a file, but a record.  Is 
>there such thing as "end of recordset", or am I going about this wrong?



--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.