I have written a REXX that does my function but i able to read from a flat file and write into a flat file. Is there any way for me to read a PDS member and create a o/p PDS member after running my REXX?
REXX is as follows :
Code:
/******* REXX*******/
"FREE FI(OUTDD)"
"FREE FI(INDD)"
"ALLOC FI(OUTDD) DA('output.flat.file') "
"ALLOC FI(INDD) DA('INPUT.flat.file.DATASET') "
EOFFLG = 4 /* RETURN CODE TO INDICATE END-OF-FILE */
RETURN_CODE = 0 /* INITIALIZE RETURN CODE */
IN_CTR = 0 /* INITIALIZE # OF LINES READ */
IN_CTR1= 0 /* INITIALIZE # OF LINES READ */
IN_CTR2= 0 /* INITIALIZE # OF LINES READ */
OUT_CTR = 0 /* INITIALIZE # OF LINES WRITTEN */
PUSH1 = 'N'
STFND ='N'
ALF='N'
LIB1 ='//STEPLIBDDDSN=&DSLEV..DB2.DSNLOAD'
LIB11 ='//DDDSN=&DSLEV..DB2.DSNLOAD'
LIB2 ='//DDDSN=&DSLEV..&RGN..BATCH.LOAD '
LIB22 ='//STEPLIBDDDSN=&DSLEV..&RGN..BATCH.LOAD '
LIB3 ='//DDDSN=SYS2.DB2.&DSNA.SDSNLOAD'
LIB33 ='//STEPLIBDDDSN=SYS2.DB2.&DSNA.SDSNLOAD'
LIB4 ='//DDDSN=SYS3.CAI.EZTPLUS.&DSNA.CAILIB'
LIB44 ='//STEPLIBDDDSN=SYS3.CAI.EZTPLUS.&DSNA.CAILIB'
LIB5 ='//DDDSN=SYS3.CAI.PANSQL.&DSNA.LOAD'
LIB55 ='//STEPLIBDDDSN=SYS3.CAI.PANSQL.&DSNA.LOAD'
LIB6 ='//STEPLIBDDDSN=&DSLEV..&RGN..BATCH.LOAD'
LIB7 ='//STEPLIBDDDSN=SYS2.DB2.&DSNA.SDSNLOAD'
LIB1FLG='N'
LIB2FLG='N'
LIB3FLG='N'
LIB4FLG='N'
LIB5FLG='N'
LIB6FLG='N'
LIB7FLG='N'
/*******************************************************************/
/* OPEN THE INDD FILE */
/*******************************************************************/
"EXECIO 0 DISKR INDD (OPEN" /* OPEN INDD */
/*******************************************************************/
/* NOW READ ALL LINES FROM INDD, STARTING AT LINE 1, AND COPY */
/* SELECTED LINES TO OUTDD. */
/*******************************************************************/
DO WHILE (RETURN_CODE ^ = EOFFLG) /* LOOP WHILE NOT END-OF-FILE */
'EXECIO 1 DISKR INDD' /* READ 1 LINE TO THE DATA STACK */
RETURN_CODE = RC /* SAVE EXECIO RC */
/*IF RETURN_CODE = 0 THEN */ /* GET A LINE OK? */
/*DO /* YES */ */
IN_CTR = IN_CTR + 1 /* INCREMENT INPUT LINE CTR */
SAY 'IN_CTR' =IN_CTR
PARSE PULL LINE.1 /* PULL LINE JUST READ FROM STACK*/
PAV1 = LINE.1
PARSE VAR PAV1 WORD1 WORD2 WORD3
STRIP1 = STRIP(WORD1)
STRIP2 = STRIP(WORD2)
STRIP3 = STRIP(WORD3)
PAV2 =STRIP1||STRIP2||STRIP3
PAV3 =SUBSTR(STRIP1||STRIP2||STRIP3,1,11)
SAY 'PAV3:' SUBSTR(PAV2,1,32)
SAY 'LIB1FLG:'LIB1FLG
SAY 'LIB2FLG:'LIB2FLG
SAY 'LIB3FLG:'LIB3FLG
SAY 'LIB4FLG:'LIB4FLG
SAY 'LIB5FLG:'LIB5FLG
SAY 'LIB6FLG:'LIB6FLG
SAY 'LIB7FLG:'LIB7FLG
IF SUBSTR(PAV3,1,2) = ' ' THEN
DO
EOFFLG = 4
EXIT
END
IF PAV3 = '//STEPLIBDD' THEN
DO
STFND ='Y'
SAY 'STEP-FOUND ='STFND
CALL SET_FLG
END
ELSE
CALL SET_FLG
CALL SET_PUSH
SAY 'STFND=' STFND
SAY 'PUSH1=' PUSH1
IF STFND='N'|(STFND= 'Y'& PUSH1 ='Y'& (SUBSTR(PAV2,10,7)='INCLUDE'))THEN
DO
SAY 'WRITE OUTPUT'
"EXECIO 1 DISKW OUTDD (STEM LINE."
OUT_CTR = OUT_CTR + 1
IF PUSH1 ='Y' THEN
DO
SAY'INSIDE THE RESET FLAG IS STATEMENT'
PUSH1='N'
STFND='N'
SAY 'STFND=' STFND
SAY 'PUSH1=' PUSH1
END
END
END
/*EXIT*/
SET_FLG:
SAY 'INSIDE SET_FLG'
DO
IF SUBSTR(PAV2,1,34)=LIB1 |SUBSTR(PAV2,1,27)=LIB11 THEN
DO
LIB1FLG = 'Y'
SAY 'LIB1FLG =' LIB1FLG
END
IF SUBSTR(PAV2,1,32)=LIB2 THEN
DO
LIB2FLG = 'Y'
SAY 'LIB2FLG =' LIB2FLG
END
IF SUBSTR(PAV2,1,31)=LIB3 |SUBSTR(PAV2,1,37)=LIB33 THEN
DO
LIB3FLG = 'Y'
SAY 'LIB3FLG =' LIB3FLG
END
IF SUBSTR(PAV2,1,37)=LIB4 |SUBSTR(PAV2,1,44)=LIB44 THEN
DO
LIB4FLG = 'Y'
SAY 'LIB4FLG =' LIB4FLG
END
IF SUBSTR(PAV2,1,34)=LIB5 |SUBSTR(PAV2,1,41)=LIB55 THEN
DO
LIB5FLG = 'Y'
SAY 'LIB5FLG =' LIB5FLG
END
IF SUBSTR(PAV2,1,39)=LIB6 THEN
DO
LIB6FLG = 'Y'
SAY 'LIB5FLG =' LIB6FLG
END
IF SUBSTR(PAV2,1,38)=LIB7 THEN
DO
LIB7FLG = 'Y'
SAY 'LIB5FLG =' LIB7FLG
END
END
RETURN
SET_PUSH:
SAY 'INSIDE SET_PUSH'
IF (STFND='Y')&(LIB1FLG='Y')&(LIB2FLG='Y')&(LIB3FLG='Y') ,
& (LIB4FLG='Y') & (LIB5FLG='Y') THEN
DO
PUSH '//STEPLIB INCLUDE MEMBER=STEPEZT'
PUSH1 ='Y'
LIB1FLG='N'
LIB2FLG='N'
LIB3FLG='N'
LIB4FLG='N'
LIB5FLG='N'
END
IF (STFND='Y')&(LIB1FLG='Y')&(LIB2FLG='Y')&(LIB3FLG='Y') ,
&(LIB4FLG='N')&(LIB5FLG='N') THEN
DO
PUSH '//STEPLIB INCLUDE MEMBER=STEPDB2'
SAY 'INSIDE SET_PUSH'
PUSH1 ='Y'
LIB1FLG='N'
LIB2FLG='N'
LIB3FLG='N'
LIB4FLG='N'
LIB5FLG='N'
LIB6FLG='N'
LIB7FLG='N'
END
IF (STFND='Y')&(LIB1FLG='N')&(LIB2FLG='N')&(LIB7FLG='Y') ,
&(LIB4FLG='N')&(LIB5FLG='N') THEN
DO
PUSH '//STEPLIB INCLUDE MEMBER=STEPSQL'
SAY 'INSIDE SET_PUSH'
PUSH1 ='Y'
LIB1FLG='N'
LIB2FLG='N'
LIB3FLG='N'
LIB4FLG='N'
LIB5FLG='N'
LIB6FLG='N'
LIB7FLG='N'
END
IF (STFND='Y')&(LIB1FLG='N')&(LIB6FLG='Y')&(LIB3FLG='N') ,
&(LIB4FLG='N')&(LIB5FLG='N') THEN
DO
PUSH '//STEPLIB INCLUDE MEMBER=STEPCOB'
SAY 'INSIDE SET_PUSH'
PUSH1 ='Y'
LIB1FLG='N'
LIB2FLG='N'
LIB3FLG='N'
LIB4FLG='N'
LIB5FLG='N'
LIB6FLG='N'
LIB7FLG='N'
END
RETURN
Edited: Please use BBcode when You post some code/error, that's rather readable, Thanks... Anuj
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
Here is the code that I have used in the past to do something similar. The code is part of a larger edit macro but this part deals with STEPLIB replacement.
Obviously this is not a perfect match for your requirement, but that will be up to you to adapt.
The macro is invoked from a control REXX which edits each PDS member with the macro. The member shown in the code is a member in the same PDS that is being edited and contains the code to be inserted into the PDS member being edited.
Code:
DO FOREVER
"ISREDIT FIND 'STEPLIB' FIRST"
IF RC <> 0 THEN LEAVE
"ISREDIT (CRSLINE,CRSCOL) = CURSOR"
"ISREDIT COPY member AFTER "CRSLINE
"ISREDIT EXCLUDE 'STEPLIB' ALL"
"ISREDIT DELETE X ALL"
END