Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

REXX file main file modify without modifying its copy file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: REXX file main file modify without modifying its copy file
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

Active Member


Joined: 08 May 2006
Posts: 995
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri Oct 15, 2010 4:05 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Fri Oct 15, 2010 4:06 pm    Post subject: Reply to: REXX file main file modify without modifying its c
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

Site Director


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

PostPosted: Fri Oct 15, 2010 7:13 pm    Post subject:
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

Senior Member


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

PostPosted: Fri Oct 15, 2010 7:23 pm    Post subject: Reply to: REXX file main file modify without modifying its c
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts REXX to get the all datasets name parasmalik20 CLIST & REXX 5 Tue Jul 18, 2017 9:10 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us