× 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.



Page at a time is the way to go.

Here's a sample program from my book on System APIs coming out in June. It
happens to be based on QUSLOBJ and shows how to handle page at a time
subfiles. I'm not including the DDS for the *DSPF, but there's nothing
special about it. The book of course has text explaining what's going on
(in addition to appendixes showing the same approach for fixed form RPG
and COBOL).

h dftactgrp(*no) bnddir('APILIB')

fFIG16_15 cf e workstn SFILE(SFLRCD:SFLCount)
f INFDS(WSFeedBack)

d/copy qsysinc/qrpglesrc,qusgen
d/copy qsysinc/qrpglesrc,quslobj

dCrtUsrSpc pr * extproc('CrtUsrSpc')
d SpcName 20 const

dListObj pr extpgm('QUSLOBJ')
d SpcName 20 const
d Format 8 const
d ObjLibName 20 const
d ObjTyp 10 const

dGenHdr ds likeds(QUSH0100)
d based(GenHdrPtr)

dListEntry ds likeds(QUSL010003)
d based(ListEntryPtr)

dSpcName ds
d SName 10 inz('TESTSPACE')
d SLib 10 inz('QTEMP')

dObjLibName ds
d ObjName 10 inz('*ALL')
d LibName 10 inz('*CURLIB')

dWSFeedBack ds
d AidKey 1 overlay(WSFeedBack :369)

dEnter c x'F1'
dPageUp c x'F4'
dPageDown c x'F5'

dListCount s 10i 0 inz(1)
dSFLCount s 4 0
dSFLPag s 10i 0 inz(16)
dSFLMax s 10i 0

/free

// Create user space and get a pointer to the start of the space
GenHdrPtr = CrtUsrSpc( SpcName);

// Call the List API
ListObj( SpcName :'OBJL0100' :ObjLibName :'*ALL');

// Check on the status of the returned list
if (GenHdr.QUSIS = 'C') or (GenHdr.QUSIS = 'P');

// Set ListEntryPtr to first entry
ListEntryPtr = GenHdrPtr + GenHdr.QUSOLD;

dow *in03 = *off; // Test F3 for exit

write SFLCtl; // Clear subfile

// determine maximum number of entries we can load
if (ListCount + SFLPag) > GenHdr.QUSNBRLE;
SFLMax = (GenHdr.QUSNBRLE - ListCount) + 1;
else;
SFLMax = SFLPAG;
endif;

// process all entries
for SFLCount = 1 to SFLMax;
// process the current list entry

ObjName = ListEntry.QUSOBJNU;
ObjLib = ListEntry.QUSOLNU;
ObjType = ListEntry.QUSOBJTU;
write SFLRcd;
ListCount += 1;
ListEntryPtr += GenHdr.QUSSEE;
endfor;

// Still more to process?
if ListCount >= GenHdr.QUSNBRLE;
*in24 = *on; // No, show 'Bottom'
else;
*in24 = *off; // Yes, show 'More'
endif;

*in21 = *on; // display subfile
write Key;
exfmt SFLCtl;
*in21 = *off;

if AidKey = Enter;
leave;
endif;

if AidKey = PageUp; // Page up key used
ListCount = (ListCount - SFLMax - SFLPag);
if ListCount < 1;
ListCount = 1;
endif;
// Set ListEntryPtr to desired entry
ListEntryPtr = (GenHdrPtr + GenHdr.QUSOLD +
((ListCount - 1) * GenHdr.QUSSEE));
endif;

enddo;

// List status is not Complete or Partial
else;
// Report an error
endif;

// exit when the list has been processed
*inlr = *on;
return;

/end-free

Hope this helps,
Bruce




Bryan Dietz <bdietz400@xxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
05/15/2007 07:57 AM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>


To
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
cc

Subject
today's how-best-to question...






I have a how-best-to question:

I have a utility program that gets a list of objects using the QUSLOBJ
API then retrieves info about each object in the list and displays in a
subfile.

The problem I ran into is that if the list has more than 9999 records it
blows up the subfile.

As I see it I have two choices; "page at a time" subfile or a UIM panel.

I know that a UIM panel would not have the 9999 record limitation and I
have used them.

I can see that a "page at a time" subfile works well for data from a
file, or "file like" source. I am struggling to figure out how best do
the same with the list api data in the user space.

I am thinking of cranking thru the list api and building a temp dtaq or
file to store the data then read from there to populate the "page at a
time" subfile. I worry about the performance having to essentially read
the data twice to show the first page.

I am not inclined to use the initial user space as I would have to keep
retrieving the object info for each page up/down request.

Bryan
--

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.