When you want to move a value from one Numeric/Packed/Binary variable to another Numeric/Packed (COMP-3) /Binary (COMP) variable, never use the MOVE verb. Just use the assignment statement using “=” (equal) symbol.
This is because, MOVE will work fine, if the hexadecimally stored values are compatible. (ie, Numeric to Numeric, Packed to Packed, or Binary to Binary). Other cases, you will see unwanted values.
Instead of facing such issues, just use the simple assignment statements.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- LIST ON FILE INFILE WS-NUERIC W 9 N VALUE 5 WS-BINARY W 4 B WS-PACKED W 5 P 0 * JOB INPUT NULL * PRINT 5 DISPLAY WS-NUMERIC * ASSIGN IT TO WS-BINARY WS-BINARY = WS-NUMERIC DISPLAY WS-BINARY * ASSIGN IT TO WS-PACKED WS-PACKED = WS-BINARY DISPLAY WS-PACKED STOP.
|Numeric to Packed, Binary||WS-BINARY = WS-NUMERIC
WS-PACKED = WS-NUMERIC
|Binary to Numeric, Packed||WS-NUMERIC = WS-BINARY
WS-PACKED = WS-BINARY
|Packed to Binary, Numeric||WS-NUMERIC = WS-PACKED
WS-BINARY = WS-PACKED
If you want to move a value from Packed to Alpha,
first move the packed to a Numeric variable, then move the Numeric variable to an Alpha variable.
WS-NUMERIC = WS-PACKED MOVE WS-NUMERIC TO WS-ALPHA
Similarly, if you want to move from Binary to Alpha,
WS-NUMERIC = WS-BINARY MOVE WS-NUMERIC TO WS-ALPHA
Learn more about Easytrieve variable declaration.
- Easytrieve – check if value IS NUMERIC in an alpha variable
- Easytrieve program to parse a string
- simple and nested IF-ELSE-ENDIF statement in Easytrieve
- Comments in Easytrieve (start with *)
- Easytrieve Error messages A0** and B0**
- SYSDATE and SYSTIME in Easytrieve
- JOB statement with START and FINISH procs in Easytrieve
- PROC (perform paragraph) in Easytrieve
- GOTO statement in Easytrieve
- SORT in Easytrieve