Hello Munnu,
Here is a code I developed which will list all "EDI-" variables from a code and write to an output file. After that you may apply DFSORT on the output with SUM FIELDS=NONE option to remove the duplicates. It'd be cumbersome to do with REXX.
P.S - I developed this exec without mainframe and hence could not run it. Please test it before use.
/* REXX */
DROP INREC.
DROP OUTREC.
/* HARD-CODE INPUT & OUTPUT FILE */
INFILE = "XXX.YYY.ZZZ(AAA)"
OUTFILE = "PPP.QQQ.RRR(SSS)"
"ALLOCATE FI(INDSN) DA('"INFILE"') SHR REUSE"
"EXECIO * DISKR INDSN (STEM INREC. FINIS"
K = 1
J = 1
POSITION = 0
DO WHILE K <= INREC.0
POSITION = POS("EDI-",INREC.K)
IF POSITION > 0 THEN DO
OUTREC.J = EXTRACTFLD(INREC.K)
J = J + 1
SAY "ONE EDI- FIELD FOUND"
END
K = K + 1
END
OUTREC.0 = J - 1
"ALLOCATE FI(OUTDSN) DA('"OUTFILE"') SHR REUSE"
"EXECIO * DISKR OUTDSN (STEM OUTREC. FINIS"
/* END MAIN */
EXTRACTFLD:
/* THIS WILL EXTRACT THE VARIABLE NAME FROM THE LINE */
ARG INLINE
DO WHILE SUBSTR(INLINE,POSITION,1) <> " "
FLD = FLD || SUBSTR(INLINE,POSITION,1)
POSITION = POSITION + 1
END
FLD = STRIP(FLD)
RETURN FLD
/* END EXTRACTFLD */