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

Adding the relevant fields to give the total


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

New User


Joined: 07 Aug 2007
Posts: 7
Location: Hyderabad

PostPosted: Mon Feb 09, 2009 4:49 pm
Reply with quote

Hi All,

I need to create an ouptut which will give the sumation of the marks for each student as the total.
Input :

Code:

A ENGLISH 10
A MATHS   10
B ENGLISH 20
B MATHS   20
C ENGLISH 30
C MATHS   30


output:

Code:

A ENGLISH 10  20
A MATHS   10  20
B ENGLISH 20  40
B MATHS   20  40
C ENGLISH 30  60
C MATHS   30  60


Regards,
Deepak
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Mon Feb 09, 2009 4:56 pm
Reply with quote

Hi,

You can use SORT utility. Have a look at the DFSORT & give it a try.

The SUM statement tells DFSORT to summarize records that have equal
control fields. The format of the SUM statement is:

SUM FIELDS=({pos,len{,fmt}{,...} } | NONE}){,FORMAT=fmt}

where - 'pos' = field starting position
'len' = field length, including any sign
'fmt' = field format, FORMAT= may be used if all fields are
the same format. possible values are:
BI = unsigned binary (2, 4 or 8 bytes)
FI = signed fixed-point (2, 4 or 8 bytes)
PD = signed packed decimal (1 to 16 bytes)
ZD = signed zoned decimal (1 to 18 bytes)
'NONE' = deletes duplicate records without summarization

An example of the SUM statement:

SUM FIELDS=(21,5,PD,58,3,ZD)

Hope this helps.
Back to top
View user's profile Send private message
jdeepak_mca

New User


Joined: 07 Aug 2007
Posts: 7
Location: Hyderabad

PostPosted: Mon Feb 09, 2009 5:29 pm
Reply with quote

Hi,

Thank you for your input:
I am aware of the sum fields, but actually here I should have an extra total field which will always be displayed with the all the key records.

what should be sysin: ?

Example:
Input
Deepak English 20
Deepak Maths 20
Output
Deepak English 20 --> 40
Deepak Maths 20 --> 40

here the total is repeating with the complete record , i.e appended at the end.

Regards
Deepak.
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 Feb 09, 2009 10:57 pm
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=*.IN,VOL=REF=*.IN,DISP=(OLD,PASS)
//OUT DD DSN=...  output file
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(CON) TO(OUT) ON(1,1,CH) WITHALL WITH(1,14)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,
    SECTIONS=(1,1,TRAILER3=(1,12,15:TOT=(11,2,ZD,EDIT=(TT))))
/*
Back to top
View user's profile Send private message
jdeepak_mca

New User


Joined: 07 Aug 2007
Posts: 7
Location: Hyderabad

PostPosted: Tue Feb 10, 2009 12:58 pm
Reply with quote

Hi Frank,

Thank you very much for the quick response, I tried the solution you provided and it works fine.

Have a nice day !

Regards,
Deepak
Back to top
View user's profile Send private message
jdeepak_mca

New User


Joined: 07 Aug 2007
Posts: 7
Location: Hyderabad

PostPosted: Wed Feb 11, 2009 8:14 pm
Reply with quote

Hi Frank,

I faced a problem when I tried to use the input file of LRECL=6000.

Where I have the field at position 5980 of length 2 which has to be added to give the total at position 5999.

This gives me an error. It says REPORT FIELD ERROR.

//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(CON) TO(OUT) ON(1,1,CH) WITHALL WITH(1,5982)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=T1,REMOVECC,NODETAIL,
SECTIONS=(1,1,TRAILER3=(1,5982,5999:TOT=(5980,2,ZD,EDIT=(TT))))
/*
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 Feb 11, 2009 10:29 pm
Reply with quote

Sigh. Why didn't you tell me the LRECL was 6000 in the first place?

The length for TRAILER1 fields is limited to 256 bytes, so 1,5982 won't work. You'd have to do it in 256 byte chunks. In this case, SUM would be a better choice like this:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=*.IN,VOL=REF=*.IN,DISP=(OLD,PASS)
//OUT DD DSN=...  output file
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SPLICE FROM(CON) TO(OUT) ON(1,1,CH) WITHALL WITH(1,5982)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(5999:5980,2)
  SORT FIELDS=(1,1,CH,A)
  SUM FIELDS=(5999,2,ZD)
/*
Back to top
View user's profile Send private message
jdeepak_mca

New User


Joined: 07 Aug 2007
Posts: 7
Location: Hyderabad

PostPosted: Thu Feb 12, 2009 12:55 pm
Reply with quote

Thank you Frank

Its working now !

Have a good day!

Regards,
Deepak
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 Adding QMF and SPUFI to the ISPF menu DB2 20
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts Adding first / last acct numerber to ... DFSORT/ICETOOL 7
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Adding 'ODD' and 'EVEN' indicator at ... DFSORT/ICETOOL 6
Search our Forums:

Back to Top