have you already read Easytrieve Variable declaration?
In COBOL, REDEFINES verb can be used to declare variables that share a same memory location.
In Easytrieve also, there is a similar functionality.
For example, the ALPHA and NUMERIC variables given below share the same 5 bytes.
WS-ALPHA W 5 A WS-NUMERIC WS-ALPHA 5 N
Since the starting position for WS-NUMERIC is given as WS-ALPHA, both of them start from the same memory location.
In case, if you want the same functionality in a File variable,
FILE INFILE IN-REC 1 80 A IN-ALPHA 1 5 A IN-NUMERIC 1 5 N FILLER 6 75 A
Example of taking a Numeric field in WS of 6 bytes and breaking it down into 6 seperate alpha bytes please
Hi Louie,
WS-NUMERIC W 6 N
WS-DIGIT-1 WS-NUMERIC 1 N
WS-DIGIT-2 WS-NUMERIC +1 1 N
WS-DIGIT-3 WS-NUMERIC +2 1 N
WS-DIGIT-4 WS-NUMERIC +3 1 N
WS-DIGIT-5 WS-NUMERIC +4 1 N
WS-DIGIT-6 WS-NUMERIC +5 1 N
Hope this helps. You can also read https://littlecode.in/2009/10/07/easytrieve-variable-declaration/
How can i move a Packed datatype to unpacked datatype?
I want to perform this manipulation in Easytrieve
Hi Prerna,
You can move a packed number to unpacked variable by using assign statements like
WS-UNPK = WS-PACK
Please read “Moving Numeric values between variables in Easytrieve”
https://littlecode.in/2010/09/16/moving-numeric-values-between-variables-in-easytrieve/
Hi Prerna,
WS-AMOUNT-PKD W 4 P 2
WS-AMOUNT-UNPKD W 6 N 2
If you want to move the above mentioned packed to unpacked (numeric) data type variable, plz code it as below
WS-AMOUNT-UNPKD = WS-AMOUNT-PKD * 1
In EZTV packed format, the size of the field must be declared same as the total memory bytes that is stored. For example, above unpacked variable will be stored in memory as 4 bytes using the formula n/2+1. While converting packed into unpacked, care should be taken to declare a correct size with appropriate dec point.