|
View previous topic :: View next topic
|
| Author |
Message |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
I have 2 files, and needs to get output using SORT
file-1
| Code: |
AB00001 X12
AB00002MACY12
* BBCZ34 |
File-2
| Code: |
AB00002AAAX12
AB00003CCCY13
AB00004SSSU32 |
If first 7 positions matches from both the file then
then from 8th position I i have to check for spaces or MAC then move 'N' to last byte of that record else 'M'
output:
|
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Do you need output like this
| Code: |
AB00001 X12N
AB00002MACY12N
* BBCZ34M |
Or
| Code: |
AB00001 X12 N
AB00002MACY12 N
* BBCZ34M |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| I have to skip the record where first 7 postions are equal to ' * ' |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
So final output would be
| Code: |
AB00001 X12N
AB00002MACY12N |
|
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Try this
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
AB00001 X12
AB00002MACY12
* BBCZ34
//INB DD *
AB00001 X12
AB00002AAAX12
AB00003CCCY13
AB00004SSSU32
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=INA,FIELDS=(1,7,A)
JOINKEYS F2=INB,FIELDS=(1,7,A)
REFORMAT FIELDS=(F1:1,13)
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(8,1,CH,EQ,C' '),BUILD=(1,13,14:C'N')),
IFTHEN=(WHEN=NONE,BUILD=(1,13,14:C'M'))
//*
//JNF1CNTL DD *
OMIT COND=(1,7,CH,EQ,C'*******')
//* |
Output
| Code: |
AB00001 X12N
AB00002MACY12M |
|
|
| Back to top |
|
 |
Naish
New User

