Page 1 of 1

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

PostPosted: Wed May 02, 2012 5:11 am
by dn2012
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

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

PostPosted: Wed May 02, 2012 7:26 am
by dick scherrer
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. . .

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

PostPosted: Wed May 02, 2012 11:30 am
by BillyBoyo
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?

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

PostPosted: Wed May 02, 2012 2:13 pm
by NicC
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.

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

PostPosted: Wed May 02, 2012 10:20 pm
by dn2012
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

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

PostPosted: Wed May 02, 2012 10:39 pm
by BillyBoyo
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.

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

PostPosted: Wed May 02, 2012 10:41 pm
by Robert Sample
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.

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

PostPosted: Wed May 02, 2012 11:07 pm
by dick scherrer
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?

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

PostPosted: Wed May 02, 2012 11:08 pm
by dn2012
Thanks Billy and all