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
 
How to check repetations?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sabarikanth

New User


Joined: 07 Jun 2010
Posts: 59
Location: coimbatore

PostPosted: Sat Aug 07, 2010 3:11 pm    Post subject: How to check repetations?
Reply with quote

Hi all,
This may be a simple question.
But i need a solution for this.

My question is,
I have to check a group of values from a database which has a primary key say for e.g Emp.Number. Here this emp.number has another set of number inturn called Roll.Number. This Roll.Number has a value. The Roll.Number can be repeated any number of times(There may be duplicates). Here i need to calculate the sum of the repeated Roll.Number's value together for a Emp.Number. If their is no repeated values it must give the same value.

Please go thru the example.

Let me Give u an example:
Code:
Emp.Number- 00100

Roll.number :1 value-10
Roll.number :2 value-20
Roll.number :3 value-30
Roll.number :1 value-40
Roll.number :2 value-50
Roll.number :6 value-60


My output should be sum of oly repeated Roll.numbers:

Code:
10+40=50 for Roll.number :1
20+50=70 for Roll.number :2
and
30 for Roll.number :3
60 for Roll.number :6


Please help me with a sample code to begin with.

Thanks,
Sabari
Back to top
View user's profile Send private message

Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Sat Aug 07, 2010 4:01 pm    Post subject:
Reply with quote

Hi Sabari,

Quote:
Please help me with a sample code to begin with.
Sorry to dampen your spirit... but this is not how we work here... Start with your coding or design... and in case you are facing any problems, surely some one here should be able to help you ....

On a personal note...
Could you please provide a sample for us to know exactly how your input is and what is expected in the output... Please dont have anything else (calculations, comments, ... ) inside the code tag ... that's confusing... icon_sad.gif
Back to top
View user's profile Send private message
saurabh39
Warnings : 1

Active User


Joined: 11 Apr 2008
Posts: 144
Location: Jamshedpur

PostPosted: Sat Aug 07, 2010 9:54 pm    Post subject: Reply to: How to check repeatations?
Reply with quote

HI Sabari,

If I understand your question......which is just to add up or sum values for a duplicate roll number......then i guess you should start looking at Sort rather than coding logic in COBOL. It will save you lot of time & hassles
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Sat Aug 07, 2010 11:32 pm    Post subject:
Reply with quote

sounds like simple enough sql.

had you explained it properly, you would have had a head start:

you want the sum of the values for like emp_no and like roll number.

or,
you want your results to reflect a 'GROUPed BY' accumulation.


you want to select the emp_no, roll_no, and a sum of the value column.
combine that with a group by clause and order by.

hint:
you use sum in the select,
so that the group by can sum the duplicates,
and with an Aggregate function - SUM(VALUE) - in the select,
it does not have to be part of the group by clause.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Aug 08, 2010 1:43 am    Post subject:
Reply with quote

Hello,

Quote:
then i guess you should start looking at Sort rather than coding logic in COBOL. It will save you lot of time & hassles

Not . . . icon_sad.gif

There is rarely a good reason to to drop cobol code for sort code. . .

In fact, more than 99% of business requirements need more processing than a sort alone can accomplish. . . When a sort solution can meet an entire requirement it may be the best choice, but on any "real" system there are multiple inputs and outputs including qsam fles, vsam files, and database info. . .

To add to what DBZ mentioned - the requirement does not sound overly complicated. If it cannot be clearly described, it will be almost impossible to implement. . .
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Sun Aug 08, 2010 6:41 pm    Post subject:
Reply with quote

if this needs to be done completely in cobol code,
1. insure that your input is sorted on the double-key
2. read input - eof output last accumulation - goback
3. if new double-key = last double-key accumulate value, goto read
4. output accumulation, move new double-key and value to last, goto read
Back to top
View user's profile Send private message
sabarikanth

New User


Joined: 07 Jun 2010
Posts: 59
Location: coimbatore

PostPosted: Mon Aug 09, 2010 12:10 pm    Post subject: Reply to: How to check repetations?
Reply with quote

Hi all,
Thanks for your comments. Sorry for late reply.
I started to code in COBOL. Because my requirement is to code in COBOl.
I cant use SQl codes here. I got the aggregate value with simple preform statement and i used IDMS for binding the database. thank you all. If in case I have any concerns i'l reach you.

Thanks,
Sabari.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Aug 09, 2010 7:49 pm    Post subject: Reply to: How to check repetations?
Reply with quote

Good to hear it is working - thanks for the followup icon_smile.gif

Someone will be here if there are additional questions.

d
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 ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am

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