How to move P to N field?

How i said in the title i have a P field and i need move to N field, how to do that? because a simple MOVE i can’t do

For example:

DEFINE DATA

Local
1 VAR-P (P09)
1 RESULT-N (N11) (EM=ZZZ.ZZZ.ZZ9)
END-DEFINE
WRITE ‘=’ VAR-P
MOVE VAR-P TO RESULT-N
END

OUTPUT
VAR-P = 440?000

Error messages: NAT0954 Abnormal termination S0C7 during program execution.

ACLARATION: i’m new in this, sorry for the ignorance, any help it’s welcome here!, thanks for reading and for u time

A S0C7 indicates invalid data in the packed field, how did this value into the field ?

Move valid data into VAR-P and it’ll work, MOVE from P to N is the correct way.

This value is coming from file

Then the data coming from your file is NOT PACKED:

Or someone managed to store invalid data on the file. This can happen if the P field is redefined.

DEFINE DATA                      
LOCAL                            
1 VAR-P (P09)                    
1 REDEFINE VAR-P                 
  2 VAR-A (A05)                  
1 RESULT-N (N11) (EM=ZZZ,ZZZ,ZZ9)
END-DEFINE                       
MOVE 'ABCE' TO VAR-A             
MOVE VAR-P TO RESULT-N           
DISPLAY VAR-P RESULT-N           
END

This will result in SOC7.

Some things to use when the incoming data is suspect:

  • check if the field is packed with the “IF = MASK(NNNNNNNNZ)” statement and report an error if it is not (see docs: Logical Condition Criteria)
  • display the field with a hex edit mask to see the actual contents of the field (EM=H(5)) in hex

By “file”, do you mean a flat file you are reading from a CMWKFnn dataset, or a database file? I suppose in either case it is possible your DEFINE DATA doesn’t accurately reflect the actual content (yes a view of an ADABAS file can be wrong and not match the FDT). The other replies are correct as to why the error occurs, though, but my suggestion is to investigate if the source data really contains the content (column width, format, length) that the program is expecting to read.