adding a seq number to a group of recs with DFSORT



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

adding a seq number to a group of recs with DFSORT

Postby dgrimsley » Fri Jun 25, 2010 1:31 am

I am new to DFSORT but I have used SYNCSORT for several years.
I have groups of records that I need to add a value to each record in a group then +1 to the next set of records.
The records are all different lengths with differnet data but I have included the fields at the beginning which are in the same positions.

Here is an example of my records:
here is where I need to sequence the records the same number for all records in this group
------------------------------vvvvvv------
000012151782010-06-265000001  10
000012151782010-06-075000001  20
000012151782010-06-265000001  30
000012151782010-06-265000002  30
000012151782010-06-075000001  40
000012151782010-06-075000001  50
000012151782010-06-075000002  20
000012151782010-06-265000003  30
000012151782010-06-265000004  30
000012151782010-06-075000002  40
000012151782010-06-075000002  50

000012194532010-06-265000002  10
000012194532010-06-075000003  20
000012194532010-06-265000005  30
000012194532010-06-265000006  30
000012194532010-06-075000003  40
000012194532010-06-075000003  50

Here is the code I used until I found out not all groups will have a '10' record. I knew there was going to be a problem having two '30' records in a group. I am also changing the dates on certain records. The positions are correct they may not match the included records above since I did not include the entire record(s).

OPTION COPY                                             
  INREC IFTHEN=(WHEN=(54,2,CH,EQ,C'10'),                 
             OVERLAY=(239:C'2010-06-26',                 
                      20:C'2010-06-26',71:C'2010-06-26',
                      31:SEQNUM,6,ZD,START=1)),         
        IFTHEN=(WHEN=(54,2,CH,EQ,C'20'),                 
             OVERLAY=(31:SEQNUM,6,ZD)),                 
        IFTHEN=(WHEN=(54,2,CH,EQ,C'30'),                 
             OVERLAY=(125:C'2010-06-26',                 
                      20:C'2010-06-26',71:C'2010-06-26',
                      31:SEQNUM,6,ZD)),                 
        IFTHEN=(WHEN=(54,2,CH,EQ,C'40'),                 
             OVERLAY=(31:SEQNUM,6,ZD)),                 
        IFTHEN=(WHEN=(54,2,CH,EQ,C'50'),                 
             OVERLAY=(31:SEQNUM,6,ZD)),                 
        IFTHEN=(WHEN=(54,2,CH,NE,C'99'),                 
             OVERLAY=(20:C'2010-06-26',71:C'2010-06-26'))


I would appreciate any help.

Thanks You.
dgrimsley
 
Posts: 7
Joined: Fri Jun 25, 2010 1:10 am
Has thanked: 0 time
Been thanked: 0 time

Re: adding a seq number to a group of recs with DFSORT

 

Re: adding a seq number to a group of recs with DFSORT

Postby dick scherrer » Fri Jun 25, 2010 1:38 am

Hello and welcome to the forum,

It will help if you show the output you want from the sample input.

Notice that your data and sort control statements have been "Code'd" for alignment and readability.

Also, please mention the recfm and lrecl of the files.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: adding a seq number to a group of recs with DFSORT

Postby Frank Yaeger » Fri Jun 25, 2010 1:44 am

It's not clear from your description what exactly you want to do. I feel like I came in in the middle.

I have groups of records


What defines a group? Which fields are you looking at to determine if a record falls into a group?

I need to add a value to each record in a group then +1 to the next set of records.


Where do you want to add this value?

Are the example records you show the input records or the expected output records?

You need to do a better job of describing exactly what is you want to do before anyone can help you.

Please show an example of the records in your input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input file.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: adding a seq number to a group of recs with DFSORT

Postby dgrimsley » Fri Jun 25, 2010 2:03 am

The records are VB 450 bytes long.

The sequence number needs to go where the xxxxx is (this is position 31 for a length of 6 on the file) on the input file there are currently random numbers in the field and it is numeric. The first 10 bytes of the record is a key along with the '10' in position 54. Each time a '10' is in position 54 that starts a new group of reocrds and they will have the same data in the first 10 bytes of each record. The next '10' records begins a new group.

000012151782010-06-265xxxxxx 10
000012151782010-06-075xxxxxx 20
000012151782010-06-265xxxxxx 30
000012151782010-06-265xxxxxx 30
000012151782010-06-075xxxxxx 40
000012151782010-06-075xxxxxx 50
000012151782010-06-075xxxxxx 20
000012151782010-06-265xxxxxx 30
000012151782010-06-265xxxxxx 30
000012151782010-06-075xxxxxx 40
000012151782010-06-075xxxxxx 50

000012194532010-06-265xxxxxx 10
000012194532010-06-075xxxxxx 20
000012194532010-06-265xxxxxx 30
000012194532010-06-265xxxxxx 30
000012194532010-06-075xxxxxx 40
000012194532010-06-075xxxxxx 50



Here is what I need the output to look like:
000012151782010-06-265000001 10
000012151782010-06-075000001 20
000012151782010-06-265000001 30
000012151782010-06-265000001 30
000012151782010-06-075000001 40
000012151782010-06-075000001 50
000012151782010-06-075000001 20
000012151782010-06-265000001 30
000012151782010-06-265000001 30
000012151782010-06-075000001 40
000012151782010-06-075000001 50

000012194532010-06-265000002 10
000012194532010-06-075000002 20
000012194532010-06-265000002 30
000012194532010-06-265000002 30
000012194532010-06-075000002 40
000012194532010-06-075000002 50

I hope this explains what I am trying to do a little better.
dgrimsley
 
Posts: 7
Joined: Fri Jun 25, 2010 1:10 am
Has thanked: 0 time
Been thanked: 0 time

Re: adding a seq number to a group of recs with DFSORT

Postby Frank Yaeger » Fri Jun 25, 2010 2:22 am

Assuming your starting positions include the RDW in positions 1-4, you can use a DFSORT job like the following to do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (VB/450)
//SORTOUT DD DSN=...  output file (VB/450)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(54,2,CH,EQ,C'10'),
    PUSH=(31:ID=6))
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: adding a seq number to a group of recs with DFSORT

Postby dgrimsley » Fri Jun 25, 2010 5:16 pm

Frank thank you very much. This worked great.
dgrimsley
 
Posts: 7
Joined: Fri Jun 25, 2010 1:10 am
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post