MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

File record replacement

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
naveen
Beginner


Joined: 03 Dec 2002
Posts: 90
Topics: 31

PostPosted: Tue Jul 08, 2003 7:06 am    Post subject: File record replacement Reply with quote

I have 2 files : MAINFILE and DATAFILE both FB 80 lrec. MAINFILE can contain any number of records but DATAFILE will just contain 3 records.

MAINFILE reads like this:
RALP ANDREWS 31 XXX 88 8888 BD*DEC*FLD ***************
TEST 200C002C MOVE ZEROS TO YYY-RECORD-LENGTH
CODE NUM: 11111111111111111111111111111111ZZZ111111111111111111
22 LAL122233 333 AJFAS 03 03 009.99 889.99 FREE
XXX 32 45 67


DATAFILE reads like this:
77 SAFASFS ASFASAS
888-UM CODE 32
4444444444


I want the contents of MAINFILE to be changed in such a way that,
MAINFILE after change will look like this:
RALP ANDREWS 31 XXX77 SAFASFS ASFASAS
TEST 200C002C MOVE ZEROS TO YYY888-UM CODE 32
CODE NUM: 11111111111111111111111111111111ZZZ4444444444
22 LAL122233 333 AJFAS 03 03 009.99 889.99 FREE
XXX77 SAFASFS ASFASAS

i.e.
1. whenever a XXX is encountered on any record in MAINFILE , the content after that, on the record should be replaced by first record on DATAFILE.
2. whenever a YYY is encountered on any record in MAINFILE , the content after that, on the record should be replaced by second record on DATAFILE.
3. whenever a ZZZ is encountered on any record in MAINFILE , the content after that on the record should be replaced by third record on DATAFILE.

How can this be achieved in REXX or any other utility ?


Last edited by naveen on Tue Jul 08, 2003 11:40 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jul 08, 2003 1:24 pm    Post subject: Reply with quote

Naveen,

The following job using sort/file-aid job will give you the desired results. A brief explanation of the job.STEP010 takes in the datafile and creates 3 control cards one for each line.The control cards created in this step will be as follows:
Line1 file:
Code:

$$DD01 COPY REPLALL=(1,0,C'XXX',C'XXX77 SAFASFS ASFASAS'),           

Line2 file:
Code:

            REPLALL=(1,0,C'YYY',C'YYY888-UM CODE 32'),               

Line3 file:
Code:

            REPLALL=(1,0,C'ZZZ',C'ZZZ4444444444')                   


now we concatenate these 3 control cards files together as sysin cards for file-aid which actually does the replace of the strings.

Code:

//STEP010  EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=YOUR DATAFILE,
//            DISP=SHR                                                 
//LINE1    DD DSN=&L1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)               
//LINE2    DD DSN=&L2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)               
//LINE3    DD DSN=&L3,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)               
//SYSIN    DD *                                                         
 SORT FIELDS=COPY                                                       
 OUTFIL FNAMES=LINE1,ENDREC=1,                                         
 OUTREC=(C'$$DD01 COPY REPLALL=(1,0,C',X'7D',C'XXX',X'7D',C',',         
         C'C',X'7D',C'XXX',1,18,X'7D',C'),',80:X)                       
 OUTFIL FNAMES=LINE2,STARTREC=2,ENDREC=2,                               
 OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'YYY',X'7D',C',',         
         C'C',X'7D',C'YYY',1,14,X'7D',C'),',80:X)                       
 OUTFIL FNAMES=LINE3,STARTREC=3,ENDREC=3,                               
 OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'ZZZ',X'7D',C',',         
         C'C',X'7D',C'ZZZ',1,10,X'7D',C')',80:X)                       
