Вы находитесь на странице: 1из 56

COBOL (COMMON

BUSINESS ORIENTED
LANGUAGE)

Overview

COBOL
Fundamentals DAY1

Day

1:

Introduction to COBOL
Evolution, Features & Language Fundamentals
Program Structure
Data description entry

Session Plan

M.K.Roy

and D. Ghosh Dastidar, COBOL


Programming, Tata McGraw Hill, New York,
1973.

Nancy

Stern and Robert Stern, COBOL


Programming, John Wiley & Sons, New
York, 1973.

Newcomer

and Lawrence, Programming


with Structured COBOL, McGraw Hill
Books, New York, 1973.

References

1959 United States Department of Defense


1960 - COBOL initial specifications presented by CODASYL
(Conference on
Data Systems Languages)

1964 BASIC COBOL extended to Visual COBOL


1968 ANSI (American National Standards Institute)
developed
American National Standard (ANS) COBOL
1974 ANSI published revised version of (ANS) COBOL

Business applications needed to


manipulate character as well as numeric
data

String operations added


1985 COBOL 85 Standards was introduced with revised
version of COBOL-74.

History of COBOL

What

does COBOL stand for?


COmmon Business Oriented
Language.

Which

are target area of COBOL


applications?

Defense, Aircraft, Insurance, Finance,


Retail etc
(file & data oriented applications
involved)

So

we can say that COBOL is basically


used for writing business applications
and not for developing system software

COBOL

COBOL Program Structure


PROGRAM

DIVISIONS

SECTIONS

PARAGRAPHS

SENTENCES

Principal portions of a program.


There are 4 divisions
a) Identification (Required)
b) Environment (Optional)
Userc)
defined
of code
Datachunk
(Optional)
which
consists
of
one/more
d) Procedure (Required)
paragraphs.
e.g.
User defined chunk of code
a) U000-CHECK-LOG
SECTION.
which consists of one/more
b)
FILE SECTION.
sentences.
e.g.
A
consists of one or
a) SENTENCE
P000-PRINT-FINAL-TOTALS.
A
STATEMENT
consists
of a
more
statements
is
b) PROGRAM-ID.and
COBOL
verb
and
an
terminated by a full stop.
or operands.
e.g. a) MOVEoperand
.21 TO VAT-RATE
RESERVEDb)
WORDS
e.g.
COMPUTE VAT-AMOUNT =
SUBTRACT
T-TAX.
PRODUCT-COST
* VAT-RATE

STATEMENTS

FROM
GROSSCHARACTERS
PAY GIVING NET-PAY

USER DEFINED WORDS

COBOL CHARACTER SET


Overview

Character

Meaning

Space
+

Plus sign

Minus sign or hyphen

Asterisk

Forward slash or solidus

Equal sign

Currency sign1

Comma

Semicolon

Decimal point or period

"

Quotation mark2

Left parenthesis

Right parenthesis

>

Greater than

<

Less than

Colon

'

Apostrophe

A-Z

Alphabet (uppercase)

a-z

Alphabet (lowercase)

0-9

Numeric characters

IDENTIFICATION DIVISION
Compiler takes this as
Program Identifier.
PROGRAM-ID comes
immediately after ID
Division.

IDENTIFICATION
IDENTIFICATIONDIVISION.
DIVISION.
PROGRAM-ID.
PROG1.
PROGRAM-ID.
PROG1.
AUTHOR.
R.R.
AUTHOR.
R.R.BHATT.
BHATT.
INSTALLATION.
ABC
CORP.
INSTALLATION.
ABC CORP.
DATE-WRITTEN.
01-JAN-2005.
DATE-WRITTEN.
01-JAN-2005. OPTIONAL
DATE-COMPILED.
01-JAN-2005.
DATE-COMPILED.
01-JAN-2005.
SECURITY.
HIGH.
SECURITY.
HIGH.

