|
How about using SQL to access the data, with cursors and fetches.
In this way you will not have to worry about tens of logical files.
Dynamic SQL in RPG is less performant compared with static SQL, because atOr even nicer with prepared sql's.
Wilt, Steve...
Thanks for the input. Do you know of any examples of this kind of
thing on the web?
Kelley
----- Original Message -----
From: "Wilt, Charles" <WiltC@xxxxxxxxxx>
To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx>
Sent: Wednesday, December 12, 2007 9:53 AM
Subject: RE: A Question Of Technique
Kelly,contents
You don't "exit" a service program...mainly because you never enter
it. <grin>
Instead, the service program contains one or more individual
procedures. Those procedures can be called from outside (or inside
:) the service program, ie. From your UI program.
You have two options for returning data from a procedure.
1) In an parameter variable
2) As a returned value.
In either case, the data can be a single variable or a DS.
You'll see many of examples of procedures that output/return the
of the entire record using aneed
DS defined from the external file. However, I'd argue against doing
it that way. When you need to change the file, you have to
recompile the world. The reality is few program really need the
entire record, mainly the just CRUD programs. The rest only need
certain parts of the data in the file.
Another technique is to have Getters/Setters that set/return
individual fields. Again, I'd argue against doing it this way.
Mostly because you end up duplicating the business logic related to
the fields. In addition, it's more work when you need data out of
more than one field.
Instead, consider having procedures that return the data in a
business appropriate way. For instance, a GetDescriptiveInfo() that
returns item#, name, size, and other often used together fields. In
addition, if you've currently got Yes/No type flag fields, don't use a
GetFlagFld() type procedure to
return the actual value of the field. Instead, use a IsItemSomething()
procedure. This way, if you
ever need to change the business logic behind the decision, you only
to change it in one place.
I've gone so far as to have a GetSimpleList() procedure that takes
as input, the number of records at a time you want and an empty DS
of the appropriate size to fill; which I can call from multiple
subfile programs, either 5250 or web based.
HTH,
Charles
--
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 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.