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
 

 

Performing addition using JCL sort card

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Shaheen Shaik

New User


Joined: 05 May 2016
Posts: 7
Location: India

PostPosted: Fri May 06, 2016 12:25 pm    Post subject: Performing addition using JCL sort card
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: 1716
Location: UK

PostPosted: Fri May 06, 2016 2:55 pm    Post subject:
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: 7
Location: India

PostPosted: Fri May 06, 2016 3:02 pm    Post subject:
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: 7
Location: India

PostPosted: Fri May 06, 2016 5:28 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7235

PostPosted: Fri May 06, 2016 5:31 pm    Post subject: Reply to: Performing addition using JCL sort card
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Fri May 06, 2016 8:10 pm    Post subject:
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: 331
Location: USA

PostPosted: Fri May 06, 2016 8:38 pm    Post subject: Reply to: Performing addition using JCL sort card
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Fri May 06, 2016 8:48 pm    Post subject:
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: 65
Location: India

PostPosted: Fri May 06, 2016 8:56 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Fri May 06, 2016 10:12 pm    Post subject:
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: 65
Location: India

PostPosted: Fri May 06, 2016 10:43 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7235

PostPosted: Sat May 07, 2016 3:13 am    Post subject: Reply to: Performing addition using JCL sort card
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: 7
Location: India

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

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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Mon May 09, 2016 9:10 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7235

PostPosted: Tue May 10, 2016 3:46 am    Post subject: Reply to: Performing addition using JCL sort card
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    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 Performing arithmetic on input field zh_lad DFSORT/ICETOOL 22 Tue Dec 06, 2016 8:04 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


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