1

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'

Compo
  • 36,585
  • 5
  • 27
  • 39
Ahmed SEDDIK
  • 149
  • 12

1 Answers1

1

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).

Simon Sobisch
  • 6,263
  • 1
  • 18
  • 38
  • I want to fill the file manually. What i should put on PIC 9(11) COMP-3 for exemple ? – Ahmed SEDDIK May 05 '23 at 13:05
  • You don't - you place `USAGE DISPLAY` data in for easy changes.... but that's a separate question placed in https://stackoverflow.com/questions/76182957/fill-file-field-pic-911-comp-3-with-data-manually (please accept this answer if it is working for the original question posted or comment on what is missing). – Simon Sobisch May 05 '23 at 14:08