You are on page 1of 4

H DFTACTGRP(*NO) OPTION(*SRCSTMT: *NODEBUGIO) ** This program will find all places that a bound module is called.

** (by searching all ILE programs in the user libraries) ** ** Scott Klement, May 7, 1997 ** fQSYSPRT O F 80 * * Field Definitions. * d searchlibrary s d ObjectLibrary s d EC_Escape PR d When d CallStackCnt d ErrorCode PRINTER OFLIND(*INOF)

10 20 60A const 10I 0 value 32766A options(*varsize) ExtPgm('QBNLPGMI') const const const options(*varsize)

* List ILE program information API d QBNLPGMI PR d UsrSpc 20A d Format 8A d PgmName 20A d Errors 32766A

* List ILE service program information API d QBNLSPGM PR ExtPgm('QBNLSPGM') d UsrSpc 20A const d Format 8A const d SrvPgm 20A const d Errors 32766A options(*varsize) * Create User Space API d QUSCRTUS PR d UsrSpc d ExtAttr d InitSize d InitVal d PublicAuth d Text d Replace d Errors ExtPgm('QUSCRTUS') 20A const 10A const 10I 0 const 1A const 10A const 50A const 10A const 32766A options(*varsize)

* Retrieve pointer to user space API d QUSPTRUS PR ExtPgm('QUSPTRUS') d UsrSpc 20A const d Pointer * d d d d d d * API error code structure dsEC DS dsECBytesP dsECBytesA dsECMsgID dsECReserv dsECMsgDta

10I 0 inz(%size(dsEC)) 10I 0 inz(0) 7A 1A 240A

* List API generic header structure d p_Header S *

d dsLH DS BASED(p_Header) * Filler d dsLHFill1 103A * Status (I=Incomplete,C=Complete d dsLHStatus 1A d dsLHFill2 12A d dsLHHdrOff 10I 0 d dsLHHdrSiz 10I 0 d dsLHLstOff 10I 0 d dsLHLstSiz 10I 0 d dsLHEntCnt 10I 0 d dsLHEntSiz 10I 0 * * PGML0100 format: modules in program * SPGL0100 format: modules in service program * (these fields are the same in both APIs) d p_Entry S * d dsPgm DS based(p_Entry) d dsPgm_Pgm 10A d dsPgm_PgmLib 10A d dsPgm_Module 10A d dsPgm_ModLib 10A d dsPgm_SrcF 10A d dsPgm_SrcLib 10A d dsPgm_SrcMbr 10A d dsPgm_Attrib 10A d dsPgm_CrtDat 13A d dsPgm_SrcDat 13A d peModule d Entry c c c c *entry S S plist parm parm 10A 10I 0 peModule SearchLibrary

except PrtHeader * Create a user space to stuff module info into c callp QUSCRTUS('MODULES QTEMP': 'USRSPC': c 5120*3072: x'00': '*ALL': c 'List of modules': '*YES': dsEC) c if dsECBytesA > 0 c callp EC_Escape('Calling QUSCRTUS API':3:dsEC) c endif c callp QUSPTRUS('MODULES QTEMP': p_Header) c eval objectLibrary = '*ALL ' + c searchlibrary * List all ILE programs modules to space c callp QBNLPGMI('MODULES QTEMP': 'PGML0100': c objectLibrary : dsEC) c if dsECBytesA > 0 c callp EC_Escape('Calling QBNLPGMI API':3:dsEC) c endif * List occurrances of our module c eval p_Entry = p_Header + dsLHLstOff c c c for if except Entry = 1 to dsLHEntCnt dsPgm_Module = peModule PrtModule

c c c

endif eval

p_Entry = p_Entry + dsLHEntSiz

endfor * List all ILE service program modules to space c callp QBNLSPGM('MODULES QTEMP': 'SPGL0100': c '*ALL *ALLUSR': dsEC) c if dsECBytesA > 0 c callp EC_Escape('Calling QBNLSPGM API':3:dsEC) c endif * List occurrances of our module c eval p_Entry = p_Header + dsLHLstOff c c c c c c for if except endif eval endfor * And that's about the size c eval OQSYSPRT o o o o o o o o o o o o o E Entry = 1 to dsLHEntCnt dsPgm_Module = peModule PrtModule p_Entry = p_Entry + dsLHEntSiz of it *inlr = *on 2 3 10 +3 'Listing of programs' +1 'that use module' +1 75 'Page' 80 2 3 10 +1 +1 +1 +1 +1

PrtHeader *DATE peModule PAGE

PrtModule dsPgm_Pgm dsPgm_PgmLib dsPgm_SrcF dsPgm_SrcLib dsPgm_SrcMbr dsPgm_SrcDat

* Send back an escape message based on an API error code DS P EC_Escape B d EC_Escape PI d When 60A const d CallStackCnt 10I 0 value d ErrorCode 32766A options(*varsize) * Send Program Message API d QMHSNDPM PR d MessageID d QualMsgF d MsgData d MsgDtaLen d MsgType d CallStkEnt d CallStkCnt d MessageKey d Errors ExtPgm('QMHSNDPM') 7A Const 20A Const 256A Const 10I 0 Const 10A Const 10A Const 10I 0 Const 4A 1A

* API error code (passed from caller) d p_EC S *

d d d d d d

dsEC dsECBytesP dsECBytesA dsECMsgID dsECReserv dsECMsgDta

DS 10I 0 10I 0 7A 1A 240A

based(p_EC)

* API error code (no error handling requested) d dsNullError DS d dsNullError0 10I 0 inz(0) d MsgDtaLen d MsgKey c c c c c c * c c c * c c c c P S S 10I 0 4A

eval p_EC = %addr(ErrorCode) if dsECBytesA <= 16 eval MsgDtaLen = 0 else eval MsgDtaLen = dsECBytesA - 16 endif diagnostic msg tells us when the error occurred in our pgm callp QMHSNDPM('CPF9897': 'QCPFMSG *LIBL': When: %Len(%trimr(when)): '*DIAG': '*': 1: MsgKey: dsNullError) send back actual error from API callp QMHSNDPM(dsECMsgID: 'QCPFMSG *LIBL': dsECMsgDta: MsgDtaLen: '*ESCAPE': '*': CallStackCnt: MsgKey: dsNullError) E

You might also like