IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Syncsort Seqnum + Count


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jackare

New User


Joined: 27 Aug 2008
Posts: 35
Location: Brazil

PostPosted: Wed Feb 08, 2012 3:36 am
Reply with quote

Hello folks!
I need some help here.

This is my SORTIN (File A)

Code:
00 000000000 HEADER                                 
01 000000001 08.01.2012 000000000000045             
01 000000002 12.11.2012 000000000000150             
01 000000003 15.12.2011 000000000000126             
01 000000004 01.01.2011 000000000000210             
99 999999999 TRAILER  000000004    000000000000531


And this is mu SORTIN (File B)
Code:

01 000000001 08.01.2011 000000000000150
01 000000002 23.11.2011 000000000000158
01 000000003 23.11.2011 000000000020005
01 000000004 23.11.2011 000000000100000
01 000000005 23.11.2011 000000000350000
01 000000006 23.11.2011 000000000012500


Both files have the same layout, but only "File A" have Header and Trailer


a) The layout of the first 13 characters for all types of records is the same:
(01,02,ch) --> Record type: 00 is Header, 01 is detail, 99 is Trailer
(03,01,ch) --> Filler (space)
(04,09,ch) --> Record sequence: 000000000 is Header, 999999999 is Trailer and 1 til 999999998 is reserved to record detail.
(13,01,ch) --> Filler (space)

b) Header
(14,09,ch) --> Header Text
(23,28,ch) --> Filler (spaces)

c) detail record
(14,10,ch) --> field detail 01 is a date format "DD.MM.YYYY"
(25,15,ch) --> field detail 02 contains a numeric val.

d) trailer
(14,09,ch) --> Trailer Text
(23,09,ch) --> Total detail records
(36,15,ch) --> Sum of field 02 of detail records

So I have to join these files with a "Record sequence" in sequence from 1 by 1, put in Trailer the correct "Total detail record" (COUNT) and correct
"Sum of field 02 of detail records" (SUM).

Like this:
Code:
00 000000000 HEADER
01 000000001 08.01.2011 000000000000150
01 000000002 08.01.2012 000000000000045
01 000000003 12.11.2012 000000000000150
01 000000004 23.11.2011 000000000000158
01 000000005 15.12.2011 000000000000126
01 000000006 23.11.2011 000000000020005
01 000000007 01.01.2011 000000000000210
01 000000008 23.11.2011 000000000100000
01 000000009 23.11.2011 000000000350000
01 000000010 23.11.2011 000000000012500
99 999999999 TRAILER  000000010    000000000483344


Thanks !
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 08, 2012 4:04 am
Reply with quote

What is the rule for producing the output in that order?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Wed Feb 08, 2012 4:32 am
Reply with quote

seems that the record are being alternated and resequenced


1 from f1 1
1 from f2 2
2 from f1 3
2 from f2 4
....
4 from f1 7
4 from f2 8
5 from f2 9

on the lest the input sequence number, on the right the new one

in the TS example the first two record are flipped
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Feb 08, 2012 4:45 am
Reply with quote

Hi,

until the TS decides how the order is achieved, here is a starting point for the DFSORT job

Code:
//STEP1    EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN01 DD *                                               
01 000000001 08.01.2011 000000000000150                       
01 000000002 23.11.2011 000000000000158                       
01 000000003 23.11.2011 000000000020005                       
01 000000004 23.11.2011 000000000100000                       
01 000000005 23.11.2011 000000000350000                       
01 000000006 23.11.2011 000000000012500                       
//SORTIN02 DD *                                               
00 000000000 HEADER                                           
01 000000001 08.01.2012 000000000000045                       
01 000000002 12.11.2012 000000000000150                       
01 000000003 15.12.2011 000000000000126                       
01 000000004 01.01.2011 000000000000210                       
99 999999999 TRAILER  000000004    000000000000531               
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                   
 MERGE FIELDS=(1,12,BI,A)                                         
 OUTREC IFTHEN=(WHEN=(01,2,ZD,EQ,1),OVERLAY=(4:SEQNUM,9,ZD))     
 OUTFIL IFTRAIL=(TRLID=(1,2,CH,EQ,C'99'),                         
 TRLUPD=(23:COUNT-1=(M11,LENGTH=9),                               
         36:TOTAL=(25,15,ZD,TO=ZD,LENGTH=15)))                   


