Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Regarding groupin of records based on one field in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ajaikumar andy robert
Warnings : 1

New User


Joined: 01 Dec 2006
Posts: 23
Location: India

PostPosted: Fri Dec 01, 2006 4:26 pm    Post subject: Regarding groupin of records based on one field in COBOL
Reply with quote

hi i need to group records present in a file based on one field..
say for example,
if there is a field acct-no in the file for every record, then i have to group all the records based on this acct-no.
similarly after grouping i have to sum up another field in every record.. say there is an amount field in each record, i have to sum up all the amount values in the file after the records are grouped.
it ll be very helpful if i get the solution ASAP..

Back to top
View user's profile Send private message

nbalajibe
Warnings : 1

New User


Joined: 28 Nov 2006
Posts: 75
Location: India

PostPosted: Fri Dec 01, 2006 4:36 pm    Post subject:
Reply with quote

HI,
U can use loops using condition to seperate the records based on the filed.
Inside the loop itself u can keep adding the amount of those records which satisfy the condition.

Inform me if i'm wrong.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Fri Dec 01, 2006 4:38 pm    Post subject:
Reply with quote

Sort and sum.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1190
Location: Bangalore,India

PostPosted: Fri Dec 01, 2006 4:40 pm    Post subject:
Reply with quote

Hi ajaikumar andy robert,

It can be done using sort if u give us file layout then we will be able to provide u sort card.
Back to top
View user's profile Send private message
SSR
Warnings : 1

New User


Joined: 26 Feb 2006
Posts: 38

PostPosted: Fri Dec 01, 2006 4:56 pm    Post subject: Re: Regarding groupin of records based on one field in COBOL
Reply with quote

Hi,

You can sort the file based on the account number(using the position of account number) and then sum it.

This can be done using JCL sort i think that would be more efficient.

Regards
SSR
Back to top
View user's profile Send private message
ajaikumar andy robert
Warnings : 1

New User


Joined: 01 Dec 2006
Posts: 23
Location: India

PostPosted: Fri Dec 01, 2006 5:52 pm    Post subject: Re: Regarding groupin of records based on one field in COBOL
Reply with quote

thank you guys for all those replies..
but how do i group the records in cobol, that too based on one field?
is there any specific or command to do so? icon_confused.gif
if not can any of u give me a sample syntax for this grouping and finding the sum of the amount field..

the file consists of some 40 fields and has a total length of 930..
the field acct-no occupies the position 34-42..
the amount field is in the position 560-574..
assume ther are 50 records in the file..
now can any of u give me a sample syntax for groupin these records based on the acct-no field pls.......
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2352
Location: @my desk

PostPosted: Fri Dec 01, 2006 5:58 pm    Post subject:
Reply with quote

Hi

Do you want this to be done through COBOL pgm???

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

Global Moderator


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

PostPosted: Fri Dec 01, 2006 6:07 pm    Post subject:
Reply with quote

Create a 50 row table with an account number field and an amount field (don't forget to initialize the fields).
Read a record and scan the table looking for an account number match.
If found, add the record amount to the table amount.
If not found, find the first "empty" row and move the account number and amount from the record to that row.
At eof, done (unless you wanted them sorted also icon_wink.gif ).
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 -> COBOL Programming 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 display offset thru cobol prog... tvinodkumar7 CICS 1 Sun Apr 22, 2018 8:42 pm
No new posts Linkage editor is part of COBOL, z/OS... ankit.jain COBOL Programming 4 Fri Apr 20, 2018 4:17 pm
This topic is locked: you cannot edit posts or make replies. Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am
No new posts Call COBOL or PLI with a click from w... vaibhav gs All Other Mainframe Topics 1 Mon Apr 16, 2018 7:29 pm
No new posts How to include a particular field val... sakrat DFSORT/ICETOOL 8 Fri Apr 06, 2018 8:27 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us