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: 1187
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: 2285
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
No new posts How to insert a value on specific pos... Poha Eater DFSORT/ICETOOL 9 Sun Oct 01, 2017 3:04 am

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