2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-04-28 16:49:39 +02:00
Some COBOL compilers such as IBM one will assume that the minimum value of ``++OCCURS DEPENDING ON++`` is 1 but nothing is enforcing that and this behaviour can change or be different when using another compiler.
Setting the minimum value of ``++OCCURS DEPENDING ON++`` makes the code more readable, and less dependent on compiler.
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,cobol]
2021-04-28 16:49:39 +02:00
----
01 MY-TABLE-COUNT PIC S9(4) BINARY.
01 MY-TABLE.
03 MY-ITEM OCCURS 500 TIMES *> Noncompliant
DEPENDING ON MY-TABLE-COUNT.
05 MY-FIELD-01 PIC X(08).
05 MY-FIELD-02 PIC 9(05).
----
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,cobol]
2021-04-28 16:49:39 +02:00
----
01 MY-TABLE-COUNT PIC S9(4) BINARY.
01 MY-TABLE.
03 MY-ITEM OCCURS 1 TO 500 TIMES *> Compliant; minimum value is 1
DEPENDING ON MY-TABLE-COUNT.
05 MY-FIELD-01 PIC X(08).
05 MY-FIELD-02 PIC 9(05).
----
2021-04-28 18:08:03 +02:00
2021-09-20 15:38:42 +02:00
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
Add a minimum value to this "OCCURS DEPENDING [ON]" clause.
2021-09-20 15:38:42 +02:00
endif::env-github,rspecator-view[]