ENVIRONMENT DIVISION
ENVIRONMENT DIVISION

CONFIGURATION SECTION

INPUT-OUTPUTT SECTION

Identifies the
computer used for
compiling of programs

Identifies the
resources used for
executing the program

DATA DIVISION

The DATA DIVISION is used to describe the data structures used in the
program.

There are sections in the DATA DIVISION

The

FILE SECTION
WORKING-STORAGE SECTION
LINKAGE SECTION
REPORT SECTION
two most commonly used components (sections) are
a) WORKING-STORAGE SECTION
Internal data structures are defined here.
b) FILE SECTION
File I/O buffer areas are defined here.

DATA DIVISION.
FILE SECTION.
FD INVENTORY-FILE
RECORD CONTAINS 78 CHARACTERS.
01 INVENTORY-REC.
05 IF-PART-NUMBER
05
05 IF-WHSE-LOCS.
10 IF-MAIN-LOC
10 IF-ALT-LOC
05
FD PRINT-FILE.
01 PRINT-REC.
05
05 P-PART-NUMBER
05
05 P-MAIN-LOC
05
05 P-ALT-LOC
WORKING-STORAGE SECTION.
01 FLAGS.
05 F-MORE-RECORDS

DATA DIVISION

PIC X(09).
PIC X(24).
PIC X(06).
PIC X(06).
PIC X(33).
PIC
PIC
PIC
PIC
PIC
PIC

X(10).
X(09).
X(05).
X(06).
X(05).
X(06).

PIC X VALUE 'Y'.

The PROCEDURE DIVISION


consists of the following

Sections

Paragraphs

Sentences

StatementsDIVISION ..
PROCEDURE

Section

Section contain one or


more Paragraphs.

PROCEDURE DIVISION.
0001-ACCOUNT-SECTION.

Paragraph
A PARAGRAPH
comprises of one or
more sentences

001-ACCOUNT-READ-PARA.
READ ACC-FILE AT END
MOVE Y TO EOF.
MOVE TAX-REDUCT TO TAX-AMOUNT
001-ACCOUNT-VALIDATE-PARA.
ADD AMOUNT TO TOT-AMOUNT.
ACCEPT EMPLOYEE-SALARY
DISPLAY Current Employee Salary
EMPLOYEE-SALARY.
001-EXIT-PARA.
STOP RUN.

Sentences

A SENTENCE is a
combination of one or
more statements and is
terminated by a full
stop.

statement

PROCEDURE DIVISION

A STATEMENT is a
combination of a
COBOL verb and one
or more operands.

IDENTIFICATION
IDENTIFICATIONDIVISION.
DIVISION.
PROGRAM-ID.
PROGRAM-ID. FIRSTPG.
FIRSTPG.
PROCEDURE
PROCEDUREDIVISION.
DIVISION.
A0000-MAIN-PARA.
A0000-MAIN-PARA.
DISPLAY
DISPLAY-------------------------------.
-------------------------------.
DISPLAY

DISPLAY WELCOME
WELCOMETO
TOCOBOL.
COBOL.
DISPLAY
--------------------------------.
DISPLAY --------------------------------.
STOP
STOPRUN.
RUN.

First COBOL program

COBOL coding sheet


Column numbers
1 2

Column
numbers

8 9 10

Area A

11

12

72

Area B

80

I
D
E
N
T

I
F

I
C
A
T
I
O
N
A
R
E
A

Almost all COBOL compilers treat a line of COBOL


code as if it contained two distinct areas. These are -

AREA A

AREA B

*) Between Column 8 to 11
*) Division, Section, Paragraph
names, FD entries & 01
level entries must start in
Area A

*) Between Column 12 to 72
*) All Sentences & Statements
start in Area B

COBOL coding sheet

Each

line is considered to be made up of 80


