IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SORT control card needed


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Jun 12, 2012 7:48 pm
Reply with quote

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:
Code:
AB000001   X12N
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jun 12, 2012 8:08 pm
Reply with quote

Do you need output like this

Code:
AB00001   X12N
AB00002MACY12N
 *          BBCZ34M
Or

Code:
AB00001   X12     N 
AB00002MACY12     N
 *          BBCZ34M
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Jun 12, 2012 8:31 pm
Reply with quote

I have to skip the record where first 7 postions are equal to ' * '
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Jun 12, 2012 8:32 pm
Reply with quote

So final output would be
Code:

AB00001   X12N
AB00002MACY12N
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jun 12, 2012 8:54 pm
Reply with quote

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
View user's profile Send private message
Naish

New User


Joined: 07 Dec 2006
Posts: 82
Location: UK

PostPosted: Tue Jun 12, 2012 9:12 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jun 12, 2012 9:38 pm
Reply with quote

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 icon_sad.gif

OMIT should use SS rather than CH
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Jun 13, 2012 12:21 am
Reply with quote

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 icon_sad.gif


Pandora-Box,

Contrary to your name , you need to OPEN the box (manuals) that internet gave you. icon_biggrin.gif 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
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Jun 13, 2012 12:26 am
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Wed Jun 13, 2012 6:13 pm
Reply with quote

Thanks a lot everyone.
I would try these options and come back agian.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Jun 19, 2012 8:29 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Jun 19, 2012 9:26 pm
Reply with quote

add this line before REFORMAT statement in your control cards
Code:

JOIN UNPAIRED,F1


Check this link which explains in detail about JOIN statement

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA60/4.4?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Wed Jun 20, 2012 6:10 pm
Reply with quote

Thank you Skolusu, I will try it.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Mon Jun 25, 2012 7:20 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Jun 25, 2012 7:48 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jun 25, 2012 8:32 pm
Reply with quote

So, look at OUTFIL.

If you have a pre-allocated output dataset, write to it with DISP=OLD.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Jun 25, 2012 9:30 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Wed Jun 27, 2012 3:22 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 27, 2012 4:20 pm
Reply with quote

"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
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Wed Jun 27, 2012 6:27 pm
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Jun 27, 2012 6:49 pm
Reply with quote

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" icon_razz.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 27, 2012 7:18 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Jul 03, 2012 5:32 pm
Reply with quote

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 icon_smile.gif Thanks again!!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top