Joined: 07 Dec 2006 Posts: 82 Location: UK
|
|
|
|
Pandora-Box,
Rohit wants 'N' @ 14th position when there are 'spaces' OR 'MAC' @ 8th position else 'M'. Correct me if I am wrong.
Also, Rohit, you have '*' in 2nd position in your data. (You can change the sort card accordingly).
Hope this helps.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
AB00001 X12
AB00002MACY12
AB00099TSTY12
* BBCZ34
//INB DD *
AB00001XYZX12
AB00002AAAX12
AB00003CCCY13
AB00004SSSU32
AB00099TS2Y12
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OMIT COND=(2,1,CH,EQ,C'*')
JOINKEYS F1=INA,FIELDS=(1,7,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(1,7,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,13)
OUTREC IFTHEN=(WHEN=(8,3,CH,EQ,C' ',OR,8,3,CH,EQ,C'MAC'),
BUILD=(1,13,14:C'N')),
IFTHEN=(WHEN=NONE,
BUILD=(1,13,14:C'M')) |
O/P:
| Code: |
AB00001 X12N
AB00002MACY12N
AB00099TSTY12M |
|
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
AB00001 X12
AB00002MACY12
* BBCZ34
//INB DD *
AB00001 X12
AB00002AAAX12
AB00003CCCY13
AB00004SSSU32
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=INA,FIELDS=(1,7,A)
JOINKEYS F2=INB,FIELDS=(1,7,A)
REFORMAT FIELDS=(F1:1,13)
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(8,1,CH,EQ,C' ',OR,8,3,CH,EQ,C'MAC'),BUILD=(1,13,14:C'N')),
IFTHEN=(WHEN=NONE,BUILD=(1,13,14:C'M'))
//*
//JNF1CNTL DD *
OMIT COND=(1,7,SS,EQ,C'*') |
Hi Naish,
We both missed
OMIT should use SS rather than CH |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Pandora-Box wrote: |
Is there a place where I could learn how sort inteprets these things
I believe it won't be available for layman like me  |
Pandora-Box,
Contrary to your name , you need to OPEN the box (manuals) that internet gave you. There is nothing cryptic about how BUILD or OVERLAY works. The manuals explains in detail about these parms. If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
And most DFSORT keywords follow the actual English meaning. So BUILD is actually building a record from scratch where as OVERLAY is just overlaying in a particular position with already built record.
When you use OVERLAY beyond the record length it is same as BUILD.
The most important Flowchart you need to keep in mind is this
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA60/1.5.4?
It shows you where and how each DFSORT keywords are processed. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
oh btw you can completely avoid the IFTHEN and use a simple CHANGE command to build the record.
| Code: |
//SYSIN DD *
JOINKEYS F1=INA,FIELDS=(1,7,A)
JOINKEYS F2=INB,FIELDS=(1,7,A)
REFORMAT FIELDS=(F1:1,13)
OPTION COPY
INREC BUILD=(1,13,8,3,CHANGE=(1,C' ',C'N',C'MAC',C'N'),
NOMATCH=(C'M'))
//* |
or
| Code: |
//SYSIN DD *
JOINKEYS F1=INA,FIELDS=(1,7,A)
JOINKEYS F2=INB,FIELDS=(1,7,A)
REFORMAT FIELDS=(F1:1,13)
OPTION COPY
INREC OVERLAY=(14:8,3,CHANGE=(1,C' ',C'N',C'MAC',C'N'),
NOMATCH=(C'M'))
//* |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Thanks a lot everyone.
I would try these options and come back agian. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
I have tried with ,
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
AB00001 X12
AB00002MACY12
AB00099TSTY12
* BBCZ34
//INB DD *
AB00001XYZX12
AB00002AAAX12
AB00003CCCY13
AB00004SSSU32
AB00099TS2Y12
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OMIT COND=(2,1,CH,EQ,C'*')
JOINKEYS F1=INA,FIELDS=(1,7,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(1,7,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,13)
OUTREC IFTHEN=(WHEN=(8,3,CH,EQ,C' ',OR,8,3,CH,EQ,C'MAC'),
BUILD=(1,13,14:C'N')),
IFTHEN=(WHEN=NONE,
BUILD=(1,13,14:C'M')) |
and it is ok, but if the match is not there then I want to add 'N' at the last byte of the record from the first input file and write it to a output file.
Could you please help to modify the above controld card?? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| Thank you Skolusu, I will try it. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
I am now using below SORT card,
| Code: |
SORT FIELDS=(1,16,CH,A)
SUM FIELDS=NONE
OPTION COPY
OMIT COND=(2,1,SS,EQ,C'*')
JOINKEYS F1=INA,FIELDS=(1,10,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(1,10,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,112,F2:340,3)
OUTREC IFTHEN=(WHEN=(113,3,CH,EQ,C' ',OR,113,3,CH,EQ,C'MAA',
OR,113,3,CH,EQ,C'MAE',OR,113,3,CH,EQ,C'MAD'),
BUILD=(1,112,113:C'N')),
IFTHEN=(WHEN=NONE,
BUILD=(1,112,113:C'M')) |
Here, if I want to get two output files like
1) one file will be created newly with DISP=(new,catlg,delete)
2)second file will be with DISP=SHR mode
then how to go ahead with this. |
|
| Back to top |
|
 |
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
| Rohit Umarjikar wrote: |
I am now using below SORT card,
| Code: |
SORT FIELDS=(1,16,CH,A)
SUM FIELDS=NONE
OPTION COPY
OMIT COND=(2,1,SS,EQ,C'*')
JOINKEYS F1=INA,FIELDS=(1,10,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(1,10,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,112,F2:340,3)
OUTREC IFTHEN=(WHEN=(113,3,CH,EQ,C' ',OR,113,3,CH,EQ,C'MAA',
OR,113,3,CH,EQ,C'MAE',OR,113,3,CH,EQ,C'MAD'),
BUILD=(1,112,113:C'N')),
IFTHEN=(WHEN=NONE,
BUILD=(1,112,113:C'M')) |
Here, if I want to get two output files like
1) one file will be created newly with DISP=(new,catlg,delete)
2)second file will be with DISP=SHR mode
then how to go ahead with this. |
Why whould you want to create a file with disp=shr? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
So, look at OUTFIL.
If you have a pre-allocated output dataset, write to it with DISP=OLD. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Rohit Umarjikar wrote: |
I am now using below SORT card,
| Code: |
SORT FIELDS=(1,16,CH,A)
SUM FIELDS=NONE
OPTION COPY
OMIT COND=(2,1,SS,EQ,C'*')
JOINKEYS F1=INA,FIELDS=(1,10,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(1,10,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,112,F2:340,3)
OUTREC IFTHEN=(WHEN=(113,3,CH,EQ,C' ',OR,113,3,CH,EQ,C'MAA',
OR,113,3,CH,EQ,C'MAE',OR,113,3,CH,EQ,C'MAD'),
BUILD=(1,112,113:C'N')),
IFTHEN=(WHEN=NONE,
BUILD=(1,112,113:C'M')) |
Here, if I want to get two output files like
1) one file will be created newly with DISP=(new,catlg,delete)
2)second file will be with DISP=SHR mode
then how to go ahead with this. |
Why do you have a OPTION COPY and also SORT FIELDS=(1,16,CH,A) for the main task? Why did you move the elimination of * records to the main task from JNF*CNTL?
If you are running Syncsort then please post your questions in the JCL forum and please do not take advantage of people trying to help you. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Craq,
I am replacing my current COBOL program with SORT so whatever the current fuctionality is there, I have to keep them same. And hence I am creating it with SHR. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
"DISP=SHR" is nothing to do with "functionality".
It will allow two jobs to access (including write to) the same dataset at the same time.
So, two jobs writing to the same dataset. Or one job writing another reading. At the same time. Dumb-as-all-heck. Review it. Unless it is "protected" from doing such things by some other method, then it should be changed.
I'm sure your spec doesn't really include "provide same functionality even if it is garbage and an accident waiting to happen". If it does, you should at least have something to say about it, not just lie down silently.
If nothing else, you need a CYA memo/e-mail so that you don't get busted for it whilst preparing your "I was warned about this, but you said..." to which the reply is "if I told you to jump off a cliff, would you just do it, because it is in the spec?" |
|
| Back to top |
|
 |
xknight
Active User

Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Hello,
| Quote: |
| I am replacing my current COBOL program with SORT so whatever the current fuctionality is there, I have to keep them same. And hence I am creating it with SHR. |
You dont have to follow the same unless it is meant to be. |
|
| Back to top |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
| Bill Woodger wrote: |
| If nothing else, you need a CYA memo/e-mail so that you don't get busted for it whilst preparing your "I was warned about this, but you said..." to which the reply is "if I told you to jump off a cliff, would you just do it, because it is in the spec?" |
And the reply to that is, "Yes, it is the requirement"  |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
| Quote: |
| And hence I am creating it with SHR. |
No, you're Not. If SHR successfully runs, the dataset already exists and will not be re-created. . .
SHR is NOT a requirement - the requirement is that the process work properly every time with no surprise "opportunities".
No output sequential file should ever be SHR unless it is a member of some PDS. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
yes I agree Dick. But this is something which is already in place,if it would have been into some new development project then would have sounds good not to use it in SHR mode Thanks again!! |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|