Beruflich Dokumente
Kultur Dokumente
BUSINESS ORIENTED
LANGUAGE)
Overview
COBOL Fundamentals
DAY2
EDITING PICTURE
CLAUSE
Edited picture symbols
Z Zero suppression
* Check protection
, Comma insertion
- Minus sign insertion
+ Plus or minus sign insertion
Edited picture symbols
ZZ999 12 012
***99 12 ***12
$9999 123 $0123
-9999 -1234 -1234
+9999 -1234 -1234
Edited picture symbols (Example)
Overview
What is Redifines ?.
01 WS-POLICY-INFO.
05 POLICY-ID.
10 POLICY-LOC PIC X(3).
Must not be used for data-items defined in level numbers 66 and 88.
Syntax
data-name-1 REDEFINES data-name-2.
Example
01 STUD-DETAILS.
05 STUD-NAME.
10 FIRST-NAME PIC A(15).
10 MIDDLE-NAME PIC A(10).
10 LAST-NAME PIC A(10).
05 NAME REDEFINES STUD-NAME.
REDEFINES CLAUSE … WS00-YEAR2
example redefines WS00-YEAR1.
It is the same 8 bytes of
information which WS00-YEAR2
provides in the Year, Month & Day
format in it’s sub-items.
Any change in WS00-YEAR1 changes
value of WS00-YEAR2 and vice-versa.
************************************
YEAR FOR ENTERED DATE IS : 2005
Syntax
*********************************
Output SPOOL WS-REN VALUE IS : 341234
*********************************
Procedure Division VERBS
Arithmetic Verbs.
ADD
SUBTRACT
MULTIPLY
DIVIDE
COMPUTE
ADD VERB
The ADD statement sums two or more numeric operands and stores the result.
Syntax-1
Syntax-2
Before After
Before
WS00-IN1 123
WS00-OUT2 0000
After
WS00-IN1 123
WS00-OUT2 0223
Before After
The SUBTRACT statement subtracts one numeric item, or the sum of two
or more numeric items, from one or more numeric items and stores the
result.
Syntax
Before After
Before
WS00-IN1 111
WS00-OUT2 2222
After
WS00-IN1 111
WS00-OUT2 2000
Before After
The MULTIPLY statement multiplies numeric items and sets the values of
data items equal to the results
Syntax
Before
WS00-IN1 100
WS00-OUT1 1111
After
WS00-IN1 100
WS00-OUT1 1000
Before After
WS00-IN2 10 WS00-IN2 10
WS00-OUT2 0222 WS00-OUT2 0222
WS00-OUT3 0666 WS00-OUT3 2220
DIVIDE VERB
The DIVIDE statement divides one numeric data item into or by other(s) and sets the
values of data items equal to the quotient and remainder.
Syntax-1
Before
WS00-IN1 100
WS00-OUT1 1000
After
WS00-IN1 100
WS00-OUT1 0010
Before After
WS00-IN2 10 WS00-IN2 10
WS00-OUT2 2000 WS00-OUT2 0008
WS00-OUT3 00 WS00-OUT3 16
The
COMPUTE
Precedence Rules.
1. ** = POWER NN
2. * = MULTIPLY x
/ = DIVIDE ÷
3. + = ADD +
- = SUBTRACT -
On Size error
Divide by zero
The ROUNDED option
Receiving Field Actual Result Truncated Result Rounded Result
WS00-IN1 12.34
WS00-IN2 12.34
WS00-IN3
After
WS00-IN1 12.34
WS00-IN2 12.34
WS00-IN3 24.6
Before After
Arithmetic statement
[ON SIZE ERROR imperative statement . . .]
Examples
WS00-IN1 12.34
WS00-IN2 12.34
WS00-IN3 0
WS00-ERROR-IN3 N
After
WS00-IN1 12.34
WS00-IN2 12.34
WS00-IN3 00
WS00-ERROR-IN3 Y
Before After
*********************************************
Syntax
****************************
Output SPOOL WS00-GR2 : NISHANT 00000
****************************
MOVE . . . OF . . . TO . . . OF
Example:
Receiving field
Alphabe Alphanu Edited Numeri Numeri Edited
tic meric Alpha c c non numeri
numer integer c
ic
Alphabetic Y Y Y N N N
Sending field
Alphanumeri Y Y Y Y Y Y
c
Edited Y Y Y N N N
Alphanumeri
c
Numeric N Y Y Y Y Y
Numeric non N N N Y Y Y
integer
Edited N Y Y Y Y Y