MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

'internal' sort in block of data
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
rover
Beginner


Joined: 15 May 2007
Posts: 9
Topics: 2

PostPosted: Wed May 16, 2007 2:32 pm    Post subject: 'internal' sort in block of data Reply with quote

Hi. I wonder if this complex (seems) sort is even possible with z/OS DFSORT v1r5 we have in our shop...

Input DS:

Code:
       ->   01 some data record    sort yes
       |    01 associated line
 block |    02 some data record
       |    02 associated line
  #1   |    04 sorted record#1     A
       |    04 associated data for record #1
       |    04 sorted record#2     C
       |    04 associated data for record #2
       |    04 sorted record#3     B
        ->  04 associated data for record #3
        ->  01 some data record    sort no
       |    01 associated line
 block |    02 some data record
       |    02 associated line
  #2   |    04 sorted record#1     C
       |    04 associated data for record #1
       |    04 sorted record#2     A
       |    04 associated data for record #2
       |    04 sorted record#3     B
        ->  04 associated data for record #3


Output DS:
Code:
 
        ->  01 some data record    sort yes
       |    01 associated line
 block |    02 some data record
       |    02 associated line
  #1   |    04 sorted record#1     A
       |    04 associated data for record #1
       |    04 sorted record#2     B
       |    04 associated data for record #2
       |    04 sorted record#3     C
        ->  04 associated data for record #3
        ->  01 some data record    sort no
       |    01 associated line
 block |    02 some data record
       |    02 associated line
  #2   |    04 sorted record#1     C
       |    04 associated data for record #1
       |    04 sorted record#2     A
       |    04 associated data for record #2
       |    04 sorted record#3     B
        ->  04 associated data for record #3


Sorting rules are:

a) only 04 records sorted
b) 04 records sorted only in a boundaries of 'home' block
c) the associated data should follow sorted 04 record
d) 04 records sorted only if 01 record contains sort 'indicator'

many thanks for help in advance.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed May 16, 2007 3:55 pm    Post subject: Reply with quote

Is the order of the record types in each block always 01, 02 and 04? If not, what are the variations?

Are there always two 01 record types at the start of every block? If not, what are the variations?

What is the RECFM and LRECL of the input file?

What is the starting position, length and format of the type indicator (01, etc)?

What are the actual values for the sort indicator - is it really 'sort yes' and 'sort no' or something else?

What is the starting position, length and format of the sort indicator?

How do you distinguish a sorted 04 record from an associated 04 record? Is there an indicator, or is every sorted 04 always followed by one associated 04, or what?

What is the starting position, length and format of the key in the sorted 04 record?
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rover
Beginner


Joined: 15 May 2007
Posts: 9
Topics: 2

PostPosted: Thu May 17, 2007 2:24 am    Post subject: Reply with quote

Quote:

Is the order of the record types in each block always 01, 02 and 04? If not, what are the variations?


The order can be 01-04 or 01-02-04, where 02 and 04 can be multiple, but only 04 should be sorted. Every record type has one (only one) associated (detail) record which starts with CR - this forms an 'indivisible' group.

Quote:

Are there always two 01 record types at the start of every block? If not, what are the variations?


I must admit that sample block in my first post is not accurate. Sorry.

It should be:

Code:

       ->   HEADER
       |    01 some data record    sort yes
       |    CR associated line
 block |    02 some data record
       |    CR associated line
  #1   |    02 some data record
       |    CR associated line
       |    04 sorted record#1     A
       |    CR associated data for record #1
       |    04 sorted record#2     C
       |    CR associated data for record #2
       |    04 sorted record#3     B
        ->  CR associated data for record #3
....


So, start of every block distinguished by keyword 'HEADER' which always starts in position 1 and followed by one group of 01 + CR records.

Quote:

What is the RECFM and LRECL of the input file?


RECFM = VB, LRECL = 1954

Quote:

What is the starting position, length and format of the type indicator (01, etc)?


starting position = 1, length = 2. Format: 0x, where x = 1, 2, 4.

Quote:

