Sequence Number Problem



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

Sequence Number Problem

Postby Mayank[123] » Thu Oct 11, 2012 12:03 pm

We have a file with key fields data. Data is sorted first, based on the value.

Now my requirement is like below:

a) Whenever 'data' changed from its previous value count will remain to 1

b) if counting of iterations of data field becomes as 50 then it will increase the count value by one.

Please see below example

Line          Data                   Count
1              ABC       1
2          ABC      1
3           ABC      1
4           DEf      1   
5           GHI      1
6              GHI                   1


conitinue with the same 'value' till 50 record not comes

55            GHI      2
56            GHI      2
57            GHI      2
58            JKL      1
59            JKL       1
60            JKL      1


conitinue with same 'value' till 50 record not comes

107           JKL      1
108           JKL      2
109           JKL      2
110           JKL      2     


conitinue with same 'value' till 50 record not comes

157           JKL      2     
158            JKL      3
160           JKL      3


Code'd and got rid of the "worst" of the misalignments
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sequence Number Problem

 

Re: Sequence Number Problem

Postby BillyBoyo » Thu Oct 11, 2012 1:50 pm

After reading for a third time:

You want "keys" to have numbers in groups of 50. 1 for the first 50 of the key, 2 for the second 50, 3 for the third fifty?

Can you run the following step and paste the sysout here. That will show us the level of your sort product so we know which functions you're able to use.

//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DUMMY
//SYSIN   DD   *
  OPTION COPY
/*
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Sequence Number Problem

Postby Mayank[123] » Thu Oct 11, 2012 2:30 pm

Yes, You are right basically this sequence will remain same till the record count became 50 and if it is 51 then it will increased by 1and when the value of key will be change it(count) again starts(initialize) with 1.
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sequence Number Problem

Postby Mayank[123] » Thu Oct 11, 2012 2:43 pm

Sysout look like -->

ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
ICE751I 0 C5-K62149 C6-K90026 C7-K58148 C8-K67572 E9-K60824 C9-BASE E5-K70685 E7-K70685
ICE143I 0 BLOCKSET COPY TECHNIQUE SELECTED
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AND MORE
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 04:45 ON THU OCT 11, 2012 -
OPTION COPY
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sequence Number Problem

Postby BillyBoyo » Thu Oct 11, 2012 3:12 pm

OK.. If you look at the ICE201I message, you'll see the H which means you're fairly current, so no problems there.

A couple of options are SEQNUM with RESTART and IFTHEN=(WHEN=GROUP with KEYBEGIN.

You'd use either of those to generate a sequence number within the group specified by your key.

Now, you don't just want that, you want a particular sequence number that is the same for each fifty records of the key and then increments.

This can be achieved, amongst other ways, by using DIV (divide) on the generated sequence number. If you DIV the generated sequence by 50, for the first 50 the answer will be 0, for the next fifty the answer will be 1, for the third fifty the answer will be 2, etc.

OK, that is not the answer you want, it is "one off". So, you ADD 1 after doing the DIV. That should give you what you want.

I think the SEQNUM with RESTART is the simplest of the two for your purpose.

I don't know if your file is fixed-length records or variable. I'll assume fixed. You'd need to append a sequence number to each record. The use DIV and ADD on the sequence number to get your result and then drop the sequence number.

Have a go yourself. DFSORT provides a very good "Getting Started" as well as the main "Application Programming Guide". You can also google (SORT SEQNUM RESTART for instance) will find you more examples.

If you have problems or questions, let us know.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Sequence Number Problem

Postby Mayank[123] » Thu Oct 11, 2012 3:48 pm

Thanks a lot Billy !!
My problem is resolved...
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sequence Number Problem

Postby BillyBoyo » Thu Oct 11, 2012 3:53 pm

No problem. Thanks for letting us know. Quick work :-)

If you can post your solution it may help others with a similar problem.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Sequence Number Problem

Postby Mayank[123] » Thu Oct 11, 2012 3:58 pm

 SORT FIELDS=COPY
 OUTREC IFTHEN=(WHEN=INIT,
       OVERLAY=(10:SEQNUM,5,FS,RESTART=(1,3))),
       IFTHEN=(WHEN=(10,5,FS,GT,+1),
       OVERLAY=(10:(10,5,FS,DIV,+51),ADD,+1,TO=FS,LENGTH=5))


Code'd
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sequence Number Problem

Postby BillyBoyo » Thu Oct 11, 2012 4:27 pm

Thanks. Just a couple of things. No need to use FS (as you have no sign). You can use ZD instead throughout.

There is no need for the GT,+1 condition, you can use a second WHEN=INIT. It would not matter that the first sequence number is one, and then getting set to one through the code.

Why DIV by 51? The zero "gets in the way" in that you don't have one. But, you can:
 OVERLAY=(10:SEQNUM,5,ZD,START=0,RESTART=(1,3))),


And then DIV by 50.

You have extended the record, but not returned it to its original size.

You can do it with one IFTHEN=(WHEN=INIT and extend the OVERLAY. Here's what I did, assuming an FB 80 input:

//DOIN11S  EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
                                             
  INREC IFOUTLEN=80,
        IFTHEN=(WHEN=INIT,
                  OVERLAY=(81:SEQNUM,7,ZD,
                               START=0,
                               RESTART=(1,3),
                           5:81,7,ZD,
                              DIV,+11,
                              ADD,+1,
                              TO=ZD,LENGTH=1))
//SORTIN   DD *


I chose 11 for the change of the sequence number desired, as it is much easier to check than with 50 :-)

You show in your example a generated sequence number of length 5 and the same length for your modified sequence number. That means you could do it without having to extend the record.

With mine it would be:

//DOIN11S  EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
                                             
  INREC IFTHEN=(WHEN=INIT,
                  OVERLAY=(5:SEQNUM,7,ZD,
                               START=0,
                               RESTART=(1,3),
                           5:5,7,ZD,
                              DIV,+11,
                              ADD,+1,
                              TO=ZD,LENGTH=7))
//SORTIN   DD *


Kolusu will be along later today, and might have some other suggestions :-)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Sequence Number Problem

Postby Mayank[123] » Thu Oct 11, 2012 4:44 pm

Yes,That's what i call the best result..Thanks again Billy.... :)
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post