Page 1 of 1

How to add Values of field in cobol?

PostPosted: Sat Dec 24, 2011 6:44 pm
by chetan_mfguy
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 ?

Re: How to add Values of field in cobol?

PostPosted: Sat Dec 24, 2011 7:04 pm
by prino
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...

Re: How to add Values of field in cobol?

PostPosted: Sat Dec 24, 2011 7:05 pm
by BillyBoyo
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.

Re: How to add Values of field in cobol?

PostPosted: Wed Dec 28, 2011 11:56 am
by Nik22Dec
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

Re: How to add Values of field in cobol?

PostPosted: Wed Dec 28, 2011 2:52 pm
by BillyBoyo
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.

Re: How to add Values of field in cobol?

PostPosted: Wed Dec 28, 2011 10:27 pm
by dick scherrer
Hello,

Just curious - what exactly is a COBOL file?

Re: How to add Values of field in cobol?

PostPosted: Wed Dec 28, 2011 10:45 pm
by Robert Sample
Dick -- longer and more verbose than a FORTRAN file? :D

Re: How to add Values of field in cobol?

PostPosted: Thu Dec 29, 2011 11:48 am
by Nik22Dec
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

Re: How to add Values of field in cobol?

PostPosted: Thu Dec 29, 2011 12:20 pm
by dick scherrer
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". . .

Re: How to add Values of field in cobol?

PostPosted: Thu Dec 29, 2011 6:57 pm
by Robert Sample
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.