Gerry
Back to top
View user's profile Send private message
jackare

New User


Joined: 27 Aug 2008
Posts: 35
Location: Brazil

PostPosted: Wed Feb 08, 2012 6:54 am
Reply with quote

Bill Woodger wrote:
What is the rule for producing the output in that order?

Bill,
There is no rules for sequence, but I need re sequence all of detail record using just one counter from 1 by 1. In my example I have 10 detail record, so the sequence starts in 1 and it goes to 10.
ok?
Back to top
View user's profile Send private message
jackare

New User


Joined: 27 Aug 2008
Posts: 35
Location: Brazil

PostPosted: Wed Feb 08, 2012 6:57 am
Reply with quote

gcicchet,
I will try this and I will post the sort's results.
Thanks a lot!
Back to top
View user's profile Send private message
jackare

New User


Joined: 27 Aug 2008
Posts: 35
Location: Brazil

PostPosted: Wed Feb 08, 2012 7:17 am
Reply with quote

Sorry guys, I forgot to say that goal is format a single file. In this file the details must have a unique sequential and sort key is "(01,2, ZD, A, 14.10, CH, A), then please correct my SORTOUT using this key.
Thanks!
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Feb 08, 2012 7:27 am
Reply with quote

Hi,

if 14,10,CH,A is a date, then it will not achieve the desired results.

You should use 20,4,CH,A,17,2,CH,A,14,2,CH,A

Try this
Code:
//STEP1    EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
01 000000001 08.01.2011 000000000000150                               
01 000000002 23.11.2011 000000000000158                               
01 000000003 23.11.2011 000000000020005                               
01 000000004 23.11.2011 000000000100000                               
01 000000005 23.11.2011 000000000350000                               
01 000000006 23.11.2011 000000000012500                               
//         DD *                                                       
00 000000000 HEADER                                                   
01 000000001 08.01.2012 000000000000045                               
01 000000002 12.11.2012 000000000000150                               
01 000000003 15.12.2011 000000000000126                               
01 000000004 01.01.2011 000000000000210                               
99 999999999 TRAILER  000000004    000000000000531                   
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
 SORT FIELDS=(01,2,ZD,A,20,4,CH,A,17,2,CH,A,14,2,CH,A)               
 OUTREC IFTHEN=(WHEN=(01,2,ZD,EQ,1),OVERLAY=(4:SEQNUM,9,ZD))         
 OUTFIL IFTRAIL=(TRLID=(1,2,CH,EQ,C'99'),                     
 TRLUPD=(23:COUNT-1=(M11,LENGTH=9),                           
         36:TOTAL=(25,15,ZD,TO=ZD,LENGTH=15)))                 



Gerry
Back to top
View user's profile Send private message
jackare

New User


Joined: 27 Aug 2008
Posts: 35
Location: Brazil

PostPosted: Wed Feb 08, 2012 4:20 pm
Reply with quote

gcicchet wrote:
Hi,

if 14,10,CH,A is a date, then it will not achieve the desired results.

You should use 20,4,CH,A,17,2,CH,A,14,2,CH,A

Try this
Code:
//STEP1    EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
01 000000001 08.01.2011 000000000000150                               
01 000000002 23.11.2011 000000000000158                               
01 000000003 23.11.2011 000000000020005                               
01 000000004 23.11.2011 000000000100000                               
01 000000005 23.11.2011 000000000350000                               
01 000000006 23.11.2011 000000000012500                               
//         DD *                                                       
00 000000000 HEADER                                                   
01 000000001 08.01.2012 000000000000045                               
01 000000002 12.11.2012 000000000000150                               
01 000000003 15.12.2011 000000000000126                               
01 000000004 01.01.2011 000000000000210                               
99 999999999 TRAILER  000000004    000000000000531                   
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
 SORT FIELDS=(01,2,ZD,A,20,4,CH,A,17,2,CH,A,14,2,CH,A)               
 OUTREC IFTHEN=(WHEN=(01,2,ZD,EQ,1),OVERLAY=(4:SEQNUM,9,ZD))         
 OUTFIL IFTRAIL=(TRLID=(1,2,CH,EQ,C'99'),                     
 TRLUPD=(23:COUNT-1=(M11,LENGTH=9),                           
         36:TOTAL=(25,15,ZD,TO=ZD,LENGTH=15)))                 



