I am trying with the below code , but it is giving later version code , I tried giving Dataset.GDG(-2) but gives me error. Do i need to change anything below.
PARSE UPPER PULL GDG
DSN = STRIP(GDG!!".G0000V00") /* DEFAULT IF NOT EXIST */
X=OUTTRAP(LST.) /* LISTCAT GDG BASE */
" LISTC ENT('"GDG"')"
DO A = LST.0 TO 1 BY -1 /* FIRST FIND = 0 GDG */
IF POS('NONVSAM',LST.A) > 0 THEN DO
DSN = SUBSTR(LST.A,POS('NONVSAM',LST.A)+13,44)
A = 0
SAY "GDG=" GDG
SAY "DSN =" DSN
"EXECIO "QUEUED() "DISKW OUTSRCH (FINIS"