/* ------------------------- REXX ---------------------------------- * * Name: finddsn * * * * Function: Find the datasets allocted to a specified ddname * * * * Usage: called from a rexx or clist * * * * library = finddsn(ddname) * * * * library will contain a count of dsnames found for the * * dd followed by the dsnames * * * * For example: * * * * xx=finddsn(ispmlib);say xx * * 2 ISP.SISPMENU SYS1.PROD.ISPMENU * * * * History: * * Updated 05/09/2019 improve results * * Updated 11/13/2013 by Lionel B. Dyck * * - created from FINDDDN * * Updated 10/28/2013 by Lionel B. Dyck * * - cleanup for COMMAND and FUNCTION * * generalization * * Updated 5/28/2013 by Lionel B. Dyck * * - add test for function or command invocation * * Created 5/24/2013 by Lionel B. Dyck * * ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- * * Access variables to be used * * ----------------------------------------------------------------- */ parse source with sourcetype . arg dd /* ---------------------------- * * Define our working variables * * ---------------------------- */ hit = 0 results = '' /* ----------------------------------------------------------------- * * Trap list of current allocations * * ----------------------------------------------------------------- */ call outtrap 'trap.' Address TSO 'listalc sta' call outtrap 'off' /* ----------------------------------------------------------------- * * Process the allocations to find our DD * * Skip the 1st record * * ----------------------------------------------------------------- */ do i = 2 to trap.0 Select When left(trap.i,1) <> ' ' then do dsn = word(trap.i,1) if hit = 1 then call return_dsn end When substr(trap.i,3,1) <> ' ' then do ddn = word(trap.i,1) if ddn <> dd then if hit = 1 then signal dd_done else iterate hit = 1 call return_dsn end Otherwise nop end end return words(results) results /* ----------------------------------------------------------------- * * Done so get out of here * * ----------------------------------------------------------------- */ dd_done: results = subword(results,1,words(results)-1) if sourcetype = 'COMMAND' then do say '>>'results'<<' return end if length(results) = 0 then return 8 if sourcetype = 'FUNCTION' then return words(results) results /* ----------------------------------------------------------------- * * Test dsname for member and return all dsn's * * ----------------------------------------------------------------- */ return_dsn: Procedure Expose results dsn testdsn = "'"dsn"'" results = strip(results dsn) return