I'm moving a field which is in PIC 9(11) COMP-3 coming from an INPUT file to PIC 9(11). I'm getting S0C7 error or ABEND Bellow is my code:
10 FIELD-FROM PICTURE 9(11) OCCURS 012 TIMES COMPUTATIONAL-3.
01 FIELD-TO PICTURE 9(11).
Then:
INITIALIZE FIELD-TO
DISPLAY 'ST' FIELD-FROM (WS-CPT)
MOVE FIELD-FROM (WS-CPT) TO FIELD-TO
On "DISPLAY 'ST' FIELD-FROM (WS-CPT)", it shows numbers with spaces
Finally, it shows an ABEND S0C7 on the instruction 'MOVE'

You getting an abend because of invalid data. Very likely a test of
will show bad data. Moving the data to this record, for example by
READor by aMOVEstatement to the record you just place the data into it without any transformation or check.When doing a numeric
MOVElater (in this case from the numeric field in the table to a numeric field) and they don't have the exact same definition (USAGE, size) the original data is "unpacked" an then placed into the new field with padding/truncation as necessary.During this unpacking you get an abend - because the data is not valid.
Solution: check if the definition in the record / table matches the input file, if it does "in general" then you possibly have a broken input.
As always: never trust input data, check it for validity if it is not performance-critical (keeping in mind that the
READtakes more time than a common validation) and "external checked".You could validate at least those numeric fields with a
NUMERICclass check (but other data can commonly be checked, too).