columns.
Columns 1 to 6 are reserved for line numbers.
Column 7 is an indicator column and has
special
meaning to the compiler.
Asterisk ( * ) indicates comments
Hyphen ( - ) indicates continuation
Slash
( / ) indicates form feed
Columns 8 to 11 are called Area A. All COBOL
DIVISIONs, SECTIONs, paragraphs and some
special entries must begin in Area A.
Columns 12 to 72 are called Area B. All COBOL
statementscoding
must begin
in Area B.
COBOL
rules
Columns 73 to 80 are identification area.

Basic data types


Alphabetic

( A)
Numeric( 9)
Alphanumeric (X)
Edited numeric ( Z, $)
Edited alphanumeric(/,-)

Are

named memory locations.

Must

be described in the DATA


DIVISION before they can be used
in the PROCEDURE DIVISION.

Can

be of elementary or group
type.

Can

be subscripted for Arrays.

Are

user defined words .

Data names

Can

be at most 30 characters in
length.

Only

alphabets, digits and hyphen


are allowed.

Blanks
May

are not allowed.

not begin or end with a hyphen.

Should

not be a COBOL reserved


word like
ADD,SUBTRACT,MOVE,DISPLAY etc.

Rules for forming User-defined


words

All

the data names used in the PROCEDURE


DIVISION must be described in the DATA DIVISION.
The description of a data name is done with the aid
of the following
(1) Level number
(2) PICTURE clause
(3) VALUE clause

DATA DIVISION.
01 WS-EMPL-NO PIC X(10) VALUE 1001.

Description of data names


VALUE
LEVEL NO

Data Name

Picture Clause

Clause

Level number

Is used to specify the the data hierarchy.

Level Number
01
02 to 49

Purpose

Record description and independent items


Fields within records and sub items

66

RENAMES clause

77

Independent items

DATA NAME LEVEL NO


88
Condition names

Code
PICTURE
clause

Piture Clause

Meaning

Numeric

Alphabetic

Alphanumeric

Implicit Decimal

Sign bit

Some examples

PICTURE
PICTURE
PICTURE
PICTURE
99.99
PICTURE

999
S999
XXXX
99V99
S9V9

a three digit (+ive only) integer


a three digit (+ive/-ive) integer
a four character text item or string
a +ive real in the range 0 to
a +ive/-ive real in the range ?

If you wish you can use the abbreviation PIC.

Numeric values can have a maximum of 18


(eighteen) digits (i.e. 9s).

The limit on string values is usually systemdependent.

COBOL PICTURE Clauses

Recurring

symbols can be specified using


a repeat factor inside round brackets
PIC 9(6) is equivalent to PICTURE 999999
PIC 9(6)V99 is equivalent to PIC 999999V99
PICTURE X(10) is equivalent to PIC
XXXXXXXXXX
PIC S9(4)V9(4) is equivalent to PIC
S9999V9999
PIC 9(18) is equivalent to PIC
999999999999999999

Abbreviating recurring
symbols

In COBOL a variable declaration consists of a line containing the following


items;
A level number.
A data-name or identifier.
A PICTURE clause.

We can give a starting value to variables by means of an extension to the


picture clause called the value clause.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 Num1
PIC 999
VALUE ZEROS.
01 VatRate
PIC V99
VALUE .18.
01 StudentName
PIC X(10) VALUE SPACES.

DATA
Declaring
DATA in COBOL
Num1 VatRate
Num1 VatRate

000
000

.18
.18

StudentName
StudentName

VALUE clause

Is used to assign an initial value to a elementary data item.

The initial value can be numeric literal, non- numeric literal


or figurative constant.

Is an optional clause.

Description of data names ..

Literals

are symbols whose value does


not change in a program.

There are 3 types of literals namely


(1) Numeric literals.
(2) Non-numeric literals.
(3) Figurative constants.

Literals

Figurative constants

Meaning

ZERO(S) or ZEROES

Represents the value 0, one or


more depending on the context

SPACE(S)

Represents one or more spaces

HIGH-VALUE(S)

