How to add Values of field in cobol?



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

How to add Values of field in cobol?

Postby chetan_mfguy » Sat Dec 24, 2011 6:44 pm

Month Expenditure

01 800
02 700
03 600
04 500
01 100
02 200
03 100

I need the total expenditure month wise in output.
e.g.
month expenditure
01 900
02 900
03 700
04 500

Please explain how to add expenditure month wise in cobol ?
chetan_mfguy
 
Posts: 4
Joined: Sat Dec 24, 2011 6:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to add Values of field in cobol?

 

Re: How to add Values of field in cobol?

Postby prino » Sat Dec 24, 2011 7:04 pm

Ask your employer to send you to a Cobol programming course, this is a forum for Beginners and Students and given the nature of your question, you are obviously still way below that level...
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 536
Joined: Wed Mar 11, 2009 12:22 am
Location: Oostende, Belgium
Has thanked: 3 times
Been thanked: 21 times

Re: How to add Values of field in cobol?

Postby BillyBoyo » Sat Dec 24, 2011 7:05 pm

If you have a table with twelve entries, you can arrange to use the month-number as a subscript/index, accumulate amount per month for each record, at the end of records list everything out from the table.

Remember to set the table to initial values, as you may not have data for each month.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How to add Values of field in cobol?

Postby Nik22Dec » Wed Dec 28, 2011 11:56 am

In case you are reading the data from a cobol file, you can evaluate the month after every read request & add the expenditure to the corresponding month-exp-variable.You will have to define 12 different variables, one for each month.

Thanks & Regards,
Nikhil
Thanks,
Nik
User avatar
Nik22Dec
 
Posts: 68
Joined: Mon Dec 26, 2011 6:38 pm
Has thanked: 2 times
Been thanked: 0 time

Re: How to add Values of field in cobol?

Postby BillyBoyo » Wed Dec 28, 2011 2:52 pm

Nik22Dec wrote:In case you are reading the data from a cobol file, you can evaluate the month after every read request & add the expenditure to the corresponding month-exp-variable.You will have to define 12 different variables, one for each month.

Thanks & Regards,
Nikhil


Why would the source of the data ("cobol file") have an impact on the solution? Whilst you could use EVALUATE and individually-named fields, you'd end up with a horrible mess of a program if you have to do any reasonable amount of processing of the data, with each use of the data requiring 12 slightly-different statements. Say you wanted it in an output record? EVALUATE and 12 different MOVEs. Makes the program more difficult to understand, more difficult to maintain.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How to add Values of field in cobol?

Postby dick scherrer » Wed Dec 28, 2011 10:27 pm

Hello,

Just curious - what exactly is a COBOL file?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: How to add Values of field in cobol?

Postby Robert Sample » Wed Dec 28, 2011 10:45 pm

Dick -- longer and more verbose than a FORTRAN file? :D
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: How to add Values of field in cobol?

Postby Nik22Dec » Thu Dec 29, 2011 11:48 am

Shucks..I guess I am always going to be looked down because of my lack of inhibition in using terms indiscretely. Apologies all, by COBOL File, I meant a normal PS File.
Thanks & Regards,
Nik
Thanks,
Nik
User avatar
Nik22Dec
 
Posts: 68
Joined: Mon Dec 26, 2011 6:38 pm
Has thanked: 2 times
Been thanked: 0 time

Re: How to add Values of field in cobol?

Postby dick scherrer » Thu Dec 29, 2011 12:20 pm

Hello,

I guess I am always going to be looked down because of my lack of inhibition in using terms indiscretely
A lack of inhibition has caused no "down looking" on our forum that i've seen.

What does incur flames, chiding, and other less than enthusiastic replies is the posting of things like a "cobol file", kiddie chat-room text, laziness (unwillingness for folks to invest a bit of thought when building their topics). In a category all by itself is when a member decides to verbally abuse someone who is trying to help them. NOTE: Most of these do not apply to you :)

Because this forum is intended for students and other beginners, we ("the old ones" here) work hard to make consistent, correct use of the terminology. Once a bad idea/term takes hold, it is very difficult to replace with the proper concept.

Look around the forum for the number of "things" people want to do with "a JCL". . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: How to add Values of field in cobol?

Postby Robert Sample » Thu Dec 29, 2011 6:57 pm

COBOL is a computer language -- there is NO such thing as a "COBOL file". There are sequential files, VSAM files (that can be sequential, relative, indexed, linear), partitioned files, and so forth -- but there's no such thing as a COBOL file, or a C file, or a FORTRAN file, or an Assembler file; the language choice has nothing to do with how the file is accessed or used.

Terminology is CRITICAL in IT, where similar terms may mean very different things. If you use terms indiscretely (sic), you require people to take longer to figure out just what you are talking about, and you increase the odds that sooner or later you are going to use a valid term in a context that causes people to wonder about your intelligence, or sanity, or both. Furthermore, using terms out of context causes managers to have a negative view of your talents (since you don't know the terms, how can you know the concepts? type of thinking), which could affect your career.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post