What are the actual values for the sort indicator - is it really 'sort yes' and 'sort no' or something else?

What is the starting position, length and format of the sort indicator?


Sort indicator is a 3-char string, starting position = 37, it does not have any format - the only exception is that it can not contain digits. The 04 recs should be sorted if the value in block's sort indicator is 'YCF' or 'ZAQ'.

Quote:

How do you distinguish a sorted 04 record from an associated 04 record? Is there an indicator, or is every sorted 04 always followed by one associated 04, or what?


04 record is always followed by one (only one) associated (detail) record, which starts with CR.

Quote:

What is the starting position, length and format of the key in the sorted 04 record?


The starting position of the key is 120, lenght is up to 10 chars and does not follow any format, i. e. can be a varying string of any characters.
Back to top
View user's profile Send private message
rover
Beginner


Joined: 15 May 2007
Posts: 9
Topics: 2

PostPosted: Wed May 30, 2007 9:26 am    Post subject: Reply with quote

Frank, sorry for impatience... Does my post above contain enought details on problem we have? Is there any way to solve it with DFSORT? Thanks.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed May 30, 2007 11:18 am    Post subject: Reply with quote

There probably is a way to do it with DFSORT, but I just got back from vacation and I'm really swamped right now, so I can't take the time to figure it out. Sorry.

Maybe Kolusu or Alain has time to work it out?
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Wed May 30, 2007 11:31 am    Post subject: Reply with quote

I hope I will have enough time between 2 baby's bottles to post something this night.

Alain
Back to top
View user's profile Send private message
krisprems
Beginner


Joined: 13 Dec 2006
Posts: 101
Topics: 4
Location: india

PostPosted: Wed May 30, 2007 11:52 am    Post subject: Reply with quote

check this link => http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
for the topic => "Sort groups of records"
_________________
cHEERs
krisprems
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed May 30, 2007 12:45 pm    Post subject: Reply with quote

Quote:

check this link => http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
for the topic => "Sort groups of records"

krisprems,

Try to understand the question. The above trick does NOT work

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed May 30, 2007 1:26 pm    Post subject: Reply with quote

Quote:

04 record is always followed by one (only one) associated (detail) record, which starts with CR.


rover,

Is there anything to distinguish these 'CR' records (i.e 1 CR record immediately after the 04 record) from the other 'CR' records within the same group?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rover
Beginner


Joined: 15 May 2007
Posts: 9
Topics: 2

PostPosted: Thu May 31, 2007 2:11 am    Post subject: Reply with quote

kolusu, yes, your suggestion is quite correct - every CR (min 1: max 1) record 'belongs' to preceding 04 (min 1: max 1) record and this is a way to distinguish them.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jun 01, 2007 12:17 pm    Post subject: Reply with quote

rover,

Yikes I hate VB files. Solving it and preparing the test data sucked. Try this job.


Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN       DD DSN=YOUR INPUT VB 1954 LRECL FILE,
//            DISP=SHR
//T1       DD DSN=&&T1,DISP=(,CATLG),SPACE=(CYL,(x,y),RLSE)
//T2       DD DSN=&&T2,DISP=(,CATLG),SPACE=(CYL,(x,y),RLSE)
//OUT      DD SYSOUT=*
//TOOLIN   DD *
  SPLICE FROM(IN) TO(T1) ON(1973,08,CH) WITH(1,1973) WITHALL -
  USING(CTL1) KEEPBASE
  SPLICE FROM(T1) TO(T2) ON(1973,19,CH) WITH(1,1962) -
  KEEPBASE WITHALL KEEPNODUPS
  SORT FROM(T2) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
  SORT FIELDS=(1973,8,CH,A,
               1981,3,CH,D)

  INREC IFTHEN=(WHEN=INIT,
       OVERLAY=(1963:10X,
                1973:SEQNUM,8,ZD,
                1981:3X)),
        IFTHEN=(WHEN=(05,06,CH,NE,C'HEADER'),
       OVERLAY=(1955:SEQNUM,8,ZD,
                1973:1973,8,ZD,SUB,1955,8,ZD,M11,LENGTH=8),HIT=NEXT),
        IFTHEN=(WHEN=(05,02,CH,EQ,C'01',AND,
                      41,03,SS,EQ,C'YCF,ZAQ'),
       OVERLAY=(1981:41,3)),
        IFTHEN=(WHEN=(05,02,CH,EQ,C'04'),
       OVERLAY=(1963:124,10)),
        IFTHEN=(WHEN=NONE,
       OVERLAY=(1973:SEQNUM,8,ZD))

  OUTFIL FNAMES=T1,
         IFTHEN=(WHEN=INIT,OVERLAY=(1984:SEQNUM,8,ZD)),
         IFTHEN=(WHEN=(05,02,CH,EQ,C'04'),
                 OVERLAY=(1984:SEQNUM,8,ZD)),
          IFTHEN=(WHEN=NONE,
                  OVERLAY=(1992:SEQNUM,8,ZD,
                           1984:1984,8,ZD,SUB,1992,8,ZD,M11,LENGTH=8))
