|
View previous topic :: View next topic
|
| Author |
Message |
renjithravi1 Warnings : 2 New User
Joined: 31 May 2005 Posts: 16
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
renjithravi1 Warnings : 2 New User
Joined: 31 May 2005 Posts: 16
|
|
|
|
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 |
|
 |
renjithravi1 Warnings : 2 New User
Joined: 31 May 2005 Posts: 16
|
|
|
|
Hi Frank,
You any solution to do the above requirement in DFSORT
Thanks and regards
Renjith |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
renjithravi1 Warnings : 2 New User
Joined: 31 May 2005 Posts: 16
|
|
|
|
Hi Skolusu,
It is working. Thanks for your suggestion
Regards
Renjith |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|