IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

REXX file main file modify without modifying its copy file


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sourabh jain

New User


Joined: 29 Feb 2008
Posts: 27
Location: Pune

PostPosted: Fri Oct 15, 2010 3:46 pm
Reply with quote

Using REXX, could you please tell me how to copy one file (main-file) to a backup file. And then modify some data at definite positions in the Main-File (not the backup file). This is required to be done in a single JCL.

I have written a JCL which will execute in the following manner.

STEP1 - In the first STEP of the Parent JCL, run a JCL which will create a backup file of the main file with system time added to the end of backup file name.

STEP2 - In the second STEP of the Parent JCL, execute another REXX program which will do the modification of data in the main file.

Problem: When this Parent JCL is run, then main file is getting modified as required. But the backup file is also getting modified which is not required.


/* Parent JCL code */

//DEMOJCL JOB ,'REXXPROG',CLASS=A,TIME=1440,
// NOTIFY=&SYSUID,
// MSGCLASS=Q
//*
//STEP010 EXEC PGM=IKJEFT1B
//SYSTSIN DD *
SUBMIT 'USERID.REXX.JCL(DATEDEMO)'
//SYSTSPRT DD SYSOUT=*
/*
//STEP020 EXEC PGM=IKJEFT01
//SYSEXEC DD DSN=USERID.REXX.EXEC.DEMOPROG,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
%DEMOPROG USERID.REXX.EXEC.INFILE1
/*


------

/* JCL written to run the REXX code for creating backup data */

//JOB123 JOB ,'DEMODATE',CLASS=A,TIME=1440,
// NOTIFY=&SYSUID,
// MSGCLASS=X
//*
// SET OLDDSN='USERID.REXX'
//*
//STEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=&OLDDSN,
// DISP=(,CATLG,DELETE),UNIT=DISK,
// SPACE=(TRK,(50,10),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//*
//STEP2 EXEC PGM=IKJEFT01,
// PARM='PROG1 &OLDDSN USERID.REXX.EXEC.INFILE1'
//SYSTSIN DD DUMMY
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
//SYSEXEC DD DSN=USERID.REXX.EXEC.DEMOPROG,DISP=SHR

-------

/* REXX Code for copying main file to back up file */
/* Program name = USERID.REXX.EXEC.DEMOPROG(PROG1) */

/* REXX */
PARSE ARG odsn inpfile
Call CurrTime
Call ChngFileNm
Call CreateBckFile
EXIT
/* END of Main Program */
CurrTime:
tod = TIME()
PARSE VAR tod hh ':' mn ':' ss
timedd = hh||mn
RETURN
/* End of Current Time */
ChngFileNm:
ndsn = odsn'.T'timedd
"RENAME '"odsn"' '"ndsn"' "
RETURN
/* End of Rename File */
CreateBckFile:
"alloc DA('"inpfile"') f(indd) shr reuse"
"alloc DA('"ndsn"') f(outdd) shr reuse"
"EXECIO * DISKR indd (STEM record."
"EXECIO 0 DISKR indd (FINIS"
"EXECIO" record.0 "DISKW outdd (STEM record."
"EXECIO 0 DISKW outdd (FINIS"
"FREE f(indd)"
"FREE f(outdd)"
RETURN
/* End of Create Back-up File */

------

/* REXX Code for modifying tha data in main input file */
/* Program name = USERID.REXX.EXEC.DEMOPROG(DEMOPROG) */

/* REXX */
PARSE ARG infile
Say '*******************'
Say '* MAIN PROGRAM *'
Say '*******************'
Say
Call DateRet
rc = 0
"alloc DA('"infile"') f(updd) OLD"
Call RevDate
EXIT
/* End Of Main */
DateRet:
"alloc DA('userid.rexx.exec.infile2') f(indd) shr reuse"
"EXECIO 1 DISKR indd (FINIS"
PULL record
PARSE VAR record 1 date1 11
PARSE VAR record 1 date1 11
PARSE VAR date1 1 year 5 6 mnth 8 9 day
date3 = year||mnth||day
"FREE f(indd)"
RETURN
/* End of Data retrieval */
Say
/* Start of Data Modification */
RevDate:
"EXECIO * DISKRU updd (STEM rec. FINIS"
IF rc = 0 THEN
DO
Say "-----------------------------------"
Say "- "rec.0 "records are read -"
Say "-----------------------------------"
Say
DO i = 1 TO rec.0
PARSE VAR rec.i 1 idx 3 remdata
IF idx = 00 THEN
DO
PARSE VAR remdata 1 val 3 date2 13 rest
remdata = val||date1||rest
rec.i = idx||remdata
END
ELSE
IF idx = 12 THEN
DO
PARSE VAR remdata 1 val 2 date2 10 rest
remdata = val||date3||rest
rec.i = idx||remdata
END
ELSE NOP
END
"EXECIO" rec.0 "DISKW updd (STEM rec."
IF rc = 0 THEN
DO
Say
Say rec.0 "records are modified"
END
ELSE
DO
rc = RC
Say
Say "Error during write, return code is" rc
END
END
ELSE
DO
rc = RC
Say
Say "Error during write, return code is" rc
END
Say
"EXECIO 0 DISKW updd (FINIS"
"FREE f(updd)"
RETURN
/* End of Reverse Data Modification */

------------


Above are the programs that I have written.
Please tell me if there is any possible solution for the above mentioned issue.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Fri Oct 15, 2010 4:05 pm
Reply with quote

You are submitting a job to run the REXX to copy the file in the first step. How do you know how soon this will run?

Youll probably find that the copy job is executing after the REXX to modify the file is run - so you get the same details in bopth the original and the copy.

I'd suggest you rethink your approach. Maybe setup the 'parent' JCL to use IEBCOPY or IEBGENER to copy the original file and only when the copy has completed run the REXX.

Garry.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Oct 15, 2010 4:06 pm
Reply with quote

let' s all hope that this is just for training
describe clearly the requirements
and we' ll be glad to provide an overall better solution

Quote:
This is required to be done in a single JCL.

You just flunked the requirement by having a <parent> jcl and a submitted jcl
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Oct 15, 2010 7:13 pm
Reply with quote

Hello,

Keep in mind that simpler is almost always better.

There are utilities for making a copy of a file. REXX is a very bad choice for copying files.

As you mentioned, the process needs to run serially - not concurrently. So, the submit will be removed.

Re-think how you will implement and post back here. We will let you know what we think.

FWIW - your sort product will probably make the copy very quickly.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Fri Oct 15, 2010 7:23 pm
Reply with quote

You have two jobs...

replace STEP10 with STEP1 and STEP2 from the second job. And get rid of the second job.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top