Handle DSPPGMREF Failures
This commit is contained in:
parent
bde7cea719
commit
e76ff16d9d
@ -22,15 +22,30 @@ or X-Analysis. If you don't have one, this *might* be somewhat useful.
|
||||
|
||||
This is the DDL to create the REFS file that the procedure builds.
|
||||
|
||||
Change the library and then run this first.
|
||||
Change the library of the REFS table to one of your libraries and then run this first.
|
||||
|
||||
## pgm_refs.sql
|
||||
This is the code to create the PGM_REFS procedure. The library in which the REFS file is built needs to be changed to suit your environment.
|
||||
This is the code to create the PGM_REFS procedure. Change the library of the REFS table to the library you used above.
|
||||
There are two places to change following a comments like this: <<<<<< Change this table library >>>>>>>
|
||||
|
||||
## pgm_refs_test.SQL
|
||||
|
||||
These are some samples of calling the procedure to test it. I used iACS Run SQL Scripts. You could also call it in a CL program using the RUNSQLSTM command. (Or run it in STRSQL.)
|
||||
|
||||
## Running
|
||||
|
||||
### Parameters
|
||||
See pgm_refs_test.sql for some sample call.
|
||||
|
||||
You need to supply library and name. The type will default to `*PGM` and the depth will default to `0` if not supplied.
|
||||
|
||||
### Library list
|
||||
|
||||
Since many objects will have a library of `*LIBL`, that is what will get passed to DSPPGMREF for expansion. So you need to have your library list contain all libraries whose objects you want expanded.
|
||||
|
||||
### DSPPGMREF Failure
|
||||
|
||||
If DSPPGMREF failsinternally, `*ERROR` will appear in the three `USES_*` fields in the REFS file. If you get a lot of these check you have your library list correct.
|
||||
## Sample Output File Contents
|
||||
|
||||

