|
|
| Author |
Message |
rarvins
Active User
Joined: 24 Jan 2007 Posts: 51 Location: India
|
|
|
|
Hi All,
I have a sort code that compares 2 files using JOIN KEYS and I create a reformatted output file that would take some fields from file 1 and some from file 2. Following is the code that I am using:
| Code: |
//JS001 EXEC PGM=SORT,REGION=0M
//*
//SYSOUT DD SYSOUT=*
//*
//SORTJNF1 DD DISP=SHR,DSN=Qual1.file1
//SORTJNF2 DD DISP=SHR,DSN=Qual2.file2
//*
//SORTOUT DD DISP=SHR,DSN=Qual3.file3
//*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(3,4,A,7,6,A,1,2,A)
JOINKEYS FILE=F2,FIELDS=(1,4,A,5,6,A,11,2,A)
REFORMAT FIELDS=(F1:1,31,F2:13,19,F1:51,692)
SORT FIELDS=COPY
/* |
In the above mentioned code I am taking a 19 byte field from the 13th position of file2 and all the remaining bytes from file1. But I have an extra condition to be added:
If the 19th byte starting from the 13th position in file2 is spaces then I need to take the same position from file1
Can somebody please help me in adding the condition |
|
| Back to top |
|
 |
References
|
|
 |
Moved: Wed Sep 03, 2008 9:30 pm by Frank Yaeger From DFSORT/ICETOOL to JCL |
arcvns
Senior Member
Joined: 17 Oct 2006 Posts: 756 Location: Chennai, India
|
|
|
|
| Quote: |
| If the 19th byte starting from the 13th position in file2 is spaces then I need to take the same position from file1 |
Hello rarvins,
When the above condition satisifes, do you want to copy the entire 19 bytes from file2 or just the 19th byte alone starting from 13th position?
Thanks,
Arun |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8730 Location: 221 B Baker St
|
|
|
|
Hello,
Please post a small amount of sample input and the output you want from that input. |
|
| Back to top |
|
 |
rarvins
Active User
Joined: 24 Jan 2007 Posts: 51 Location: India
|
|
|
|
File1:
| Code: |
====
(1-2) (3-6) (7-12) (13-31)
1------------ 2--------------- 3----------------- 4-------------------
90 116088625 37448446 374314012010768
90 128187385 160318665 374314012032267
|
File2:
| Code: |
====
(1-4) (5-10) (11-12) (13-31)
1--------------- 2----------------- 3------------ 4-------------------
116088625 37448446 90 4444444444444444
128187385 160318665 90 ________________
|
Where __ stands for blanks in file2
The output of my code would be as follows:
| Code: |
============================
(1-2) (3-6) (7-12) (13-31)
1------------ 2--------------- 3----------------- 4-------------------
90 116088625 37448446 4444444444444444
90 128187385 160318665 ________________
|
If you see the output of my existing code bytes 13-31 alone have been taken from file2 irrespective of it containing a value or a blank.
What I need help on is to populate the 13-31 bytes from file2 only if there is a valid value present. IF positions 13-31 in file2 is spaces then i have to populate the output file from file1 positions 13-31. So the output should be
| Code: |
(1-2) (3-6) (7-12) (13-31)
1------------ 2--------------- 3----------------- 4-------------------
90 116088625 37448446 444444444444444
90 128187385 160318665 374314012032267
|
Hope this helps.
Thanks |
|
| Back to top |
|
 |
arcvns
Senior Member
Joined: 17 Oct 2006 Posts: 756 Location: Chennai, India
|
|
|
|
rarvins,
Its really difficult for somebody to understand the data positions in your sample data. Can you please post the data using the "Code" tag.
Thanks,
Arun |
|
| Back to top |
|
 |
rarvins
Active User
Joined: 24 Jan 2007 Posts: 51 Location: India
|
|
|
|
| I think its been changed now arcvns. Please let me know if I need to do anything else |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8730 Location: 221 B Baker St
|
|
|
|
Hello,
Please re-post the input and output data without all of the dashes. Also, make sure the data is the proper length. The data posted does not always appear to match the specified length.
If you both "Code" the data as well as present it similar to data shown with COLS in tso/ispf, you can get something like:
| Code: |
1 2
....+....0....+....0
903456more |
Use the Preview to check how your post will appear to toe forum. After you Preview and are satisfied with the post, click Submit. |
|
| Back to top |
|
 |
rarvins
Active User
Joined: 24 Jan 2007 Posts: 51 Location: India
|
|
|
|
| Code: |
File 1:
9012347891021111111111111111111
9034567891122222222222222222222
File 2:
1234789102903333333333333333333
345678911290
Current output:
9012347891023333333333333333333
903456789112
Expected output:
9012347891023333333333333333333
9034567891122222222222222222222 |
I have changed the sample input and output so that it matches the lengths and the positions properly. Sorry for the inconvenience caused. |
|
| Back to top |
|
 |
arcvns
Senior Member
Joined: 17 Oct 2006 Posts: 756 Location: Chennai, India
|
|
|
|
Hello rarvins,
The below SYNCSORT card will do what you asked for. I have also considered the 692 bytes from the file-1 as posted in your original requirement.
| Code: |
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(3,10,A,1,2,A)
JOINKEYS FILE=F2,FIELDS=(1,10,A,11,2,A)
REFORMAT FIELDS=(F1:1,31,F2:13,19,F1:51,692)
INREC IFTHEN=(WHEN=(32,19,CH,EQ,C' '),OVERLAY=(32:13,19))
SORT FIELDS=COPY
OUTREC BUILD=(1,12,32,711)
/* |
Thanks,
Arun |
|
| Back to top |
|
 |
|
|
|