Represents the highest value

LOW-VALUE(S)

Represents the lowest value

QUOTE(S)

Represents single or double


quotes

Literals Figurative Constants


ALL literal

Fill With Literal

Figurative Constants - Examples


01
01 GrossPay
GrossPay PIC
PIC 9(5)V99
9(5)V99 VALUE
VALUE 13.5.
13.5.
ZERO
MOVE
TO GrossPay.
MOVE ZEROS
ZEROES TO GrossPay.
GrossPay
0 0 0 1 3 5 0

01
01 StudentName
StudentName

PIC
PIC X(10)
X(10) VALUE
VALUE "MIKE".
"MIKE".

MOVE
MOVE ALL
ALL "-"
"-" TO
TO StudentName.
StudentName.
StudentName

M I K E

Figurative Constants - Examples


01
01 GrossPay
GrossPay PIC
PIC 9(5)V99
9(5)V99 VALUE
VALUE 13.5.
13.5.
ZERO
MOVE
TO GrossPay.
MOVE ZEROS
ZEROES TO GrossPay.
GrossPay
0

01
01 StudentName
StudentName

PIC
PIC X(10)
X(10) VALUE
VALUE "MIKE".
"MIKE".

MOVE
MOVE ALL
ALL "-"
"-" TO
TO StudentName.
StudentName.
StudentName

- - - - - - - - - -

WORKING-STORAGE SECTION.
SECTION.
01WORKING-STORAGE
EMPLOYEE-DETAILS
PIC X(30).
01 EMPLOYEE-DETAILS PIC X(30).
01 EMPLOYEE-DETAILS.
0105EMPLOYEE-DETAILS.
EMP-NUM
PIC 9(4).
EMP-NUM PIC
PICX(10).
9(4).
0505EMP-NAME
EMP-NAME PIC
PICX(4).
X(10).
0505EMP-DEPT
05
EMP-DEPT
PIC
X(4).
05 EMP-LOC
PIC X(12).
05 EMP-LOC
PIC X(12).

In COBOL the term group item is


used to describe a data item which
has been further subdivided.

A Group item is declared using


a level number and a data
name. It cannot have a picture
clause.

Where a group item is the


highest item in a data
hierarchy it is referred to as a
record and uses the level
number 01.
Picture clauses are NOT
specified for group data
items because the size of a
group item is the sum of the
sizes of its subordinate,
elementary items and its type
is always assumed to be PIC X.

Group and elementary items

WORKING-STORAGE SECTION.
SECTION.
01WORKING-STORAGE
EMPLOYEE-DETAILS
PIC X(20).
01 EMPLOYEE-DETAILS PIC X(20).
01 EMPLOYEE-DETAILS.
0105EMPLOYEE-DETAILS.
EMP-NUM
PIC 9(4).
EMP-NUM PIC
PICX(10).
9(4).
0505EMP-NAME
05
EMP-NAME
PIC
X(10).
05 EMP-DEPT PIC X(4).
05
EMP-DEPT
PIC
X(4).
05 EMP-LOC
PIC X(12).
05 EMP-LOC
PIC X(12).

Group item

Sub-Items

Group Items/Records Example

Data in input file

Variable for file read

123456789012345678901234567890
1234JyothiS
E&R Bangalore
2234Archana
E&R Marathi
9999Bhushan
E&R C++

(cols)

Value

WORKING-STORAGE SECTION.
SECTION.
01WORKING-STORAGE
EMPLOYEE-DETAILS
PIC X(30). 1234JyothiS
01 EMPLOYEE-DETAILS PIC X(30). 1234JyothiS

Group Items/Records Example

E&R Bangalore
E&R Bangalore

Data in input file


123456789012345678901234567890 (cols)
1234JyothiS
E&R Bangalore
2234Archana
E&R Mysore
9999Bhushan
E&R Chennai

Variable for file read


