Hi, friends, I have a report with layout like this:
-----------------------------------------
Date: 07 01 2007 (MM DD YYYY)
record details 1
record details 2
Date: 06 01 2007
record details 1
record details 2
record details 3
Date: 05 01 2007
record details 4
record details 5
record details 6
record details 7
....
-----------------------------------------
How i can split this report into different reports by Month?
coria
Here goes the code for you with DFSORT/ICETOOL solution. If you had shown the o/p, in what way you needed, it would be better.
Anyways, here i have considered the DATE record as the header and extracted the records coming under them as one set of records and written to the o/p.
OUT1, OUT2 and OUT3 are the 3 o/p reports.
Code:
//*******************************************************
//STEP001 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
DATE: 07 01 2007
RECORD DETAILS 1
RECORD DETAILS 2
DATE: 06 01 2007
RECORD DETAILS 1
RECORD DETAILS 2
RECORD DETAILS 3
DATE: 05 01 2007
RECORD DETAILS 4
RECORD DETAILS 5
RECORD DETAILS 6
RECORD DETAILS 7
/*
//TMP1 DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//OUT3 DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(OUT1) USING(CP01)
/*
//CP01CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(903:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,4,CH,EQ,C'DATE'),
OVERLAY=(903:SEQNUM,8,ZD)),
IFTHEN=(WHEN=NONE,
OVERLAY=(911:SEQNUM,8,ZD,
903:903,8,ZD,SUB,911,8,ZD,M11,LENGTH=8))
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Krisprems,
Given that your input has LRECL=80 and you're building output records of length 20, why are you putting the seqnum way out at 903? That's very inefficient!
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
M11 is one of DFSORT's edit masks, specifically the one that gives you leading zeros. M11,LENGTH=8 would give you a value like 00005000.
If you don't specify an edit mask or length, DFSORT will use the default of M0 and 15 digits. M0 suppresses leading zeros and has the sign as the last character.
Here's a link to a description of DFSORT's edit masks:
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
I find that hard to believe
Not hard to believe at all.
Quote:
So is M11 doing that??
Yes, that's the difference between using M11,LENGTH=8 and using the default of M0.
The only real difference is how the result of the subtraction for the non-DATE records is displayed. Let's take a look at the sequence numbers in the second record. With M11,LENGTH=8, the result of the subtraction only overlays the first 8 bytes so it looks like 00000001 followed by the 00000001 that followed it before. But without M11,LENGTH=8, the result of the subtraction overlays all 16 bytes (15 digits plus the sign with leading zeros suppressed) so it looks like
Code:
1
Thus instead of creating group numbers in the first 8 bytes, you create garbage. You need the M11,LENGTH=8 for the group trick to work.
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
Frank, I'm going to have to revisit this in the morning.... I really have a problem seeing how the M11,LENGTH=8 actually added an extra sequence field....
mainframe_techie, with Frank's permission, I stand corrected (t'ain't the first time...grin....)
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
I really have a problem seeing how the M11,LENGTH=8 actually added an extra sequence field....
M11,LENGTH=8 didn't add an extra seqnum. It just put the group number (first seqnum) in the right place, whereas without M11,LENGTH=8, the group number is too big and goes in the "wrong" place.
We add the second 8-byte sequence number at 911 with 911:SEQNUM,8,ZD.
Then we overlay the first 8-byte sequence number at 903 with the result of the subtraction by using M11,LENGTH=8. LENGTH=8 just overlays the first 8-byte seqnum at 903 and leaves the second 8-byte seqnum at 911 alone. Without LENGTH=8, the default is LENGTH=16 which overlays the first and second seqnums. So we essentially lose the first 8-byte seqnum (group number) because it's overlaid with garbage by the 16-byte result of the subtraction.
Sorry for posting one more on this.
How would M11 understand from where to start masking??
How much would be told by LENGTH. But what about from where??
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Code:
p,m,f,M11,LENGTH=n
p,m,f gives the starting position, length and format of the input field. M11 edits that input field based on its length and format to create the output field. LENGTH=n gives the length of the output. Without LENGTH=n, DFSORT uses a default length for the output field based on the length and format of the input field.
For complete details on how all of this works, go here: