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 

SEQNUM value is not coming correctly

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
rama krishna reddy
Beginner


Joined: 18 Sep 2006
Posts: 31
Topics: 13
Location: Hyderabad

PostPosted: Tue Jan 13, 2009 10:13 am    Post subject: SEQNUM value is not coming correctly Reply with quote

Hi

I Need to print a report using the below input file ,when i try to use SEQNUM for the count iam not getting correct result.

Iam trying to do group by for first 12 char of teh input file

i need to display the count of the record with first 12 char having same data


Can any one help me regarding below problem.


JOB:
Code:

//STEP3    EXEC  PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                       
//SORTIN  DD DSN=TEST.CLMFCATS.RK.INPUT,                     
//           DISP=SHR                                       
//SORTOUT  DD DSN=TEST.CLMFCATS.RK.OUTPUT1,                 
//            DISP=(NEW,CATLG,KEEP),                         
//            DATACLAS=SMSALLOC                             
//SYSIN     DD *                                             
 INREC FIELDS=(1,80,SEQNUM,3,ZD)  * INCLUDE COUNTER         
 SORT  FIELDS=(1,12,CH,A)                                   
 SUM   FIELDS=(81,3,ZD)             * SUMMARIZE IN COUNTER   
 OUTREC FIELDS=(1,80,X,81,3)                                 
