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
 

 

match and replace

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
renjithravi1
Warnings : 2

New User


Joined: 31 May 2005
Posts: 16

PostPosted: Fri Mar 19, 2010 8:28 pm    Post subject: match and replace
Reply with quote

Hi,

I have one requirement like below,

File1
------------------
123;ABC;@@@

File2
------------------
ABC;XYZ;566

If the field2 in File1('ABC') matches with field1 in File2, then replace field2 in File1 with field2 in File2('XYZ'). The out file should look like below,

Ouput
--------------------
123;XYZ;@@@

Both the input files will have at least one occurance of the key and both the files are sorted based on Key.

I dont have support for JOINKEYS command since my DFSORT is old version. Is there any other way in DFSORT we can do this.

Thanks for your help

Regards
Renjith
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Mar 19, 2010 11:05 pm    Post subject:
Reply with quote

You need to give more information before I can help you.

What is the RECFM and LRECL of the input files?

Are the fields always three bytes long or are they real delimited fields that can have different lengths in different records? If different lengths, what is the maximum length for each field?

The key in File1 is the second delimited field and the key in File2 is the first delimited field?

Please show a better example of the records in each input file (relevant fields only) with matching and non-matching fields, and what you expect for output. Explain the "rules" for getting from input to output. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example.
Back to top
View user's profile Send private message
renjithravi1
Warnings : 2

New User


Joined: 31 May 2005
Posts: 16

PostPosted: Sat Mar 20, 2010 7:02 pm    Post subject:
Reply with quote

Hi Frank,

The semicolons i have put just to separate the fields. The details are as below,

File 1 ==> LRECL=156, RECFM=FB
File 2 ==> LRECL=1520, RECFM=FB

The Contents of the file1 is below,

000053281WPTRA501876XYZ...........
000055881WPTRA501877XYZ..........

The Key position in file1 is from 10 to 20 and the key is fixed length

The contents of file2 is below,

WPTRA501876KKB67887126...........
WPTRA501877KKC67887126...........

The key position in file2 is from 1 to 11 and the key is fixed length

There are no duplicates in both the files..

The output file LRECL and RECFM will be same as file1 and if the keys match replace the position 10 to 20 in file1 with values from position 12 to 22 in file2 and the output file will look like below,

000053281KKB67887126XYZ...........
000055881KKC67887126XYZ..........

Thanks and regards
Renjith
Back to top
View user's profile Send private message
renjithravi1
Warnings : 2

New User


Joined: 31 May 2005
Posts: 16

PostPosted: Mon Mar 22, 2010 5:30 pm    Post subject: Re: Match and Replace
Reply with quote

Hi Frank,

You any solution to do the above requirement in DFSORT

Thanks and regards
Renjith
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: Mon Mar 22, 2010 9:35 pm    Post subject:
Reply with quote

Hello,

If you needed this so quickly, you should have used something you already know - not something that you need someone else to do the work for you. . .
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Mar 22, 2010 9:39 pm    Post subject:
Reply with quote

renjithravi1,

The following DFSORT JCL will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=Your input FB 1520 byte file,DISP=SHR
//HEADR    DD DSN=&&HEADR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)         
//TM156    DD DSN=&&TM156,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)         
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC BUILD=(10:1,11,X,12,11,156:X)                                 
  OUTFIL FNAMES=TM156                                                 
  OUTFIL FNAMES=HEADR,ENDREC=1,BUILD=(3C'$',156:X)                     
//*                                                                   
//STEP0200 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=&&HEADR,DISP=SHR,VOL=REF=*.STEP0100.HEADR           
//         DD DSN=&&TM156,DISP=SHR                                     
//         DD DSN=&&HEADR,DISP=SHR,VOL=REF=*.STEP0100.HEADR           
//         DD DSN=your input FB 156 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(157:ID=1))   
  SORT FIELDS=(10,11,CH,A),EQUALS                                     
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(159:SEQNUM,8,ZD,RESTART=(10,11))),
  IFTHEN=(WHEN=GROUP,BEGIN=(159,8,ZD,EQ,1),PUSH=(10:22,11,158:157,1)) 
  OUTFIL INCLUDE=(157,2,ZD,EQ,21,AND,1,3,CH,NE,C'$$$'),BUILD=(1,156)   
//*
Back to top
View user's profile Send private message
renjithravi1
Warnings : 2

New User


Joined: 31 May 2005
Posts: 16

PostPosted: Tue Mar 23, 2010 6:11 pm    Post subject:
Reply with quote

Hi Skolusu,

It is working. Thanks for your suggestion

Regards
Renjith
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Match records - scdinesh DFSORT/ICETOOL 6 Wed Feb 22, 2017 5:02 am
No new posts JCL sort Match and NoMatch rakeshsekar1987 SYNCSORT 2 Thu Feb 02, 2017 10:26 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm


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