/*                                                                     
//STEP20   EXEC PGM=FILEAID                                             
//SYSPRINT DD SYSOUT=*                                                 
//DD01     DD DSN=YOUR MAINFILE,
//            DISP=SHR
//DD01O    DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE),
//            DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)         
//SYSIN    DD DSN=&L1,DISP=OLD   
//         DD DSN=&L2,DISP=OLD   
//         DD DSN=&L3,DISP=OLD                                                           


Hope this helps....

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
RonB
Beginner


Joined: 02 Dec 2002
Posts: 93
Topics: 0
Location: Orlando, FL

PostPosted: Tue Jul 08, 2003 4:28 pm    Post subject: Reply with quote

Naveen,
You're requirements are ambiguous. In each case you say "the content after that on the record should be replaced by the record on DATAFILE". By "the content after that on the record" do you mean everything up to column 80? If so, then example YYY is incorrect, since it didn't replace the trailing 11111s. If NOT so, then example XXX is incorrect, since the trailing asterisks disappeared. Which is it? Or which example is wrong?
Kolusu's solution will satisfy example YYY, but not example XXX.

Ron
_________________
A computer once beat me at chess, but it was no match for me at kick boxing.
Back to top
View user's profile Send private message
naveen
Beginner


Joined: 03 Dec 2002
Posts: 90
Topics: 31

PostPosted: Tue Jul 08, 2003 11:39 pm    Post subject: Reply with quote

Ron,
Everything upto col. 80 should be replaced. Example ZZZ was incorrect. Trailing 1111s should also be replaced. I've coorected it in main post also.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 09, 2003 5:55 am    Post subject: Reply with quote

Naveen,

My solution was based upon your first post before correction. The first ,second and third line in the datafile are 18,14& 10 bytes respectively. So I used the same exact length for them. So if you need to overlay the contents after finding the required string change the length to 70 in all the control cards as follows:

Code:

OUTFIL FNAMES=LINE1,ENDREC=1,                                         
OUTREC=(C'$$DD01 COPY REPLALL=(1,0,C',X'7D',C'XXX',X'7D',C',',         
         C'C',X'7D',C'XXX',1,70,X'7D',C'),',80:X)                       
OUTFIL FNAMES=LINE2,STARTREC=2,ENDREC=2,                               
OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'YYY',X'7D',C',',         
         C'C',X'7D',C'YYY',1,70,X'7D',C'),',80:X)                       
OUTFIL FNAMES=LINE3,STARTREC=3,ENDREC=3,                               
OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'ZZZ',X'7D',C',',         
         C'C',X'7D',C'ZZZ',1,70,X'7D',C')',80:X) 


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
naveen
Beginner


Joined: 03 Dec 2002
Posts: 90
Topics: 31

PostPosted: Wed Jul 09, 2003 6:36 am    Post subject: Reply with quote

Kolusu,
Your latest solution gives abend : S000.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 09, 2003 7:07 am    Post subject: Reply with quote

naveen,
Please post the exact sysout message from the sort step.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
naveen
Beginner


Joined: 03 Dec 2002
Posts: 90
Topics: 31

PostPosted: Wed Jul 09, 2003 9:33 am    Post subject: Reply with quote

This is the job which I am running. ( which is running fine with values 18,14,10 )

Code:
//STEP010  EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
77 SAFASFS ASFASAS                                                 
888-UM CODE 32                                                     
4444444444                                                         
/*                                                                 
//LINE1    DD DSN=&L1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)           
//LINE2    DD DSN=&L2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)           
//LINE3    DD DSN=&L3,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)           
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
  OUTFIL FNAMES=LINE1,ENDREC=1,                                     
  OUTREC=(C'$$DD01 COPY REPLALL=(1,0,C',X'7D',C'XXX',X'7D',C',',   
           C'C',X'7D',C'XXX',1,70,X'7D',C'),',80:X)                 
  OUTFIL FNAMES=LINE2,STARTREC=2,ENDREC=2,                         
  OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'YYY',X'7D',C',',   
           C'C',X'7D',C'YYY',1,70,X'7D',C'),',80:X)                 
  OUTFIL FNAMES=LINE3,STARTREC=3,ENDREC=3,                         
  OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'ZZZ',X'7D',C',',
           C'C',X'7D',C'ZZZ',1,70,X'7D',C')',80:X)               
/*                                                               
//STEP20   EXEC PGM=FILEAID                                     
//SYSPRINT DD SYSOUT=*                                           
//DD01     DD *                                                 
RALP ANDREWS 31 XXX 88 8888 BD*DEC*FLD ***************           
TEST 200C002C MOVE ZEROS TO YYY-RECORD-LENGTH                   
CODE NUM: 11111111111111111111111111111111ZZZ111111111111111111 
22 LAL122233 333 AJFAS 03 03 009.99 889.99 FREE                 
XXX 32 45 67                                                     
/*                                                               
//DD01O    DD DSN=ID.OUT.FILE,                           
//            DISP=(,CATLG,CATLG),                               
//            UNIT=SCRPK,                                       
//            SPACE=(TRK,(10,35),RLSE),                         
//            DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)                 
//SYSIN    DD DSN=&L1,DISP=OLD                                   
//         DD DSN=&L2,DISP=OLD                                   
//         DD DSN=&L3,DISP=OLD



This is abend message:

Code:
STEP010 - ABEND=S000 U0016 REASON=00000000


This is the message in sysout of STEP010:

Code:
SYSIN :                                                           
  SORT FIELDS=COPY                                               
  OUTFIL FNAMES=LINE1,ENDREC=1,                                   
  OUTREC=(C'$$DD01 COPY REPLALL=(1,0,C',X'7D',C'XXX',X'7D',C',', 
           C'C',X'7D',C'XXX',1,70,X'7D',C'),',80:X)               
  OUTFIL FNAMES=LINE2,STARTREC=2,ENDREC=2,                       
  OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'YYY',X'7D',C',', 
           C'C',X'7D',C'YYY',1,70,X'7D',C'),',80:X)               
  OUTFIL FNAMES=LINE3,STARTREC=3,ENDREC=3,                       
  OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'ZZZ',X'7D',C',', 
           C'C',X'7D',C'ZZZ',1,70,X'7D',C')',80:X)               
WER164B  6,896K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
WER164B     0 BYTES RESERVE REQUESTED, 1,004K BYTES USED         
WER146B  20K BYTES OF EMERGENCY SPACE ALLOCATED                   
WER108I  SORTIN   :  RECFM=FB   ; LRECL=    80; BLKSIZE=    80   
WER136A  LINE1     OUTREC HAS OVERLAPPING FIELDS SPECIFIED       
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                     
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 09, 2003 8:01 pm    Post subject: Reply with quote

Naveen,
The error you are getting is due to overlapping of outrec fields. The max length of the string you can replace is 68 bytes.So change the sort cards to the following.

Code:
 
 SORT FIELDS=COPY                                                   
 OUTFIL FNAMES=LINE1,ENDREC=1,                                       
 OUTREC=(C'$$DD01 COPY REPLALL=(1,0,C',X'7D',C'XXX',X'7D',C',',/,   
         C' C',X'7D',C'XXX',1,68,X'7D',C'),',80:X)                   
 OUTFIL FNAMES=LINE2,STARTREC=2,ENDREC=2,                           
 OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'YYY',X'7D',C',',/,   
         C' C',X'7D',C'YYY',1,68,X'7D',C'),',80:X)                   
 OUTFIL FNAMES=LINE3,STARTREC=3,ENDREC=3,                           
 OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'ZZZ',X'7D',C',',/,   
         C' C',X'7D',C'ZZZ',1,68,X'7D',C')',80:X)                   


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
naveen
Beginner


Joined: 03 Dec 2002
Posts: 90
Topics: 31

PostPosted: Thu Jul 10, 2003 12:25 am    Post subject: Reply with quote

Kolusu,
This is working great.
Thanks for your help.
Back to top
View user's profile Send private message Send e-mail
naveen
Beginner


Joined: 03 Dec 2002
Posts: 90
Topics: 31

PostPosted: Thu Jul 10, 2003 6:45 am    Post subject: Reply with quote

Kolusu,
What changes will be required in Sysin card , If I want to include one more record in my DATAFILE which will correspond to say 'WWW' (in addition to 3 records which were corresponding to 'XXX','YYY', & 'ZZZ') thus making a total of 4 records in DATAFILE.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jul 10, 2003 6:58 am    Post subject: Reply with quote

Naveen,

Allocate another file LINE4 and code the control cards for line4 as follows. Also you need to add a comma for line 3 file as it is no longer the last line.
Code:

OUTFIL FNAMES=LINE3,STARTREC=3,ENDREC=3,                           
OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'ZZZ',X'7D',C',',/,   
         C' C',X'7D',C'ZZZ',1,68,X'7D',C'),',80:X)
OUTFIL FNAMES=LINE4,STARTREC=4,ENDREC=4,                           
OUTREC=(C'            REPLALL=(1,0,C',X'7D',C'WWW',X'7D',C',',/,   
         C' C',X'7D',C'WWW',1,68,X'7D',C')',80:X)


Hope this helps....

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group