WORKING-STORAGE SECTION.
SECTION.
01WORKING-STORAGE
EMPLOYEE-DETAILS
PIC X(30).
01 EMPLOYEE-DETAILS PIC X(30).
01 EMPLOYEE-DETAILS.
0105EMPLOYEE-DETAILS.
EMP-NUM
PIC 9(4).
EMP-NUM PIC
PICX(10).
9(4).
0505EMP-NAME
05
EMP-NAME
PIC
X(10).
05 EMP-DEPT PIC X(4).
05
EMP-DEPT
PIC
X(4).
05 EMP-LOC
PIC X(12).
05 EMP-LOC
PIC X(12).

Value
1234JyothiS
1234JyothiS
1234
1234
JyothiS
JyothiS
E&R
E&R
Bangalore
Bangalore

Group Items/Records Example

E&R Bangalore
E&R Bangalore


WORKING-STORAGE SECTION.
01WORKING-STORAGE
POLICY-DETAILS.SECTION.
0105POLICY-DETAILS.
POLICY-NO.
05 10
POLICY-NO.
POLICY-TYP PIC X(4).
POLICY-TYP PIC
PICX(2).
X(4).
1010POLICY-LOC
10
POLICY-LOC
PIC
X(2).
10 POLICY-ID
PIC X(5).
10
POLICY-ID
PIC
X(5).
05 POLICY-TYPE
PIC X(10).
05
POLICY-TYPE
PIC
X(10).
05 POLICY-EXPDT PIC X(10).
05 POLICY-EXPDT PIC X(10).

LEVEL Numbers &


hierarchy

In COBOL, Level
numbers are used to
express data hierarchy.
The higher the level
number, the lower the
item is in the hierarchy.
So Group items contain
sets of elementary
items with lower level
numbers. At the lowest
level the data is
DATA
completely atomic.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-REGNO
PIC X(5).
01 WS-NAME.
05 WS-FIRST-NAME PIC A(15).
05 WS-MID-NAME PIC A(15).
05 WS-LAST-NAME PIC A(10).
01 WS-AGE
PIC 99V99.
01 WS-SCHOLARSHIP
PIC 9(4)
VALUE 1000.

Description of data names

ds
WORKING-STORAGE SECTION.
WORKING-STORAGE
01
StudentDetailsSECTION. PIC X(26).
01 StudentDetails
PIC X(26).

StudentDetails
H E N N E S S Y R M 9

2 3 0 1 6 5 L M 5 1 0 5 5 0

ds
WORKING-STORAGE SECTION.
WORKING-STORAGE
SECTION.
01
StudentDetails.
01 02
StudentDetails.
StudentName
02
StudentName
02 StudentId
02 CourseCode
StudentId
02
02
CourseCode
02 Grant
02 Gender
Grant
02
02 Gender

PIC X(10).
PIC9(7).
X(10).
PIC
PICX(4).
9(7).
PIC
PIC
X(4).
PIC 9(4).
PICX.
9(4).
PIC
PIC X.

StudentDetails
H EN N E S S Y RM 9 2 3 0 1 6 5 L M 5 1 0 5 5 0 F
StudentName

StudentId

CourseCode Grant

Gender

ds
WORKING-STORAGE SECTION.
WORKING-STORAGE
SECTION.
01
StudentDetails.
01 02
StudentDetails.
StudentName.
02 03
StudentName.
Surname
03Initials
Surname
03
03
Initials
02 StudentId
02 CourseCode
StudentId
02
02
CourseCode
02 Grant
02 Gender
Grant
02
02 Gender

PIC X(8).
PICXX.
X(8).
PIC
PIC
XX.
PIC 9(7).
PICX(4).
9(7).
PIC
PIC
X(4).
PIC 9(4).
PICX.
9(4).
PIC
PIC X.

StudentDetails
H EN N E S S Y RM 9 2 3 0 1 6 5 L M 5 1 0 5 5 0 F
StudentName
Surname

