Easytrieve: reformatting a field with the MASK parameter
search cancel

Easytrieve: reformatting a field with the MASK parameter

book

Article ID: 19730

calendar_today

Updated On:

Products

Easytrieve Report Generator

Issue/Introduction

How can Easytrieve code to unpack a packed input field, thereby displaying zero suppressed with a decimal point using the MASK statement?

 

Resolution

FILE DUMMY                                                             
DEFINE W_TEST_SSN              S  5  P 2  VALUE -23501.47             +
                                         MASK ('ZZZZZZZ.99-')         
DEFINE W_SSN_MASK              S  9  N 2  MASK ('ZZZZZZZ.99-')         
JOB INPUT NULL                                                         
W_SSN_MASK = W_TEST_SSN                                                
DISPLAY HEX W_TEST_SSN                                                 
DISPLAY W_TEST_SSN                                                     
DISPLAY W_SSN_MASK                                                     
STOP                                                                   
                                                                      
Result:                                                                
                                                                      
CHAR   & '                                                             
ZONE 02517                                                             
NUMR 0304D                                                             
    1...5                                                             
 23501.47-                                                            
 23501.47-                                                            
                                                                      
Note; if you just omit the MASK for both fields, the result will
look like:                                                             
                                                                      
CHAR   & '                                                             
ZONE 02517                                                             
NUMR 0304D                                                             
    1...5                                                             
  23,501.47-                                                          
  23,501.47-                                                          
 
MASK only applies to fields for files that are designated to be printed, where the printed file may be routed to disk. 
By default, in this sample, without MASK being specified, both              
DISPLAY W_TEST_SSN                                                      
DISPLAY W_SSN_MASK                                                      
would appear as                                                         
  23,501.47-                                                           
  23,501.47-    

 

Similarly, this should apply if printed in a REPORT.
MASK is ignored when the field is moved to a non-printer file.