-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram_CallStack_Table_Used
More file actions
224 lines (223 loc) · 11.9 KB
/
Copy pathProgram_CallStack_Table_Used
File metadata and controls
224 lines (223 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
-- category: .SYS
-- description: sys_Program_Call_stack
-- =========+=========+=========+=========+=========+=========+=========+=========+=========+=========+
-- =========+=========+=========+=========+=========+
-- Build the work file with program reference information.
cl:DSPPGMREF PGM(CAFTERIA/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *REPLACE);
cl:DSPPGMREF PGM(DOCSYS/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(cobra/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
--cl:DSPPGMREF PGM(webdata/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD); Don't need No Pgms
cl:DSPPGMREF PGM(parking/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(directpa/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(websrv/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(#library/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(rvicust/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(acount/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(asiap/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(asiar/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(asims/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(hralib/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(phone/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(payrol/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
--cl:DSPPGMREF PGM(logo/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD); Don't need No Pgms
cl:DSPPGMREF PGM(enumchg/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD);
cl:DSPPGMREF PGM(prodtest/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*ALL) OUTFILE(KCRAWFORD2/@tTmpSql91) OUTMBR(*FIRST *ADD)
;
stop
;
-- =========+=========+=========+=========+=========+
-- Create a work variable with search value Change the default and run both
CREATE OR REPLACE VARIABLE kcrawford2.@vTmpSql91 CHAR(10) DEFAULT 'EMPLRATR' -- Program searching for
;
CREATE OR REPLACE VARIABLE kcrawford2.@vTmpSql92 CHAR(10) DEFAULT 'STATES' -- File searching for
;
stop
;
-- =========+=========+=========+=========+=========+
-- What programs are called by this program? What is the call stack?
Select distinct
trim(whFnam) "Pgm"
, trim(whLib) "Library"
,'Called_By' as "Action",
Connect_By_Root whPnam "Program_Name",
Connect_By_Root trim(whPnam) concat
Sys_Connect_By_Path(trim(whFnam)
concat '.'
concat lower(trim(whOtyp))
, ' > ') "Call_Stack"
, Level "Levels"
,(SELECT objcreated
FROM TABLE (QSYS2.OBJECT_STATISTICS(trim(whLib), '*ALL')) Z
where z.objlib = trim(whLib) and
z.objname = trim(whFnam) fetch first row only) "Obj_Created"
,(SELECT last_used_timestamp
FROM TABLE (QSYS2.OBJECT_STATISTICS(trim(whLib), '*ALL')) Z
where z.objlib = trim(whLib) and
z.objname = trim(whFnam) fetch first row only) "Obj_Last_Used"
from kcrawford2.@tTmpSql91
where whFnam not like 'Q%'
and whFnam not like '*%'
and whFnam not like '&%'
and whObjT != 'F'
and whOTyp != '*FILE'
and Connect_By_isCycle = 0
and Connect_By_isLeaf = 0
-- and level < 2
Start With whPnam = kcrawford2.@vTmpSql91
Connect By NoCycle whPnam = Prior whFnam
and prior whObjT != 'F'
and prior whOTyp != '*FILE'
and prior whFnam != kcrawford2.@vTmpSql91
union all
-- =========+=========+=========+=========+=========+
-- What programs call this program? What is the reverse call stack?
Select distinct
trim(whPnam) "Pgm",
trim(whLib) "Library",
'Call_This' as "Action",
Connect_By_Root whFnam "Program_Name",
Connect_By_Root trim(whFnam) concat
Sys_Connect_By_Path(trim(whPnam)
concat '.'
concat lower(trim(whOtyp))
, ' < ') "Called_By_Stack"
, Level "Levels"
,(SELECT objcreated
FROM TABLE (QSYS2.OBJECT_STATISTICS(trim(whLib), '*ALL')) Z
where z.objlib = trim(whLib) and
z.objname = trim(whPnam)) "Obj_Created"
,(SELECT last_used_timestamp
FROM TABLE (QSYS2.OBJECT_STATISTICS(trim(whLib), '*ALL')) Z
where z.objlib = trim(whLib) and
z.objname = trim(whPnam)) "Obj_Last_Used"
from kcrawford2.@tTmpSql91
where whPnam not like 'Q%'
and whPnam not like '*%'
and whPnam not like '&%'
and whObjT != 'F'
and whOTyp != '*FILE'
and Connect_By_isCycle = 0
-- and Connect_By_isLeaf = 0
and level < 2
Start With whFnam = kcrawford2.@vTmpSql91
Connect By NoCycle whFnam = Prior whPnam
and prior whObjT != 'F'
and prior whOTyp != '*FILE'
and prior whPnam != kcrawford2.@vTmpSql91
Order By 3,1
;;
-- =========+=========+=========+=========+=========+
-- =========+=========+=========+=========+=========+
-- What files are used by this program?
select whPnam as "Program"
, whFnam as "Uses_This"
, whotyp as "Object_Type"
,case when whFUsg = 1 then 'I'
when whFUsg = 2 then 'O'
when whFUsg = 3 then 'I/O'
when whFUsg = 4 then 'U'
when whFUsg = 5 then 'I/U'
when whFUsg = 6 then 'O/U'
when whFUsg = 7 then 'I/O/U'
when whFUsg = 8 then 'N/S'
when whFUsg = 0 then 'N/A'
else '?'
end "Program Usage"
,(select source_type from qsys2.syspartitionstat where table_schema = x.whLib and
table_name in ('QRPGLESRC', 'CLSRC', 'QS36SRC') and table_Partition = x.whpnam
order by table_name fetch first row only) as SRC_type
,whLib as "SRC_Lib"
,(select table_name from qsys2.syspartitionstat where table_schema = x.whLib and
table_name in ('QRPGLESRC', 'CLSRC', 'QS36SRC') and table_Partition = x.whpnam
order by table_name fetch first row only) as SRC_File
,whRFnm as "Table Record Format"
,(select objtype from table(qsys2.object_statistics(x.whlib,'PGM',x.whfnam))) as Obj_Type
,(select sql_object_type from table(qsys2.object_statistics(x.whlib,'PGM',x.whfnam))) as Sql_Obj_type
,whText as "Text"
,(select last_used_timestamp from table(qsys2.object_statistics(x.whlib,'PGM',x.whfnam))) as Last_Used
,(select objcreated from table(qsys2.object_statistics(x.whlib,'PGM',x.whfnam))) as Obj_Created
,(select change_timestamp from table(qsys2.object_statistics(x.whlib,'PGM',x.whfnam))) as Obj_Changed
,(select last_source_update_timestamp from qsys2.syspartitionstat where table_schema = x.whLib and
table_name in ('QRPGLESRC', 'CLSRC', 'QS36SRC') and table_Partition = x.whfnam
order by table_name fetch first row only) as SRC_Last_Update
,(select last_change_timestamp from qsys2.syspartitionstat where table_schema = x.whLib and
table_name in ('QRPGLESRC', 'CLSRC', 'QS36SRC') and table_Partition = x.whfnam
order by table_name fetch first row only) as SRC_last_change
,(select last_used_timestamp from qsys2.syspartitionstat where table_schema = x.whLib and
table_name in ('QRPGLESRC', 'CLSRC', 'QS36SRC') and table_Partition = x.whfnam
order by table_name fetch first row only) as SRC_last_used
from KCRAWFORD2.@tTmpSql91 x
where whPnam = kcrawford2.@vTmpSql91
and whObjt = 'F'
Order By 2
;;
-- =========+=========+=========+=========+=========+
-- =========+=========+=========+=========+=========+
-- What programs use this file?
-- What programs use this file or it's dependants
Select whFnam "File/Logical/Table/View"
,trim(whPnam) "Used_by"
,lower(trim(case when whSPkg = 'P' then 'Pgm'
when whSPkg = 'S' then 'SQLPkg'
when whSPkg = 'V' then 'SrvPgm'
when whSPkg = 'M' then 'Module'
when whSPkg = 'Q' then 'QryDfn'
else '?'
end)) "Pgm_Type"
,(select source_type from qsys2.syspartitionstat where table_schema = x.whLib and
table_name in ('QRPGLESRC', 'CLSRC', 'QS36SRC') and table_Partition = x.whpnam
order by table_name fetch first row only) as SRC_type
,whLib
,(select table_name from qsys2.syspartitionstat where table_schema = x.whLib and
table_name in ('QRPGLESRC', 'CLSRC', 'QS36SRC') and table_Partition = x.whpnam
order by table_name fetch first row only) as SRC_File
,whRFnm
,case when whFUsg = 1 then 'I'
when whFUsg = 2 then 'O'
when whFUsg = 3 then 'I/O'
when whFUsg = 4 then 'U'
when whFUsg = 5 then 'I/U'
when whFUsg = 6 then 'O/U'
when whFUsg = 7 then 'I/O/U'
when whFUsg = 8 then 'N/S'
when whFUsg = 0 then 'N/A'
else '?'
end "Usage"
,(select objtype from table(qsys2.object_statistics(x.whlib,'PGM',x.whpnam))) as Obj_Type
,(select sql_object_type from table(qsys2.object_statistics(x.whlib,'PGM',x.whpnam))) as Sql_Obj_type
,whText
,(select last_used_timestamp from table(qsys2.object_statistics(x.whlib,'PGM',x.whpnam))) as Last_Used
,(select objcreated from table(qsys2.object_statistics(x.whlib,'PGM',x.whpnam))) as Obj_Created
,(select change_timestamp from table(qsys2.object_statistics(x.whlib,'PGM',x.whpnam))) as Obj_Changed
,(select last_source_update_timestamp from qsys2.syspartitionstat where table_schema = x.whLib and
table_name in ('QRPGLESRC', 'CLSRC', 'QS36SRC') and table_Partition = x.whpnam
order by table_name fetch first row only) as SRC_Last_Update
,(select last_change_timestamp from qsys2.syspartitionstat where table_schema = x.whLib and
table_name in ('QRPGLESRC', 'CLSRC', 'QS36SRC') and table_Partition = x.whpnam
order by table_name fetch first row only) as SRC_last_change
,(select last_used_timestamp from qsys2.syspartitionstat where table_schema = x.whLib and
table_name in ('QRPGLESRC', 'CLSRC', 'QS36SRC') and table_Partition = x.whpnam
order by table_name fetch first row only) as SRC_last_used
from KCRAWFORD2.@tTmpSql91 x
where whFnam = kcrawford2.@vTmpSql92
or whFnam in (SELECT DBFFDP FROM QSYS.QADBFDEP q
WHERE DBFFIL = kcrawford2.@vTmpSql92
or dbffil in (select dbffil from qsys.qadbfdep
where dbffdp = kcrawford2.@vTmpSql92)
union
SELECT DBFFIL FROM QSYS.QADBFDEP q
WHERE DBFFIL = kcrawford2.@vTmpSql92
or dbffil in (select dbffil from qsys.qadbfdep
where dbffdp = kcrawford2.@vTmpSql92)
)
--and (select last_used_timestamp from table(qsys2.object_statistics(x.whlib,'PGM',x.whpnam))) > '2019-12-30 00:00:00.000000'
Order By 2,1
;
stop
;
-- =========+=========+=========+=========+=========+
-- Clean UP
cl:DLTF FILE(KCRAWFORD2/@tTmpSql91);
cl:DLTSRVPGM SRVPGM(KCRAWFORD2/@vTmpSql91);
cl:DLTSRVPGM SRVPGM(KCRAWFORD2/@vTmpSql92);
;