SORT FIELDS=(1,3,CH,A,9,3,CH,A)



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

SORT FIELDS=(1,3,CH,A,9,3,CH,A)

Postby dn2012 » Wed May 02, 2012 5:11 am

Hello


//SYSIN    DD *
   SORT FIELDS=(1,3,CH,A,9,3,CH,A)
/*

What does it do?

FIRST KEY
1,3,CH,A - first key started at string/space 1 , its length is 3

SECOND KEY
9,3,CH,A - second key started at string/space 9, its length is 3

For example if we have following data

12345678901234567890
hello  world   hello
Adam Travel

My understanding is as: (for first key)
Position 1 and length is 3, Character , seq Asscending

 First Key
Out put will be
12345678901234567890
Adam Travel
hello  world   hello

SECOND KEY
12345678901234567890
hello  world   hello
Adam Travel


Is it correct?

I am little confused in combining both. Any help will be appricated

Thanks
dn2012
 
Posts: 114
Joined: Thu Feb 16, 2012 6:10 am
Has thanked: 0 time
Been thanked: 0 time

Re: SORT FIELDS=(1,3,CH,A,9,3,CH,A)

Postby dick scherrer » Wed May 02, 2012 7:26 am

Hello,

You need to use the Code tag when posting things that need to remain aligned. . .

It would also be better if you thought about your topic and used a meaningful subject.

Is it correct?

No, it is not correct.

The sort control is cumulative. Positions 1 thru 3 are the "major" sort field and positions 9 thru 11 are the "minor" sort field.

Suggest you generate more test data (that has something to do with your "sort keys") and run a more comprehensive test. As your data does not match your sort control, i suspect the result will not be very useful. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: SORT FIELDS=(1,3,CH,A,9,3,CH,A)

Postby BillyBoyo » Wed May 02, 2012 11:30 am

Also become awares of the "collating sequence", the order things are sorted in. Lower-case comes before upper-case. Try to find out and tell us why?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: SORT FIELDS=(1,3,CH,A,9,3,CH,A)

Postby NicC » Wed May 02, 2012 2:13 pm

Yopu have been told about using the code tags before. Please help us to help you by using them. Also help us to help you by posting in the correct section - you are asking about sort control cards which have NOTHING to do with JCL. You should post in the relevant sort section of the forum - DFSort if your sort product is from IBM (messages begin ICE) or SYNCSORT if you use SYNCSORT (messages begin WER). Due to the way your sort product is installed you may execute PGM=SORT which does not help you identify the product hence the need to look at your message identifiers or ask a colleague.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: SORT FIELDS=(1,3,CH,A,9,3,CH,A)

Postby dn2012 » Wed May 02, 2012 10:20 pm

I have coded now

Hello


//SYSIN    DD *
   SORT FIELDS=(1,3,CH,A,9,3,CH,A)
/*

What does it do?

FIRST KEY
1,3,CH,A - first key started at string/space 1 , its length is 3

SECOND KEY
9,3,CH,A - second key started at string/space 9, its length is 3

For example if we have following data

12345678901234567890
hello world hello
Adam Travel
My understanding is as: (for first key)
Position 1 and length is 3, Character , seq Ascending

First Key
Out put will be
12345678901234567890
Adam Travel
hello world hello

SECOND KEY
12345678901234567890
hello world hello
Adam Travel

Is it correct?

But did not understand output of SECOND KEY output (first example)

//SYSIN    DD *
   SORT FIELDS=(1,3,CH,A,[b]9,3,CH,A[/b])
/*



Thanks
dn2012
 
Posts: 114
Joined: Thu Feb 16, 2012 6:10 am
Has thanked: 0 time
Been thanked: 0 time

Re: SORT FIELDS=(1,3,CH,A,9,3,CH,A)

Postby BillyBoyo » Wed May 02, 2012 10:39 pm

Try it without "strings" of different lengths
222     999
111     999
222     111
111     888
111     777


Will give:

111     777
111     888
111     999
222     111
222     999


Records will be written with the value of the first field in order. Where there are duplicate keys for the first field, the order of records written depends on the value of the second field.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: SORT FIELDS=(1,3,CH,A,9,3,CH,A)

Postby Robert Sample » Wed May 02, 2012 10:41 pm

What does it do?
Ask a third time and this topic will be locked. You are being given good, valid answers but you keep posting the same question again.

For the SORT you provided, the 2 sample records you showed are useless. The SORT statement you provided will sort the file on columns 1 through 3. For those records where the first three bytes are identical -- and ONLY for those records -- will the second key be relevant. For records where the first 3 bytes are identical, those records will be sorted by the 3 bytes starting in byte 9. Use this to figure out the sequence these records will sort into:
AAABBBBBCCC
AAABBBBBAAA
AAABBBBBXXX
CCCAAAAABBB
AAACCCCCYYY
Remember, this is the SORTIN, not the SORTOUT -- it's up to you to determine the SORTOUT.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: SORT FIELDS=(1,3,CH,A,9,3,CH,A)

Postby dick scherrer » Wed May 02, 2012 11:07 pm

Hello,

But did not understand output of SECOND KEY output (first example)
Where did you see "output of SECOND KEY"?

There will only be ONE output and the sequence of that output will be in the sequence you specify on the sort control statement(s).

As mentioned before - you need data that aligns with the sort control. Why did you not use the data provided in the sampe you found/used?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: SORT FIELDS=(1,3,CH,A,9,3,CH,A)

Postby dn2012 » Wed May 02, 2012 11:08 pm

Thanks Billy and all
dn2012
 
Posts: 114
Joined: Thu Feb 16, 2012 6:10 am
Has thanked: 0 time
Been thanked: 0 time


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post