StudentId
Initials

CourseCode Grant

Gender

MOVE VERB
Overview

The MOVE
Verb
Identifier

Literal

MOVE

TO Identifier ...

MOVE

copies data from the source identifier or literal


to one or more destination identifiers.

MOVE

copies data to Group or elementary data items.

MOVE

always performs LEFT JUSTIFICATION to


Character

MOVE

always perform RIGHT JUSTIFICATION to


Numeric data.

When

data is MOVEd into an item the contents of the


item are completely replaced.
If the source data is too small to fill the destination item
entirely the remaining area is zero or space filled.

Data
MOVE
MOVE RYAN
RYAN TO
TO Surname.
Surname.
MOVE
FITZPATRICK
MOVE FITZPATRICK TO
TO Surname.
Surname.

01 Surname
PIC X(8).
C O U G H L A N

Data
MOVE
MOVE RYAN
RYAN TO
TO Surname.
Surname.
MOVE
FITZPATRICK
MOVE FITZPATRICK TO
TO Surname.
Surname.

01 Surname
R Y

A N

PIC X(8).

Data
MOVE
MOVE RYAN
RYAN TO
TO Surname.
Surname.
MOVE
FITZPATRICK
MOVE FITZPATRICK TO
TO Surname.
Surname.

01 Surname
F I T

Z P

PIC X(8).
A T R I C K

MOVEing to a
numeric item.
When

the destination item is numeric, or


edited numeric, then data is aligned along
the decimal point with zero filling or
truncation as necessary.

When

the decimal point is not explicitly


specified in either the source or
destination items, the item is treated as if
it had an assumed decimal point
immediately after its rightmost character.

01 GrossPay

PIC 9(4)V99.
GrossPay

MOVE ZEROS TO GrossPay.

0 0 0 0 0 0

GrossPay

MOVE 12.4 TO GrossPay.

0 0 1 2

4 0

GrossPay
0 1

2 3

4 5 6

MOVE 123.456 TO GrossPay.


1 2 3 4 5
7 5 7
GrossPay

MOVE 12345.757 TO GrossPay.

01 CountyPop
01 Price

PIC 999.
PIC 999V99.
CountyPop

MOVE 1234 TO CountyPop.

1 2 3 4

CountyPop

MOVE 12.4 TO CountyPop.

0 1

1 5 4
Price
MOVE 154 TO Price.

2 4

0 0

3 5 5 2
7 5

Price

MOVE 3552.75 TO Price.

Before

After

WS00-OUT1

0000

WS00-OUT1

3456

WS00-OUT2

000000

WS00-OUT2

345678

Before

WS00-OUT3

000000

After

WS00-OUT3

Before

WS00-OUT4

After

00000000

WS00-OUT4

12345678

123456

MOVE .. example

****************************

Output SPOOL

WS00-OUT1 : HARAYANA
WS00-OUT2 : HARAYANA
****************************

DISPLAY
Verb
Identifier

Literal

DISPLAY

Identifier
...

Literal

UPON Mnemonic - Name WITH NO ADVANCING


From

time to time it may be useful to display messages


and data values on the screen.

simple DISPLAY statement can be used to achieve this.

single DISPLAY can be used to display several data


items or literals or any combination of these.

The

WITH NO ADVANCING clause suppresses the


carriage return/line feed.

The ACCEPT
verb
Format 1. ACCEPT Identifier FROM Mnemonic - name
DATE

DAY

Format 2. ACCEPT Identifier FROM


DAY - OF - WEEK
TIME

01
CurrentDate
CurrentDate
*01
YYMMDD

PIC
PIC 9(6).
9(6).

01
DayOfYear
DayOfYear
*01
YYDDD

PIC
PIC 9(5).
9(5).

01
Day0fWeek
Day0fWeek
*01
D (1=Monday)

PIC
PIC 9.
9.

