Page 1 of 2

cobol salary calculation

PostPosted: Tue Dec 13, 2011 12:35 pm
by arjun kumar
Hi Everyone,
Can anyone help me as I have a problem--i.e, How to calculate salary of all employees belonging to same designation. As I have multiple designations to calculate in the same manner. Its urgent.

Re: cobol salary calculation

PostPosted: Tue Dec 13, 2011 12:38 pm
by NicC
We do not do 'urgent' (read the rules).
How much are you willing to pay for someone to write this programs - or series of programs - for you?
What have you tried - where are you stuck?

Re: cobol salary calculation

PostPosted: Tue Dec 13, 2011 12:41 pm
by arjun kumar
As I am a beginner I want to learn how to calculate designation wise thats all

Re: cobol salary calculation

PostPosted: Tue Dec 13, 2011 12:44 pm
by NicC
First define 'designation'

Re: cobol salary calculation

PostPosted: Tue Dec 13, 2011 12:50 pm
by arjun kumar
EMP-TOT-SALARY IS VARIABLE THAT I DEFINED
EMP-SALARY IS IN INPUT FILE EMPLOYEE SALARY
TL-SAL IS ALSO VARIABLE THAT I DEFINED
SALARY IS OUTPUT FILE EMPLOYEE RECORD------WILL THIS LOGIC WORK----MY DESIRED OUTPUT IS TOTAL 'TL' DESIGNATION EMPLOYEE SALARIES ALL TOGETHER

LOGIC:
EMP-TOT-SAL = EMP-TOT-SAL + EMP-SALARY
MOVE EMP-TOT-SAL TO TL-SAL
MOVE TL-SAL TO SALARY

Re: cobol salary calculation

PostPosted: Tue Dec 13, 2011 12:56 pm
by BillyBoyo
No.

You have no conditional logic.

What you will get in SALARY is a "running total" (the total so far when the move was done for that output record).

NicC asked what the designation was, and you didn't reply.

You either need a table of designations/amount for designation or you need the file pre-sorted on designation. You'll need at least one IF either way.

Re: cobol salary calculation

PostPosted: Tue Dec 13, 2011 1:01 pm
by arjun kumar
Yes, I have few designations like AM,BM,CM,DM and their salaries in a given input table.
I defined these deignations in my ws-section.
I want to calculate total salary of employees per designation wise in sorted order

Re: cobol salary calculation

PostPosted: Tue Dec 13, 2011 1:11 pm
by BillyBoyo
You make a table with designation and sum total in each entry.

Accumulate sum total per current designation. When designation changes, put the previous designation and sum into the table. Initialise sum to current value and store new designaiton. Continue until end.

At the end of all your input you will have a table of sums by designation, which you can do whatever you then want with.

If you input is not sorted on designation you will need to do the accumulation in the table, have found a matching entry for designation or, if no matching entry, create a new one.

Re: cobol salary calculation

PostPosted: Tue Dec 13, 2011 1:24 pm
by arjun kumar
Ya, Iam doing the same but couldn't get the logic for that as u said like When designation changes, put the previous designation and sum into the table. Initialise sum to current value and store new designaiton. Continue until end. Can u give idea abt the logic to write. thank u for suggestions till now.

Re: cobol salary calculation

PostPosted: Tue Dec 13, 2011 2:14 pm
by BillyBoyo
if current-designation equal to previous-designation
move previous-designation to designation of next entry in table
move salary-value to salaray of next entry in table
move current-designation to previous-designation
move current-salary to salary-value
else
add current-salary to salary-value