Program using occurs clause, COBOL Programming

PROGRAM USING OCCURS CLAUSE:

We have to write a simple program to demonstrate Occurs Clause. Get the employee details for 3 persons and compute the total salary.

identification division.

  program- id. emp-occurs.

  environment division.

  data division.

  working-storage section.

  01  emp-rec.

    02 emp-det occurs 3 times.

      05 emp-name  pic x(20).

      05 emp-sal   pic 9(5)v9(2).

  01 head-1   pic x(80) value all "- ".

  01 head-2.

    02  f  pic x(15) Value spaces.

    02  f  pic x(20) value "NAME".

    02  f  pic x(15) Value spaces.

    02  f  pic x(10) value "SALARY".

    02  f pic x(20) value spaces.

01 head-3.

  02  f pic x(15) value spaces.

  02  e-name pic x(20).

  02  f  pic x(15) Value spaces.

  02  e-sal   pic z(5).z(2).

  02  f  pic x(22) Value spaces.

01   i  pic 9 value 1.

01   tot-sal pic 9(6)v9(2) value 0.

01   e-tot-sal pic z(6).z(2).

procedure division.

para-1.

  display(1 1) erase.

  display(3 5) "Enter Data for 3 Employees...".

  perform get-para 3 times.

  display head-1.

  display head-2.

  display head-1.

  move 1 to i.

  perform disp-para until i > 3.

  display head-1.

  move tot-sal to e-tot-sal.

  display "Total Salary = " e-tot-sal.

  display " ".

  stop run.

get-para.

  display(1 1) erase.

  display(5 5) "Name :  ".

  accept emp-name(i).

  display(10 5) "Salary : ".

  accept emp-sal(i).

  add 1 to i.

disp-para.

  move  emp-name(i) to e-name.

  move  emp-sal(i)  to e-sal.

  compute tot-sal = tot-sal + emp-sal(i).

  display head-3.

  add 1 to i.

Posted Date: 10/18/2012 2:05:20 AM | Location : United States







Related Discussions:- Program using occurs clause, Assignment Help, Ask Question on Program using occurs clause, Get Answer, Expert's Help, Program using occurs clause Discussions

Write discussion on Program using occurs clause
Your posts are moderated
Related Questions
TO WRITE A QUADRATIC EQN ROOTS ARE COMPLEX IN COBOL PROGRAM

bal majduri ik kanuni apradh hai is de bavjud bache ,ghra,hotla,road, kam karn lai majbur han bacheya te mapeya nu parhai val prerit karn lai ik bashan teyar kro

PROGRAM FOR SIMPLE PERFORM: We have to write a program to elaborate simple PERFORM statement Identification division. Program- id.  Perf1. Environment division. Da

Group Item as Operand in the Relational Condition: Whenever an operand of a relational condition is the group item, the item is then considered to be an alphanumeric field. Th

REWRITE STATEMENT: As in the situation of a relative file, the REWRITE statement needs that the file should be opened in the I-O mode, and if the SEQENTIAL access mode is spec

PROGRAM FOR SIZE ERROR:   We have to write an easy program to elaborate the size error option. Identification division. Program- id. sizeerr. Environment division.

B (Blank Insertion) : The occurrence of a B anyplace in the picture will insert a space character in the edited data. There can be more than one B in the picture. Examples:

FILE-CONTROL ENTRIES FOR THE SEQUENTIAL FILES: The characteristics of each and every files handled in a program are specified in the ENVIRONMENT DIVISION and DATA DIVISION.

CLASS CONDITION:   The class condition establishes whether or not the value of the operand is numeric or alphabetic. The operand is numeric if it contains only the digits 0 t

Illustration of if- else statement: IF OK-BALANCE NEXT SENTENCE ELSE MOVE 2 BALANCE-CODE In this illustration, the OK-BALANCE is a condition name. No action is specific if