S0C7 while moving PIC 9(11) COMP-3 to PIC 9(11)

144 Views Asked by At

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

Blockquote

Finally, it shows an ABEND S0C7 on the instruction 'MOVE'

1

There are 1 best solutions below

2
Simon Sobisch On

You getting an abend because of invalid data. Very likely a test of

   IF FIELD-FROM (WS-CPT) IS NOT NUMERIC DISPLAY 'BAD'.

will show bad data. Moving the data to this record, for example by READ or by a MOVE statement to the record you just place the data into it without any transformation or check.

When doing a numeric MOVE later (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 READ takes more time than a common validation) and "external checked".

You could validate at least those numeric fields with a NUMERIC class check (but other data can commonly be checked, too).