Sort Members from PDS using REXX

16 views
Skip to first unread message

Mridul

unread,
Aug 8, 2006, 2:18:14 PM8/8/06
to MFSTUDY
Hi All,

I have written a REXX program to address the particular issue:

I have a flat file which has 2 rows. First row contains the number of
members in a PDS and the second contains the name of that particular
PDS.My REXX code reads the flat file. It will first check the validity
of the input PDS using LISTCAT. Then it allocates two different PDS's
(one for COBOL Programs and the other for copbooks) using the same
attribute as the input PDS received from the flat file.It will then get
the list of members in the PDS. If the name starts with 'FWG0' it will
put these members in the copy library else it will put them in the
cobol program library.

The Rexx is causing problem at 2 places :
1: When executing this portion of the code

CALL OUTTRAP "TRAP."
"LISTD'"||PDSNAME||"'MEMBERS"
CALL OUTTRAP "OFF"
it gives the following problem:

33 *-* "LISTD'"||PDSNAME||"'MEMBERS"
+++ RC(-3) +++

2: When the following code is uncommented out and executed

/* "ALLOC F(MYINDD) DS('"DSNAME"("X")') SHR REUSE"
"ALLOC F(MYOUTDD) DS('"PDSNAMECPY"("X")') SHR REUSE"
"EXECIO * DISKR MYINDD (FINIS"
"EXECIO * DISKW MYOUTDD (FINIS"
"FREE F(MYINDD) F(MYOUTDD)" */
it gives the following problem:

57 +++ "ALLOC F(MYINDD) DS('"DSNAME"("X
4 +++ PDSNAME = STRIP(INPUT.2)
Error running GO, line 57: Invalid hexadecimal or binary string

The complete REXX Code is copied below:

/* REXX */
"EXECIO * DISKR INFILE(STEM INPUT."
PDSNAME = STRIP(INPUT.2)
CALL OUTTRAP "LISTC."
"LISTCAT ENTRIES('"PDSNAME"')"
IF RC \= 0 THEN DO
SAY "ERROR: DATA SET DOES NOT EXIST"
EXIT 12
END
CALL OUTTRAP "OFF"
PDSNAMEPGM = SUBSTR(PDSNAME,1,20)||'.COBOLSOR'
PDSNAMECPY = SUBSTR(PDSNAME,1,20)||'.COPYLIB'
"ALLOCATE DA('"PDSNAMEPGM"') LIKE('"PDSNAME"') NEW"
IF RC > 0 THEN DO
SAY "ERROR: FAILURE TO ALLOCATE DATASET" PDSNAMEPGM
EXIT 8
END
"ALLOCATE DA('"PDSNAMECPY"') LIKE('"PDSNAME"') NEW"
IF RC > 0 THEN DO
SAY "ERROR: FAILURE TO ALLOCATE DATASET" PDSNAMECPY
EXIT 8
END
CALL OUTTRAP "TRAP."
"LISTD'"||PDSNAME||"'MEMBERS"
CALL OUTTRAP "OFF"
I = 1
MEM_FOUND = "FALSE"
DO UNTIL MEM_FOUND = "TRUE"
SAY TRAP.I
IF TRAP.I = "--MEMBERS--" THEN DO
I = I + 1
MEM_FOUND = "TRUE"
END
ELSE DO
I = I + 1
END
END
J = 0
DO UNTIL I = TRAP.0
IF SUBSTR(STRIP(TRAP.I),1,4) = 'FWG0' THEN DO
X = STRIP(TRAP.I)
/* "ALLOC F(MYINDD) DS('"DSNAME"("X")') SHR REUSE"
"ALLOC F(MYOUTDD) DS('"PDSNAMECPY"("X")') SHR REUSE"
"EXECIO * DISKR MYINDD (FINIS"
"EXECIO * DISKW MYOUTDD (FINIS"
"FREE F(MYINDD) F(MYOUTDD)" */
END
ELSE DO
X = STRIP( TRAP.I)
/* "ALLOC F(MYINDD) DS('"DSNAME"("X")') SHR REUSE"
"ALLOC F(MYOUTDD) DS('"PDSNAMEPGM"("X")') SHR REUSE"
"EXECIO * DISKR MYINDD (FINIS"
"EXECIO * DISKW MYOUTDD (FINIS"
"FREE F(MYINDD) F(MYOUTDD)" */
END
I = I + 1
J = J + 1
END
IF J = INPUT.1 THEN DO
SAY 'SUCCESS'
END
ELSE DO
SAY "ERROR: INCONSISTENT DATA MOVEMENT"
EXIT 12
END

Reply all
Reply to author
Forward
0 new messages