I’m afraid that you can’t subset the returned list of spool files by date the way you want to.
What you can do, though, is to sort the list into date order and then only process the list to the boundary of your date range.
All the best
There is no reason to sort the list. Sorting will only make the process run slower.
The “Open List” APIs return single entries at a time or however many you can reserve space for. You need to check the date to see if it falls within the range when you have the entry. Adding each entry to some kind of array for sorting simply means that the sort is going to issue comparisons against each date anyway.
You’re better off not sorting.
A basic set of subfields for filter OSPF0200 that filters spooled files for USERID1 and USERID2, created between Nov 12, 2010 9:00 AM and Nov 13, 2010 3:00 PM, on *OUTQ OUTQLIB/OUTQ, would look like this in CL:<pre>
dcl &OSPF0200 *char 150
dcl &lOSPF0200 *char 4 value( x’00000096′ ) /* 150 */
dcl &ofsUsers *char 4 value( x’0000006E’ ) /* 110 */
dcl &nbrUsers *char 4 value( x’00000002′ ) /* 2 */
dcl &lUsers *char 4 value( x’0000000A’ ) /* 10 */
dcl &ofsOutQs *char 4 value( x’00000082′ ) /* 130 */
dcl &nbrOutQs *char 4 value( x’00000001′ ) /* 1 */
dcl &lOutQs *char 4 value( x’00000014′ ) /* 20 */
dcl &filler1 *char 52 value( ‘……..’ )
dcl &StrDate *char 7 value( ‘1101112’ )
dcl &StrTime *char 6 value( ‘090000’ )
dcl &EndDate *char 7 value( ‘1101113’ )
dcl &EndTime *char 6 value( ‘150000’ )
dcl &filler2 *char 4 value( x’00000000′ )
dcl &User1 *char 10 value( ‘USERID1’ )
dcl &User2 *char 10 value( ‘USERID2’ )
dcl &OutQ *char 10 value( ‘OUTQ’ )
dcl &OutQLib *char 10 value( ‘OUTQLIB’ )</pre>
The entire filter structure fits in 150 bytes in this case. The first seven subfields are 4-byte integers. They are defined here as *CHAR(4) with hex values to show how the values fit in memory in the filter structure. All of the subfields can be concatenated together to build the &OSPF0200 structure. (In V5R4 CL or in HLLs, a data structure would allow setting the subfields directly in the data structure.)
The first field is &lOSPF0200. The x’96’ value is 150 in decimal to indicate that the complete structure is 150 bytes long. The structure can be longer, but only 150 bytes will be passed into the API.
The next subfield is &ofsUsers, x’6E’ (decimal 110), to mark the offset to the beginning of the list of users. The basic fixed length of OSPF0200 is 110 bytes, so the users list should not start before offset 110.
Next is &nbrUsers, x’02’, to indicate two users in the list. The length of user entries, &lUsers, is x’0A’, decimal 10. User entries can be longer than 10, but I don’t know why they should be.
Then, &ofsOutQs is x’82’ (decimal 130) to show that it follows the list of users. &nbrOutQs is x’01’ because there is only one in the list, and &lOutQs is x’14’ (decimal 20) because 20 bytes is plenty to hold an *OUTQ name and library.
The &filler1 field would be replaced by any other subfields that aren’t covered in this question. It covers 56 bytes of memory.
The &StrDate is a simple *CHAR(7) that holds a starting date in CYYMMDD format. &StrTime is *CHAR(6) that holds starting time in HHMMSS format.
The &EndDate is a simple *CHAR(7) that holds an ending date in CYYMMDD format. &EndTime is *CHAR(6) that holds ending time in HHMMSS format.
Together, the start/end dates/times provide the date range for selection in the resulting list.
The &filler2 field is a *CHAR(4) that is filled with binary zeros. It can be longer, but I wouldn’t trust it to be shorter if there are any selection fields after it. And if you make it longer, all of its bytes need to be filled with binary zeros.
Wherever that last field ends will be where any lists will start. You choose how far in memory you want to place your lists. I chose to start them right after the “reserved” area is defined in the specs.
The &User1 and &User2 fields are elements of an array of *CHAR(10) fields. You put as many elements there as you need. Your question asked about two user IDs. The &OutQ and &OutQLib fields are subfields of a *CHAR(20) array. You asked about a single *OUTQ.
If you leave any unused bytes between any arrays such as the user and outq arrays, those bytes should have binary zeros in them.
In ILE RPG (or V5R4 CL), you should probably base definitions for user and outq on the address just after the reserved field. Add element values one at a time, and increase the basing pointer by the length of each entry that you add. Keep count so you can add to the length that you specify in &lOSPF0200. Make sure you have enough memory allocated. Either create all of the memory allocation to hold as much as you’re going to populate for the whole structure or declare it big enough to hold the most you’ll ever use.
If you have trouble, post the related code and definitions. Also post the error message, particularly the message identifier.