/*                                                           




INPUT:
Code:

f01000256895smith country store
f01000256895smith country store
f01000256895smith country store
f01000256895smith country store
f01000256895smith country store
f01000256895smith country store
f01000256895smith country store
f01000256895smith country store
f01000256895smith country store
f01000256895smith country store
f01000258647jemes tailor outlet
f01000258647jemes tailor outlet
f01000258647jemes tailor outlet
f01000258647jemes tailor outlet
f01000258647jemes tailor outlet
f01000258647jemes tailor outlet
f01000315258williams penn supply
f02000315258williams penn supply
f02000315258williams penn supply   
f02000315258williams penn supply   
f02000315258williams penn supply   
f02000315258williams penn supply   
f02000315258williams penn supply   
f03000312856santorinis trattoria   
f03000312856santorinis trattoria   



ACTUALT OUTPUT:
Code:

f01000256895smith country store        055
f01000258647jemes tailor outlet        081
f01000315258williams penn supply       017
f02000315258williams penn supply       123
f03000312856santorinis trattoria       049


EXPECTED OUTPUT:
Code:

f01000256895smith country store       10
f01000258647jemes tailor outlet        6
f01000315258williams penn supply       1
f02000315258williams penn supply       6
f03000312856santorinis trattoria       2
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jan 13, 2009 11:12 am    Post subject: Reply with quote

rama krishna reddy,

Your approach itself is wrong. You want to count the no: of occurrences for each key. SEQNUM specifies a ascending sequence number for each record. so the first record will have a number 1 and the second will have a number 2 and so on. Since you created only a 3 byte sequence and summing on it an overflow condition occurred. ie the summation exceed 1000 and you only have 3 bytes to store that value.

The simplest way to do it is using SECTIONS and TRAILER3

Code:

//STEP3    EXEC  PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                       
//SORTIN  DD DSN=TEST.CLMFCATS.RK.INPUT,                     
//           DISP=SHR                                       
//SORTOUT  DD DSN=TEST.CLMFCATS.RK.OUTPUT1,                 
//            DISP=(NEW,CATLG,KEEP),                         
//            DATACLAS=SMSALLOC   
//SYSIN    DD *                         
  SORT FIELDS=(1,12,CH,A)               
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X), 
  SECTIONS=(1,12,                       
  TRAILER3=(1,35,COUNT))                 
/*                                       

If you want to use the counter and sum then use the following sysin control cards

Code:

//SYSIN    DD *                         
  INREC OVERLAY=(81:C'00000001')         
  SORT FIELDS=(1,12,CH,A)               
  SUM FIELDS=(81,8,ZD)                   
  OUTREC BUILD=(1,35,81,8,ZD)           
/*                                       


Hope this helps...

Cheers
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 10 Jan 2007
Posts: 123
Topics: 0

PostPosted: Tue Jan 13, 2009 3:11 pm    Post subject: Reply with quote

Hello rama krishna reddy,

If you are running SyncSort for z/OS 1.3, then the following code will produce your desired output as well:
Code:
//SYSIN DD *                                     
   INREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,12))
   SORT FIELDS=(1,12,CH,A)                       
   DUPKEYS MAX=(81,8,ZD)                         
/* 

Best Regards,
_________________
Alissa Margulies
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
rama krishna reddy
Beginner


Joined: 18 Sep 2006
Posts: 31
Topics: 13
Location: Hyderabad

PostPosted: Wed Jan 14, 2009 1:51 am    Post subject: Reply with quote

Hi Kolusu


Thanks for the solution ,it is working fine .

I have used below JOB:
Code:

//STEP01   EXEC  PGM=SORT                 
//SYSOUT   DD SYSOUT=*                     
//SORTIN  DD DSN=TEST.CLMFCATS.RK.INPUT,   
//           DISP=SHR                     
//SORTOUT  DD DSN=TEST.CLMFCATS.RK.OUTPUT1,
//            DISP=(NEW,CATLG,KEEP),       
//            DATACLAS=SMSALLOC           
//SYSIN    DD *                           
  SORT FIELDS=(1,12,CH,A)                 
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),   
  SECTIONS=(1,12,                         
  TRAILER3=(1,35,COUNT))                   
/*                                         
//*                                       
//STEP02 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=TEST.CLMFCATS.RK.OUTPUT1,DISP=SHR     
//SORTOUT  DD DSN=TEST.CLMFCATS.RK.OUTPUT5,             
//            DISP=(NEW,CATLG,KEEP),                     
//            DATACLAS=SMSALLOC                         
//SYSIN    DD *                                         
  SORT FIELDS=(1,1,CH,A,2,2,CH,A)                       
  OUTFIL REMOVECC,                                       
    SECTIONS=(1,3,                                       
      TRAILER3=(C'TOTAL                                 
        TOT=(40,4,ZD,TO=ZD,LENGTH=5)))                   
/*                                                       
//* 


OUT PUT :
Code:

f01000256895smith country store          10       
f01000258647jemes tailor outlet           6       
f01000315258williams penn supply          1       
TOTAL                                 00017   
f02000315258williams penn supply          6       
TOTAL                                 00006   
f03000312856santorinis trattoria          2       
TOTAL                                 00002   
s01000214558berkely baits                 7       
TOTAL                                 00007   
s02000265995federal ammunition           11       
TOTAL                                 00011   
s03000312856federal ammunition            6       
TOTAL                                 00006   

---------------------
I want to find the sum for the record having same value in 2,2 position

Expected Output:

Code:

f01000256895smith country store         10       
f01000258647jemes tailor outlet          6       
f01000315258williams penn supply         1       
TOTAL                                00017   
f02000315258williams penn supply         6       
TOTAL                                00006   
f03000312856santorinis trattoria         2       
TOTAL                                00002   
s01000214558berkely baits                7       
TOTAL                                00007   
s02000265995federal ammunition          11       
TOTAL                                00011   
s03000312856federal ammunition           6       
TOTAL                                00006   


TOTAL PLANS   

well-1             24   (i.e   17 for f01   + 7 for s01)
well-2             17   (i.e  6 for f02 +   11 for s02 )
well-3              8   (i.e 2 for f03 + 6 for s03)

I need report link above

In case if i use sort fields on 2,2 char then s01 records will come after f01 but i want all f records first and then s records

and total count for records with
Code:
01
02
03
04


in the 2,2 position


Iam trying to find the solution Can You please help me regarding the same.

Thanks

Rama krishna reddy
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Jan 14, 2009 11:39 am    Post subject: Reply with quote

rama krishna reddy,

Do you always have only 3 Plans ? or does it differ?

Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 18 Sep 2006
Posts: 31
Topics: 13
Location: Hyderabad

PostPosted: Wed Jan 14, 2009 9:33 pm    Post subject: Reply with quote

Hi Kolusu,

As for the current requirement i will have maximum 6 plans


Thanks

Rama krishna reddy
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jan 15, 2009 11:39 am    Post subject: Reply with quote

rama krishna reddy,

Code:

//STEP0100 EXEC PGM=ICEMAN             
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD *                       
F01000256895SMITH COUNTRY STORE       
F01000256895SMITH COUNTRY STORE       
F01000256895SMITH COUNTRY STORE       
F01000256895SMITH COUNTRY STORE       
F01000256895SMITH COUNTRY STORE       
F01000256895SMITH COUNTRY STORE       
F01000256895SMITH COUNTRY STORE       
F01000256895SMITH COUNTRY STORE       
F01000256895SMITH COUNTRY STORE       
F01000256895SMITH COUNTRY STORE       
F01000258647JEMES TAILOR OUTLET       
F01000258647JEMES TAILOR OUTLET       
F01000258647JEMES TAILOR OUTLET       
F01000258647JEMES TAILOR OUTLET       
F01000258647JEMES TAILOR OUTLET       
F01000258647JEMES TAILOR OUTLET       
F01000315258WILLIAMS PENN SUPPLY       
F02000315258WILLIAMS PENN SUPPLY       
F02000315258WILLIAMS PENN SUPPLY       
F02000315258WILLIAMS PENN SUPPLY       
F02000315258WILLIAMS PENN SUPPLY       
F02000315258WILLIAMS PENN SUPPLY       
F02000315258WILLIAMS PENN SUPPLY       
F03000312856SANTORINIS TRATTORIA       
S01000256895BARABARA MACDONALD         
S01000256895BARABARA MACDONALD         
S01000256895BARABARA MACDONALD         
S01000256895BARABARA MACDONALD         
S01000256895BARABARA MACDONALD         
S01000256895BARABARA MACDONALD         
S01000256895BARABARA MACDONALD         
S01000258647 RAMA KRISHNA REDDY       
S01000258647 RAMA KRISHNA REDDY       
S01000258647 RAMA KRISHNA REDDY       
S01000258647 RAMA KRISHNA REDDY       
S01000258647 RAMA KRISHNA REDDY       
S01000315258 HARDEWARE STORE         
S01000315258 HARDEWARE STORE         
S01000315258 HARDEWARE STORE         
S03000312856 PAINT STORE             
S03000312856 PAINT STORE             
S03000312856 PAINT STORE             
//SORTOUT  DD SYSOUT=*               
//SYSIN    DD *                                       
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,35,7C'0',C'1'))     
  SORT FIELDS=(1,12,CH,A)                             
  SUM FIELDS=(36,8,ZD)                                 

  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,43,24C'0')),       
  IFTHEN=(WHEN=(2,2,CH,EQ,C'01'),OVERLAY=(44:36,8)),   
  IFTHEN=(WHEN=(2,2,CH,EQ,C'02'),OVERLAY=(52:36,8)),   
  IFTHEN=(WHEN=(2,2,CH,EQ,C'03'),OVERLAY=(60:36,8))   

  OUTFIL REMOVECC,BUILD=(1,35,36,8,ZD),               
  SECTIONS=(1,3,                                       
  TRAILER3=('TOTAL: ',10:TOT=(36,8,ZD,M10,LENGTH=8))),
  TRAILER1=(/,'TOTAL PLANS ',/,                       
            'WELL-1',10:TOT=(44,8,ZD,M10,LENGTH=8),/, 
            'WELL-2',10:TOT=(52,8,ZD,M10,LENGTH=8),/, 
            'WELL-3',10:TOT=(60,8,ZD,M10,LENGTH=8))   
/*



The output of this job is

Code:

F01000256895SMITH COUNTRY STORE          10   
F01000258647JEMES TAILOR OUTLET           6   
F01000315258WILLIAMS PENN SUPPLY          1   
TOTAL:         17                             
F02000315258WILLIAMS PENN SUPPLY          6   
TOTAL:          6                             
F03000312856SANTORINIS TRATTORIA          1   
TOTAL:          1                             
S01000256895BARABARA MACDONALD            7   
S01000258647 RAMA KRISHNA REDDY           5   
S01000315258 HARDEWARE STORE              3   
TOTAL:         15                             
S03000312856 PAINT STORE                  3   
TOTAL:          3                             
                                               
TOTAL PLANS                                   
WELL-1         32                             
WELL-2          6                             
WELL-3          4                             


Hope this helps...

Cheers
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
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