REFORMAT A FIELD TO MASKING

Document ID : KB000019730
Last Modified Date : 14/02/2018
Show Technical Document Details

Description:

Below shows how to unpack a packed input field, thereby displaying zero suppressed with a decimal point using the MASK statement.

Solution:

Modify a program to look as follow:


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.