Rule Definition
In a MOVE statement using a numeric target data (ex: PIC S9(5) COMP-3) and an alphanumeric source data (ex: PIC X(5)), if the source data contains a value that is not numeric (alphabetic, LOW-VALUE, HIGH-VALUE...) and is used in arithmetic operations, then an abend S0C7 will occur. It is important to control the value that will be moved in the numeric variable.
Remediation
For MOVE statement where the target is numeric and the source is alphanumeric, check the type of the value in the source data with an IF NUMERIC condition.
Violation Code Sample
01 FILE-REC.
05 SRC-DATA PIC X(5).
...
01 TGT-DATA PIC S9(5) COMP-3.
...
READ MY-FILE INTO FILE-REC.
MOVE SRC-DATA TO TGT-DATA.
Fixed Code Sample
01 FILE-REC.
05 SRC-DATA PIC X(5).
...
01 TGT-DATA PIC S9(5) COMP-3.
...
READ MY-FILE INTO FILE-REC.
IF SRC-DATA IS NUMERIC
MOVE SRC-DATA TO TGT-DATA
ELSE
DISPLAY "INVALID VALUE: " SRC-DATA
END-IF
Related Technologies
Cobol
Technical Criterion
Programming Practices - Error and Exception Handling
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.