Gerry


gcicchet,
It's didn't run here

Code:
SYNCSORT FOR Z/OS  1.3.2.1N    U.S. PATENTS: 4210961, 5117495   (C) 200
                                                      z/OS   1.13.0   
   
SYSIN :                                                               
   SORT FIELDS=(01,2,ZD,A,20,4,CH,A,17,2,CH,A,14,2,CH,A)               
   OUTREC IFTHEN=(WHEN=(01,2,ZD,EQ,1),OVERLAY=(4:SEQNUM,9,ZD))         
   OUTFIL IFTRAIL=(TRLID=(1,2,CH,EQ,C'99'),                           
          *                                                           
   TRLUPD=(23:COUNT-1=(M11,LENGTH=9),                                 
           36:TOTAL=(25,15,ZD,TO=ZD,LENGTH=15)))                       
WER268A  OUTFIL STATEMENT  : SYNTAX ERROR                             
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                         
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                       

What's wrong?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 08, 2012 4:27 pm
Reply with quote

You have Synsort, not DFSORT. DFSORT supports IFTRAIL. Looks like Syncsort doesn't have IFTRAIL. Confirm/look for something similar by consulting your manuals.
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Thu Feb 09, 2012 1:17 am
Reply with quote

jackare,

try this code..

Code:

//STEP1    EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD *                                     
01 000000001 08.01.2011 000000000000150             
01 000000002 23.11.2011 000000000000158             
01 000000003 23.11.2011 000000000020005             
01 000000004 23.11.2011 000000000100000             
01 000000005 23.11.2011 000000000350000             
01 000000006 23.11.2011 000000000012500             
//         DD *                                     
00 000000000 HEADER                                 
01 000000001 08.01.2012 000000000000045             
01 000000002 12.11.2012 000000000000150             
01 000000003 15.12.2011 000000000000126             
01 000000004 01.01.2011 000000000000210             
99 999999999 TRAILER  000000004    000000000000531 
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                     
  OUTREC IFTHEN=(WHEN=(1,2,ZD,EQ,1),               
  OVERLAY=(4:SEQNUM,9,ZD,RESTART=(1,2),80:C'000000001'))         
 SORT FIELDS=(01,2,ZD,A,20,4,CH,A,17,2,CH,A,14,2,CH,A)           
 INCLUDE COND=(1,2,ZD,EQ,1)                                       
 OUTFIL REMOVECC,BUILD=(1,79),HEADER2=(C'00 000000000 HEADER'),   
 TRAILER2=(C'99 999999999 TRAILER  ',                             
 23:TOTAL=(80,9,ZD,EDIT=(TTTTTTTTT)),36:TOTAL=(25,15,ZD,         
                   EDIT=(TTTTTTTTTTTTTTT)))     


And output is -

Code:

00 000000000 HEADER                               
01 000000001 01.01.2011 000000000000210           
01 000000002 08.01.2011 000000000000150           
01 000000003 23.11.2011 000000000000158           
01 000000004 23.11.2011 000000000020005           
01 000000005 23.11.2011 000000000100000           
01 000000006 23.11.2011 000000000350000           
01 000000007 23.11.2011 000000000012500           
01 000000008 15.12.2011 000000000000126           
01 000000009 08.01.2012 000000000000045           
01 000000010 12.11.2012 000000000000150           
99 999999999 TRAILER  000000010    000000000483344


Thanks
-3nadh
Back to top
View user's profile Send private message
jackare

New User


Joined: 27 Aug 2008
Posts: 35
Location: Brazil

PostPosted: Thu Feb 09, 2012 1:45 am
Reply with quote

-3nadh,
Great tip! I did this and it works very well.

Good Job! Thanks
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Syncsort help SYNCSORT 3
No new posts Repeat n times by substuting SEQNUM i... DFSORT/ICETOOL 2
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts SYNCSORT-DB2 interface SYNCSORT 0
No new posts CA7 count with DATE variable CA Products 0
Search our Forums:

Back to Top