have you already read Easytrieve Variable declaration?
For creating reports, or printing (displaying) numeric variables, we will always need masking. It can be used to print the decimal character for the variables that have implied decimal
WS-SSN W 9 N MASK '999-99-9999' ... MOVE 123456789 TO WS-SSN DISPLAY ' WS-SSN : ' WS-SSN
This will be printed as
WS-SSN : 123-45-6789
Edit mask pattern is created by using combinations of the following characters:
9 — causes a digit to print. (including leading zeros)
Z — causes a digit to print (except for leading zeros)
$ — causes a currency symbol to print prior to the first non-zero digit
more examples to come..
4 thoughts on “EDIT MASKS – Masking variables in Easytrieve”
In EZT could you edit a field to have both $ AND (-) symbol if negative value. (EX: $ – 12.00). or, is there another way?
yes, but the sign should be at the last.
DEFINE WS-AMOUNT1 W 5 N 2 MASK ‘$999.99-‘
DEFINE WS-AMOUNT2 W 5 N 2 MASK ‘$999.99-‘
JOB INPUT NULL
WS-AMOUNT1 = -12
WS-AMOUNT2 = 12
DISPLAY ‘ WS-AMOUNT1 : ‘ WS-AMOUNT1
DISPLAY ‘ WS-AMOUNT2 : ‘ WS-AMOUNT2
output of this will be:
WS-AMOUNT1 : $012.00-
WS-AMOUNT2 : $012.00
Can we use length of the field to move the data in it. To be clear, the input file is 15 bytes
first 10 is an varchar field NAME and remaining 5 is an normal alphanumeric emp id.
Data in it : 4RAJA12345
FIRST BYTE : length of the varchar data
2nd – 5th pos. : varchar data eventhough allocated size is 10 bytes, we get only 4 bytes of data
6th – 10 pos. : emp id.
This an unload file from table.
How can i move the name alone to name1 of output and emp id to empid1 of output. Is there any way i can use the length of the data received to handle this in easytrieve.
in that case, you can group variables
WS-DATA 1 10 A
WS-LEN WS-DATA 1 N
WS-NAME WS-DATA +1 4 A
WS-EID WS-DATA +5 5 N