//CTL2CNTL DD *
  OMIT COND=(5,6,CH,EQ,C'HEADER')
  OPTION EQUALS
  SORT FIELDS=(1973,08,CH,A,
               1963,10,CH,A,
               1984,08,CH,A)
  INREC IFTHEN=(WHEN=(1981,03,SS,NE,C'YCF,ZAQ'),
       OVERLAY=(1963:10X))
  OUTFIL FNAMES=OUT,REMOVECC,VLTRIM=C' ',
  IFOUTLEN=1954,IFTHEN=(WHEN=INIT,BUILD=(1,4,5)),
  SECTIONS=(1973,8,
  HEADER3=('HEADER'))
/*


Hope this helps...

Cheers

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Fri Jun 01, 2007 4:05 pm    Post subject: Reply with quote

Rover,

I am elaborating a much more indigest solution but I can't post it yet. I have interpreted your need a much 'more complex' way.

I would be glad Kolusu's solution meets your need !

Alain
Back to top
View user's profile Send private message
rover
Beginner


Joined: 15 May 2007
Posts: 9
Topics: 2

PostPosted: Tue Jun 05, 2007 2:29 pm    Post subject: Reply with quote

kolusu,

solution works great - it's a kind of magic Smile

got some concerns however:

1.
Code:
IFTHEN=(WHEN=(05,02,CH,EQ,C'04'),
       OVERLAY=(1963:124,10))

does not 'extract' chars from 1963... I was able to 'see' that field and sort when 1963 changed to 1940 and WITH(1,1962) to WITH(1,1939)

2. (sigh) sorry, I did not tell that first record contains some data after 'HEADER' indicator. This record should be moved to output as is instead of hardcoding 'HEADER'. I really hope that this missing detail would not ruin the solution...
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Jun 05, 2007 2:35 pm    Post subject: Reply with quote

Quote:

got some concerns however:

1. Code:
IFTHEN=(WHEN=(05,02,CH,EQ,C'04'),
OVERLAY=(1963:124,10))

does not 'extract' chars from 1963... I was able to 'see' that field and sort when 1963 changed to 1940 and WITH(1,1962) to WITH(1,1939)


Hmm that is not what that statement does.

The above statement does this

1. when the first 2 bytes = '04' , it will copy the contents from pos 124 for 10 bytes and palce it in byte 1963 for 10 bytes

Quote:

2. (sigh) sorry, I did not tell that first record contains some data after 'HEADER' indicator. This record should be moved to output as is instead of hardcoding 'HEADER'. I really hope that this missing detail would not ruin the solution...


lemme see , most probably we can do it in the same pass, however it may require another pass of data
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rover
Beginner


Joined: 15 May 2007
Posts: 9
Topics: 2

PostPosted: Tue Jun 05, 2007 3:16 pm    Post subject: Reply with quote

1. yes, got the idea that OVERLAY=(1963:124,10)) will copy the content to new position, but in my case it does not happen. Will review my jcl more carefully...

2. The input ds usually is about <200 records, so another pass of data is ok, I believe.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group