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

Regarding groupin of records based on one field in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 3156
Location: Tucson AZ

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

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

Moderator


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

PostPosted: Fri Dec 01, 2006 4:40 pm
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
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
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: 2481
Location: @my desk

PostPosted: Fri Dec 01, 2006 5:58 pm
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: 3156
Location: Tucson AZ

PostPosted: Fri Dec 01, 2006 6:07 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top