|
||||
@ -39,5 +54,5 @@ These are some samples of calling the procedure to test it. I used iACS Run SQL
|
||||
|
||||
I had difficulty debugging this.
|
||||
|
||||
1. I was working on PUB400.COM and the System Debugger in iACS shows the source, but it would never stop on breakpoints.
|
||||
1. I was working on PUB400.COM and the System Debugger in iACS shows the source, but it would never stop on breakpoints. You can debug on the green screen but it isn't as convenient.
|
||||
2. The DSPPGMREF outfiles are in QTEMP. You can make a single change to put them in one of you libraries if you want to look at them. You will also have to comment out the delete at the bottom of the loop.
|
||||
@ -2,6 +2,10 @@
|
||||
-- by calling itself recursively.
|
||||
-- Result is a file named REFS containing all the objects that
|
||||
-- DSPPGMREF knows about an object, to an essentially unlimited depth.
|
||||
|
||||
-- There are two places you need to change the library name, following
|
||||
-- a comment like this: -- <<<<<< Change this table library >>>>>>>
|
||||
|
||||
CREATE OR REPLACE PROCEDURE PGM_REFS (
|
||||
IN p_INLIB varCHAR(10)
|
||||
,IN p_INPGM varCHAR(10)
|
||||
@ -13,7 +17,7 @@ CREATE OR REPLACE PROCEDURE PGM_REFS (
|
||||
MODIFIES SQL DATA
|
||||
SET OPTION dbgview = *source, commit = *none
|
||||
begin
|
||||
-- Define DSPPGMREF library and file names
|
||||
-- Define DSPPGMREF OUTFILE library and file names
|
||||
declare WrkLib varchar(10) default 'QTEMP';
|
||||
declare WrkFileOS varchar(20) default '/WRK' ;
|
||||
declare WrkFileSQL varchar(20) default '.WRK';
|
||||
@ -22,7 +26,7 @@ begin
|
||||
declare my_sqlstate char(5);
|
||||
declare no_more_data char(5) default '02000';
|
||||
declare duplicate_key char(5) default '23505';
|
||||
|
||||
declare error_msg char(30) default ' ';
|
||||
declare Cmd varchar(1024);
|
||||
declare ref_cursor_txt varchar(512) default
|
||||
'select WHLIB, WHPNAM, WHTEXT, WHLNAM, WHFNAM, WHOTYP
|
||||
@ -36,17 +40,21 @@ begin
|
||||
declare USES_LIBRARY varchar(10);
|
||||
declare USES_NAME varchar(10);
|
||||
declare USES_TYPE varchar(10);
|
||||
declare USES_TEXT varchar(30);
|
||||
|
||||
declare duplicate_object condition for sqlstate '23505';
|
||||
declare QCMDEXC_Failure condition for sqlstate '38501';
|
||||
declare ref_cursor cursor for ref_cursor_stmt;
|
||||
|
||||
declare continue handler for duplicate_object
|
||||
begin
|
||||
set my_sqlstate = duplicate_key;
|
||||
end;
|
||||
declare continue handler for QCMDEXC_Failure
|
||||
begin
|
||||
set error_msg = 'QCMDEXC DSPPGMREF Failed';
|
||||
end;
|
||||
|
||||
-- Build pgm refs work file from DSPPGMREF command.
|
||||
-- Build pgm refs work file from DSPPGMREF command.
|
||||
set WrkFileOS = WrkLib
|
||||
concat trim(WrkFileOS)
|
||||
concat trim(char(p_Depth));
|
||||
@ -58,8 +66,26 @@ begin
|
||||
concat ' OUTFILE(' concat WrkFileOS concat ')'
|
||||
;
|
||||
CALL QSYS2.QCMDEXC (Cmd);
|
||||
|
||||
-- Open cursor over the outfile from DSPPGMREF
|
||||
|
||||
-- If DSPGMREF failed, build a record showing error
|
||||
-- occurred and return.
|
||||
if error_msg <> ' ' then
|
||||
-- <<<<<< Change this table library >>>>>>>
|
||||
insert into lennonsb.refs values (
|
||||
p_Depth,
|
||||
p_INLIB,
|
||||
p_inpgm,
|
||||
p_INTYPE,
|
||||
error_msg,
|
||||
'*ERROR',
|
||||
'*ERROR',
|
||||
'*ERROR'
|
||||
);
|
||||
set error_msg = ' ';
|
||||
return;
|
||||
end if;
|
||||
|
||||
-- Open cursor over the outfile from DSPPGMREF
|
||||
set WrkFileSQL = WrkLib
|
||||
concat trim(WrkFileSQL)
|
||||
concat trim(char(p_Depth));
|
||||
@ -79,7 +105,7 @@ begin
|
||||
if sqlstate = no_more_data then
|
||||
leave Refs_Loop;
|
||||
end if;
|
||||
-- <<<< Change this table library >>>>>
|
||||
-- <<<<<< Change this table library >>>>>>>
|
||||
insert into lennonsb.refs values (
|
||||
p_Depth
|
||||
,CALLER_LIBRARY
|
||||
|
||||
@ -5,6 +5,7 @@ call lennons1.pgm_refs(p_inlib => 'LENNONS1', p_inpgm => 'MTNCUSTR');
|
||||
-- Depth field starts at 6789, an arbitrary number
|
||||
call lennons1.pgm_refs('LENNONS1', 'MTNCUSTR','*PGM', 6789);
|
||||
call lennons1.pgm_refs(p_depth => 6789, p_inlib => 'LENNONS1', p_inpgm => 'MTNCUSTR');
|
||||
call lennons1.pgm_refs('FASTBREED', 'FSTMAINR','*PGM', 0);
|
||||
|
||||
-- Start with a *MODULE
|
||||
call lennons1.pgm_refs(p_inlib => 'LENNONSB', p_inpgm => 'ART300', p_INTYPE => '*MODULE');
|
||||
@ -12,8 +13,19 @@ call lennons1.pgm_refs(p_inlib => 'LENNONSB', p_inpgm => 'ART300', p_INTYPE => '
|
||||
-- Start with a *SRVPGMMODULE
|
||||
call lennons1.pgm_refs(p_inlib => 'LENNONSB', p_inpgm => 'FVAT', p_INTYPE => '*SRVPGM');
|
||||
|
||||
-- On PUB400.COM, give the program a work out and get some errors.
|
||||
call lennons1.pgm_refs('FASTBREED', 'FSTMAINR');
|
||||
|
||||
-- Find errors. If you have a lot it's probably a library list issue.
|
||||
select * from lennonsb.refs where USES_LIBRARY = '*ERROR';
|
||||
|
||||
-- List the output file of objects used
|
||||
select * from lennonsb.refs
|
||||
order by DEPTH, CALLER_LIBRARY, CALLER_NAME, CALLER_TYPE,
|
||||
USES_LIBRARY, USES_NAME, USES_TYPE;
|
||||
|
||||
-- Find the procedures you created
|
||||
select * from qsys2.sysprocs where ROUTINE_DEFINER = 'LENNONS';
|
||||
|
||||
-- Get rid off procedure regardless of signature
|
||||
drop specific procedure lennons1.pgm_refs;
|
||||
Loading…
x
Reference in New Issue
Block a user