44 lines
1.1 KiB
Plaintext
44 lines
1.1 KiB
Plaintext
Initializing a data item with a value of the wrong type will lead to runtime errors. The rule checks that numeric data items are not initialized with alphanumeric/alphabetic values and that alphanumeric /alphabetic data items are not initialized with numeric values.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,cobol]
|
|
----
|
|
WORKING-STORAGE SECTION.
|
|
EJECT
|
|
01 TAB-POS.
|
|
02 FILLER PIC A(14) VALUE 0. *> Noncompliant
|
|
02 FILLER PIC 9(14) VALUE 'ASDFJKL;QWERTY'. *> Noncompliant
|
|
|
|
01 MYGROUP PIC 9(1).
|
|
88 X VALUE 1,2.
|
|
88 Y VALUE 3, "BLUE". *> Noncompliant; BLUE is alphanumeric
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,cobol]
|
|
----
|
|
WORKING-STORAGE SECTION.
|
|
EJECT
|
|
01 TAB-POS.
|
|
02 FILLER PIC A(14) VALUE 'ASDFJKL;QWERTY'.
|
|
02 FILLER PIC 9(14) VALUE 0.
|
|
|
|
01 MYGROUP PIC 9(1).
|
|
88 X VALUE 1,2.
|
|
88 Y VALUE 3, 4.
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|