× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



"
It is definitely the CHAIN that is the issue. It would appear that the
CHAIN/UPDATE requires the write of the subfile control before the READC
loop." - Paul Tuohy (e-mail below)

I would like very much to see any documentation where this is specified;
I couldn't find any (maybe I didn't know how/where to look for...)



Thank you


Florin Todor



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Paul Tuohy
Sent: Friday, October 01, 2010 5:37 AM
To: RPG programming on the IBM i / System i
Subject: Re: Chain and Readc

Hi Scott,

No more than yourself, it has been a few years since I have "played"
with subfiles - but this piqued my interest <g>

It is definitely the CHAIN that is the issue. It would appear that the
CHAIN/UPDATE requires the write of the subfile control before the READC
loop.

On the other hand - if you have a READC loop followed by a READC loop -
it works just fine.

If anyone feels the urge to play (and I have no idea why anyone would
want to) I am including the code for a display file and a trivial
program. The "important bit" is in the VALIDATE subroutine - comment out

either the READC loop or the CHAIN loop.

A DSPSIZ(24 80 *DS3)
A INDARA
A CA03(03 'Exit')
*
A R SUBREC SFL
A 54 SFLNXTCHG
A OPTION 1A B 7 3
A NUMBER 5S 0O 7 11

A R SUBCTL SFLCTL(SUBREC)
A OVERLAY
A 51 SFLDSP
A 52 SFLDSPCTL
A 53 SFLCLR
A 51 SFLEND(*MORE)
A SFLSIZ(0050)
A SFLPAG(0014)
A RRN 4S 0H
A 1 28'Test Subfile'
A 3 2'Type Option, Press Enter'
A 4 2'5=View'
A COLOR(BLU)
A 6 2'Opt'
A DSPATR(HI)
A 6 10'Data'

A R FOOTER
A 23 2'F3=Exit F5=Refresh'
A DSPATR(HI)
A COLOR(BLU)


H option(*srcStmt: *noDebugIO)
FTRPG007D CF E WorkStn SFile(SubRec: RRN)

D ctlEvent S 4

/free
ctlEvent = 'LOAD';

doU ctlEvent = '*END';
select;
when ctlEvent = 'LOAD';
exSR loadSubFile;
when ctlEvent = 'DISP';
exSR display;
when ctlEvent = 'VALD';
exSR validate;
when ctlEvent = 'PROC';
exSR process;
endSl;
endDo;

*inLR = *on;

begSR loadSubFile;

ctlEvent = 'DISP';

*in53 = *on;
write SUBCTL;
*in53 = *off;

RRN = 0;
option = *blanks;
number = 0;

for RRN = 1 to 10;
write SubRec;
endFor;

endSR;

begSR display;

ctlEvent = 'VALD';
*in51 = *on;
*in52 = *on;

write FOOTER;
exFmt SUBCTL;

*in51 = *off;
*in52 = *off;

select;
when *in03;
ctlEvent = '*END';
endSl;

endSR;

begSR validate;

ctlEvent = 'PROC';
RRN = 1;
*in54 = *on; // Set SFLNXTCHG

readC subRec;
dow not %EOF();
update subRec;
readC subRec;
endDo;

// for RRN = 1 to 10;
// chain RRN subRec;
// update subRec;
// endFor;

*in54 = *off;
endSR;

begSR process;

ctlEvent = 'DISP';

RRN = 1;
readC subRec;
dow not %EOF();
option = *blanks;
number += 1;
update subRec;
readC subRec;
endDo;

endSR;

/end-Free



Regards

Paul Tuohy
ComCon
www.comconadvisor.com
www.systemideveloper.com





Scott Klement wrote:
Hi Paul,


Hate to disagree, but you should not need to display the subfile for
the
subsequent READC to work.


Hmmm... I must admit, it's been a few years since I've done any
serious
subfile programming... but I definitely remember that if you set
SFLNXTCHG, then immediately try running READC (without displaying the
subfile in between) it wouldn't work.


The technique I have always used with "load all subfiles" is to
perform
a validation pass over a subfile (using a READC loop) and update each
subfile record with SFLNXTCHG set. If any record is invalid, the
subfile
is re-displayed. Otherwise, another READC loop is performed - without
any interim reference to the subfile control record.


Hmmm... I've never tried doing READC followed by another READC. I've
only done CHAIN followed by READC.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2024 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.