Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Adding the relevant fields to give the total

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Adding the relevant fields to give the total
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    Post subject:
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    Post subject: Reply to: Adding the relevant fields to give the total
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 Moderator


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

PostPosted: Mon Feb 09, 2009 10:57 pm    Post subject:
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    Post subject: Reply to: Adding the relevant fields to give the total
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    Post subject: Reply to: Adding the relevant fields to give the total
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 Moderator


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

PostPosted: Wed Feb 11, 2009 10:29 pm    Post subject:
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    Post subject: Reply to: Adding the relevant fields to give the total
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts DSNACCOX (can it be run on 1 db/ts, t... SRICOBSAS DB2 5 Sat May 06, 2017 12:59 am
No new posts Sum Fields ballaswaroop DFSORT/ICETOOL 4 Tue May 02, 2017 11:07 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us