I've added just a little error checking to the sample program. Where the
original from yesterday had:

errCde.hdr.QUSBPrv = 0;
RtvReuse( rcvVar :%size(rcvVar) :qualRtnFN
:'FILD0100' :(fileIn + libIn) :' *FIRST'
:'0' :'*LCL' :'*INT'
:errCde);
ptrPFAtrs = ptrRcvVar + baseFD.QDBPFOf;
if %bitand(pFAtrs.QDBBits33 :x'80') = x'80';
reuseSts = 'YES';
else;
reuseSts = 'NO';
endif;
*inlr = *on;
return;

The new code is:

errCde.hdr.QUSBPrv = 0;
monitor;
RtvReuse( rcvVar :%size(rcvVar) :qualRtnFN
:'FILD0100' :(fileIn + libIn) :' *FIRST'
:'0' :'*LCL' :'*INT'
:errCde);
if %bitand(%subst(baseFD.QDBBits27 :1 :1) :x'20') = x'00';
ptrPFAtrs = ptrRcvVar + baseFD.QDBPFOf;
if %bitand(pFAtrs.QDBBits33 :x'80') = x'80';
reuseSts = 'YES';
else;
reuseSts = 'NO';
endif;
else;
reuseSts = 'N/A';
endif;
on-error;
reuseStsInd = -1;
endmon;
*inlr = *on;
return;

Basically I added a monitor block around the API call and related
processing. If a hard error is encountered (most likely with the API call)
then NULL will be returned by the function ('-' if using STRSQL) and a
message can be found in the joblog identifying the problem. For instance

select reuse_deleted_records('QPRINT', 'QGPL') from sysibm/sysdummy1


will return NULL and CPF3C23 (Object QPRINT is not a file of the correct
type) will be in the joblog. Likewise a file not found will result in
messages such as CPF5715.

Within the monitor block, when processing the API output, I also added a
check to make sure the file being processed is a physical file/table. If
not, then 'N/A' is returned by the function. So if you select from
systables and do NOT filter on table_type (I would recommend still
filtering on the select to avoid unnecessary calls to the function) then
other file types (a view or logical file for instance), if encountered,
will be returned as 'N/A' as in (using STRSQL):

Select system_table_name, system_table_schema,
Reuse_Deleted_Records(system_table_name,system_Table_schema)
From systables
where system_table_schema = 'VINING'

SYSTEM_TABLE_NAME SYSTEM_TABLE_SCHEMA Function
DATES VINING YES
HEX VINING NO
MYFILE VINING NO
MYFILELF VINING N/A
QCLSRC VINING NO
QPNLSRC VINING NO
QRPGLESRC VINING NO
QSQDSRC VINING NO
QSQLSRC VINING NO
TEST VINING YES
UCS2 VINING YES
VIEW1 VINING N/A

While in the program I also noticed that I had neglected to remove the
declare for variable theFile. That line can be removed.

There are plenty of other additions that could be made to the function, but
these two changes will detect/avoid some of the more obvious problems.


On Fri, Jan 17, 2020 at 8:39 AM Gord Hutchinson <gordm1@xxxxxxxxxxxxxxx>
wrote:

Oops. I think I was looking at a DSPFFD for another file just before I
answered a post here.

On Thu, 16 Jan 2020 at 15:12, John Yeung <gallium.arsenide@xxxxxxxxx>
wrote:

On Thu, Jan 16, 2020 at 3:07 PM Bruce Vining <bruce.vining@xxxxxxxxx>
wrote:

You're right of course. For some reason I just had DSPFFD on my mind
(and
didn't re-read the original reference to DSPFD).

The reason you had DSPFFD on your mind is that OP (Gord) and I both
did as well. The very first post in this thread had the correct
command, but then OP's own subsequent post introduced DSPFFD, and I
just ran with that.

John Y.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com



--
Gord Hutchinson
TST Overland Express
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com




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