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

Performing addition using JCL sort card


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

New User


Joined: 05 May 2016
Posts: 13
Location: India

PostPosted: Fri May 06, 2016 12:25 pm
Reply with quote

Hi, I need to perform addition of a column in a file by selecting only for some records. for example
Code:
empid  salary location dept
12345  2900   Noida    hr
12342  2348   Noida    it
12398  1237   Mumbai   cs
12378  12788  Mumbai   it

my output file should contain only one record with dept it and salary is the some of all it employes
output has to be
dept salary
Code:
it      15136

[Please (added by moderator)] tell me basic way of doing this using sort card.
(Coded by moderator)
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri May 06, 2016 2:55 pm
Reply with quote

Please present your data, code, JCL (anything you see on your screen really) using the code tags. This preserves spacing. Reading other posts on this forum you will have noticed this requirement. As it happens, you seem to have mangled your data: I have tried to align it as much as possible but I do not know if your salary field is left or right justified.

Also, do not demand an answer: the simple addition of the word "Please" is sufficient to keep people on your side.

Please provide the field (not column) start, length and data type.
Back to top
View user's profile Send private message
Shaheen Shaik

New User


Joined: 05 May 2016
Posts: 13
Location: India

PostPosted: Fri May 06, 2016 3:02 pm
Reply with quote

Thank you Nic.
Back to top
View user's profile Send private message
Shaheen Shaik

New User


Joined: 05 May 2016
Posts: 13
Location: India

PostPosted: Fri May 06, 2016 5:28 pm
Reply with quote

field lengths :
empid 1-6 (numeric) , salary 7-12(numeric), location 12-32(character), dept 33-35(character).
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 06, 2016 5:31 pm
Reply with quote

Use an INCLUDE COND= for the department you want, and OUTFIL reporting features with REMOVECC,NODETAIL and TRAILER1 with a TOT/TOTAL.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri May 06, 2016 8:10 pm
Reply with quote

Bill, He can also do a sum fields and in outfil include only what for dept=it, or reporting feature is better?
Code:
//SORTIN  DD *                     
A 12                               
A 20                               
B 10                               
B 40                               
B 40                               
//SORTOUT DD SYSOUT=*               
//SYSIN DD *                       
    SORT FIELDS=(1,1,CH,A)         
    SUM FIELDS=(3,2,ZD)             
    OPTION ZDPRINT                 
    OUTFILE INCLUDE=(1,1,CH,EQ,C'A')
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Fri May 06, 2016 8:38 pm
Reply with quote

(To add to what Nic said) You should also preview before posting i.e. Preview and Read what you are going to post so that you can correct any mistakes in your statements before posting. You'll only be able to edit your post within 10 mins of posting and Not after that. Now, read this what you have posted:
Quote:
salary is the some of all it employes

If you are specifying a department name then you should write 'IT' instead of 'it'. You are talking about 'SUM' and Not 'some' and it should be 'Employees' and Not 'employes'.

Please keep in mind to use Preview.

.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri May 06, 2016 8:48 pm
Reply with quote

Welcome!
Are you aware of Beginners forum? if not then go to the home page and look at left side and redirect basic questions there as it is designed for that purpose.
Back to top
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 88
Location: India

PostPosted: Fri May 06, 2016 8:56 pm
Reply with quote

To Rohit,
Bill's method is more efficient in the way that INCLUDE COND will remove the unwanted dept. records; which would reduce the load off the TOT.
Remaining OUTFIL functions are there to trim the data in the desired form.

SUM will definitely work, but it'll first work on the entire file first summing the fields considering each record, post which the OUTFIL INCLUDE will do trimming, which is a wastage of resource if the file is fairly large.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri May 06, 2016 10:12 pm
Reply with quote

yes I agree and my intention was checking upon sum fields vs tot function, but then we can do include first then sum fields and then use outrec fields as required.
Back to top
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 88
Location: India

PostPosted: Fri May 06, 2016 10:43 pm
Reply with quote

Urmmm, fwiw, the trick lies somewhere else; by definition SUM requires the records to be sorted first on 'a key', fields of which are to be summed; whereas TOT doesn't have that limitation; meaning, it is similar to a COBOL program where one updates the summation buckets as and when the required field's criteria matches, without having to worry about where the record is occurring. Hence I feel TOT is still better.

But I'd still want to hear from Bill on this one.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat May 07, 2016 3:13 am
Reply with quote

Unless the data already requires SORTing, it is a waste of resources to use SUM. Even if you do that for a small amount of data, there can be someone (and it may be you) will copy those SORT control cards later.

Using the OUTFIL reporting features, there is no need to SORT. There are also many other things available than TOT and COUNT for when you need them.
Back to top
View user's profile Send private message
Shaheen Shaik

New User


Joined: 05 May 2016
Posts: 13
Location: India

PostPosted: Mon May 09, 2016 12:03 pm
Reply with quote

Thank you all for your answers. icon_smile.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Mon May 09, 2016 9:10 pm
Reply with quote

Bill, One question in this case does it require to do sort when we only deal with single category i.e. 'IT/it' records or DFSORT smart enough to know not to do sorting here after include? if not then , is there a way we let DFSORT know that to opt out for the sorting in such situations as there is only record all the time in SORTOUT?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 10, 2016 3:46 am
Reply with quote

If you use a SORT statement, DFSORT is smart enough to do what it is told.

You may think it smarter that it "knows" there's only one type of record, from the INCLUDE/OMIT COND=, but it would have to do that "knowing" for each and every SORT step around the planet. The extra code to do something that may seem useful would rack up CPU (even if not much for any given step) when all you have to do to avoid it is not code the SORT unless you actually need to SORT.
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 8
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
Search our Forums:

Back to Top