|
View previous topic :: View next topic
|
| Author |
Message |
jackare
New User

Joined: 27 Aug 2008 Posts: 35 Location: Brazil
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| What is the rule for producing the output in that order? |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10900 Location: italy
|
|
|
|
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 |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
 |
jackare
New User

Joined: 27 Aug 2008 Posts: 35 Location: Brazil
|
|
|
|
| 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 |
|
 |
jackare
New User

Joined: 27 Aug 2008 Posts: 35 Location: Brazil
|
|
|
|
gcicchet,
I will try this and I will post the sort's results.
Thanks a lot! |
|
| Back to top |
|
 |
jackare
New User

Joined: 27 Aug 2008 Posts: 35 Location: Brazil
|
|
|
|
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 |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
 |
jackare
New User

Joined: 27 Aug 2008 Posts: 35 Location: Brazil
|
|
|
|
| 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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| 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 |
|
 |
bodatrinadh
Active User

Joined: 05 Jan 2007 Posts: 101 Location: chennai (India)
|
|
|
|
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 |
|
 |
jackare
New User

Joined: 27 Aug 2008 Posts: 35 Location: Brazil
|
|
|
|
-3nadh,
Great tip! I did this and it works very well.
Good Job! Thanks |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|