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

Using DFSORT to split reports


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
coria

New User


Joined: 09 Oct 2006
Posts: 36

PostPosted: Mon Jul 16, 2007 7:56 am
Reply with quote

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?
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Jul 16, 2007 9:59 am
Reply with quote

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))       
                                                                       
        OUTFIL FNAMES=OUT1,INCLUDE=(903,8,ZD,EQ,+00000001),BUILD=(1,20)
        OUTFIL FNAMES=OUT2,INCLUDE=(903,8,ZD,EQ,+00000002),BUILD=(1,20)
        OUTFIL FNAMES=OUT3,INCLUDE=(903,8,ZD,EQ,+00000003),BUILD=(1,20)
/*                                                                     

OUT1:
Code:
----+----1----+----2
DATE: 07 01 2007   
RECORD DETAILS 1   
RECORD DETAILS 2   

OUT2
Code:
----+----1----+----2
DATE: 06 01 2007   
RECORD DETAILS 1   
RECORD DETAILS 2   
RECORD DETAILS 3   

OUT3
Code:
----+----1----+----2
DATE: 05 01 2007   
RECORD DETAILS 4   
RECORD DETAILS 5   
RECORD DETAILS 6   
RECORD DETAILS 7   
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Jul 16, 2007 9:00 pm
Reply with quote

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!
Back to top
View user's profile Send private message
coria

New User


Joined: 09 Oct 2006
Posts: 36

PostPosted: Mon Jul 16, 2007 9:35 pm
Reply with quote

thank you the help from both of you, friends! however, I got the idea.
I think Krisprems' codes are just for my reference icon_wink.gif
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Jul 16, 2007 9:47 pm
Reply with quote

Ok Frank, will avoid putting the seqnum's at far of places
Back to top
View user's profile Send private message
mainframe_techie

New User


Joined: 15 Jul 2007
Posts: 23
Location: India

PostPosted: Wed Jul 18, 2007 1:14 am
Reply with quote

In this code what is M11 doing?? I tried executing the code without M11 and length and got some weird results.

Thanks,
mainframe_techie
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jul 18, 2007 1:57 am
Reply with quote

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:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG20/2.4.8?DT=20060615173822#TBLMASK2
Back to top
View user's profile Send private message
mainframe_techie

New User


Joined: 15 Jul 2007
Posts: 23
Location: India

PostPosted: Wed Jul 18, 2007 2:08 am
Reply with quote

Frank,

If I remove the M11,length=8 , below is the output

Code:

DATE 01 01 2007                        00000001
123 456  567  111                                    1
123 456  AAA  111                                    1
DATE 02 01 2007                        00000002
123 456  567  222                                    2
123 456  567  222                                    2
DATE 03 01 2007                        00000003
123 456  56.7 222                                    3



where as if I put the code, below is the output

Code:

DATE 01 01 2007                        00000001
123 456  567  111                      0000000100000001
123 456  AAA  111                      0000000100000002
DATE 02 01 2007                        00000002
123 456  567  222                      0000000200000003
123 456  567  222                      0000000200000004
DATE 03 01 2007                        00000003
123 456  56.7 222                      0000000300000005


Now I can see lot of diffrences between the two outputs. So is M11 doing that?? If not what is causing those???
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jul 18, 2007 3:13 am
Reply with quote

mainframe_techie wrote:
Now I can see lot of diffrences between the two outputs. So is M11 doing that?? If not what is causing those???
Please post the sort control records you used to produce both your results.
Back to top
View user's profile Send private message
mainframe_techie

New User


Joined: 15 Jul 2007
Posts: 23
Location: India

PostPosted: Wed Jul 18, 2007 3:57 am
Reply with quote

The only change between two control cards is one didnt had the
M11,Length=8, and one had the same.

Rest entire sort card was the same as mentioned in the solution provided above in the series.

Thanks,
mainframe_techie
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jul 18, 2007 4:20 am
Reply with quote

I find that hard to believe.....
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jul 18, 2007 4:29 am
Reply with quote

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.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jul 18, 2007 4:41 am
Reply with quote

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....)

Bill
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jul 18, 2007 5:51 am
Reply with quote

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.

Code:

    IFTHEN=(WHEN=NONE,                                             
          OVERLAY=(911:SEQNUM,8,ZD,                               
                         903:903,8,ZD,SUB,911,8,ZD,M11,LENGTH=8))   


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.

Does that help?
Back to top
View user's profile Send private message
mainframe_techie

New User


Joined: 15 Jul 2007
Posts: 23
Location: India

PostPosted: Wed Jul 18, 2007 6:17 am
Reply with quote

Thanks Frank. I think that clarifies.

mainframe_techie
Back to top
View user's profile Send private message
mainframe_techie

New User


Joined: 15 Jul 2007
Posts: 23
Location: India

PostPosted: Wed Jul 18, 2007 6:21 am
Reply with quote

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??
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jul 18, 2007 6:45 am
Reply with quote

mainframe_techie wrote:
How would M11 understand from where to start masking??
How much would be told by LENGTH. But what about from where??
Have you looked up Editing Numeric Fields in the sort manual?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jul 18, 2007 7:53 pm
Reply with quote

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:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA20/3.13?DT=20060615185603

and do a find on

p,m,f,edit
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
Search our Forums:

Back to Top