01
CurrentTime
CurrentTime
*01
HHMMSSss
s = S/100

PIC
PIC 9(8).
9(8).

* YYMMDD
* YYDDD

* D (1=Monday)
* HHMMSSss

s = S/100

Run of Accept and Display program


Enter student details using template below
Enter student details using template below
NNNNNNNNNNSSSSSSSCCCCGGGGS
NNNNNNNNNNSSSSSSSCCCCGGGGS
COUGHLANMS9476532LM511245M
COUGHLANMS9476532LM511245M
Name
is MS COUGHLAN
Nameisis24MS01COUGHLAN
Date
94
Date is
is day
24 01
Today
02494of the year
Today
024 of the year
The
timeisisday
22:23
The time is 22:23

IDENTIFICATION DIVISION.
PROGRAM-ID.
AcceptAndDisplay.
IDENTIFICATION
DIVISION.
AUTHOR.
Michael
Coughlan.
PROGRAM-ID.
AcceptAndDisplay.
AUTHOR. Michael Coughlan.
DATA DIVISION.
WORKING-STORAGE
DATA DIVISION. SECTION.
01WORKING-STORAGE
StudentDetails.SECTION.
StudentName.
0102StudentDetails.
Surname
PIC X(8).
02 03StudentName.
0303Initials
PIC
Surname
PICXX.
X(8).
02 StudentId
PIC
03 Initials
PIC9(7).
XX.
0202 CourseCode
PIC
StudentId
PICX(4).
9(7).
0202 Grant
PIC
CourseCode
PIC9(4).
X(4).
0202 Gender
PIC
Grant
PICX.9(4).
02 Gender
PIC X.
01 CurrentDate.
CurrentYear
PIC 99.
0102CurrentDate.
0202 CurrentMonth
PIC
CurrentYear
PIC99.
99.
0202 CurrentDay
PIC
CurrentMonth
PIC99.
99.
02 CurrentDay
PIC 99.
01 DayOfYear.
FILLER
PIC 99.
0102DayOfYear.
0202 YearDay
PIC
FILLER
PIC9(3).
99.
02 YearDay
PIC 9(3).
01 CurrentTime.
CurrentHour
PIC 99.
0102CurrentTime.
0202 CurrentMinute
PIC
CurrentHour
PIC99.
99.
0202 FILLER
CurrentMinute PIC
PIC9(4).
99.
02 FILLER
PIC 9(4).

PROCEDURE DIVISION.
PROCEDURE DIVISION.
Begin.
Begin.
DISPLAY "Enter student details using template below".
DISPLAY"NNNNNNNNNNSSSSSSSCCCCGGGGS
"Enter student details using template below".
DISPLAY
".
DISPLAYStudentDetails.
"NNNNNNNNNNSSSSSSSCCCCGGGGS
".
ACCEPT
ACCEPT CurrentDate
StudentDetails.
ACCEPT
FROM DATE.
ACCEPT DayOfYear
CurrentDate
ACCEPT
FROMFROM
DAY.DATE.
ACCEPT CurrentTime
DayOfYear FROM
ACCEPT
FROM DAY.
TIME.
ACCEPT "Name
CurrentTime
FROM TIME.
DISPLAY
is ", Initials
SPACE Surname.
DISPLAY"Date
"Nameisis" ",
Initials SPACE
SPACE CurrentMonth
Surname.
DISPLAY
CurrentDay
SPACE CurrentYear.
DISPLAY"Today
"Date is
is day
" CurrentDay
CurrentMonth
SPACE CurrentYear.
DISPLAY
" YearDay SPACE
" of the
year".
DISPLAY
DISPLAY"The
"Today
timeisisday
" CurrentHour
" YearDay " ":"
of the
CurrentMinute.
year".
DISPLAY
STOP
RUN. "The time is " CurrentHour ":" CurrentMinute.
STOP RUN.

Example Program Date


Overview

Вам также может понравиться