Supress zeros when writing to work file

I am not able to use ED ( Edit mask) and use it with WRITE WORK and suppress zeros in XXXX-N-SIZE field.

What are we doing?
We are trying to convert ADABAS data to DB2 format data and then verify if all data has been migrated. We are able to convert ADABAS to DB2 and load the data in DB2. Now I am trying to verify all the data. I have have 2 datasets ADABAS datasets has data from ADABAS using WRITE command. second dataset has data from DB2 tables. My plan is to be able to a comparison of both files using Super C in mainframe.

But DB2 data does not have zeros padded before numeric filed but ADABAS data has zeros padded before numeric field. I want to fix this by either suppress zeros in ADABAS file or add zeros in DB2 file.

I am not able to do this , can anyone please suggest/guide/advice ?


 01 DDM-VIEW VIEW OF XXXXA      
   02 XXXX-C-SSSSSS /* (A1)     
   02 XXXX-N-TABLE /* (A4)      
   02 XXXX-N-SEQ /* (A3)        
   02 XXXX-D-UPDATE /* (A6)     
   02 XXXX-N-TIME /* (A5)       
   02 XXXX-N-SIZE /* (N4)    

 01 DB2-XXXXA                              
   02 ISN          (N10)                   
   02 XXXX_C_SSSSSS (A1)                   
   02 XXXX_N_TABLE (A4)                    
   02 XXXX_N_SEQ (A3)                      
   02 XXXX_D_UPDATE (A6)                   
   02 XXXX_N_TIME (A5)                     
   02 XXXX_N_SIZE (A5)  /* N4 + SIGN       
   02 XXXX_S_KEY (A8) /* SUPER-DESCRIPTOR  

  MOVE EDITED DDM-VIEW.XXXX-N-SIZE (EM=-9999)   
    TO DB2-XXXXA.XXXX_N_SIZE                    

  WRITE WORK 1             
  DDM-VIEW.XXXX-C-SSSSSS   
  DDM-VIEW.XXXX-N-TABLE    
  DDM-VIEW.XXXX-N-SEQ      
  DDM-VIEW.XXXX-D-UPDATE   
  DDM-VIEW.XXXX-N-TIME     
  DDM-VIEW.XXXX-N-SIZE     

BROWSE    STAGING.ADABAS                  
 Command ===>                                                  
 004400191080109:220399  <---  ZERO is added before 399   size field                                                    
 005700291090207:130399                                                         
 004700191080109:261224                                                         

BROWSE   .STAGING.DB2                    
 Command ===>                                                
 004400191080109:22399  <-- zero is not added before 399  size field                                                      
 005700291090207:13399                                                          
 004700191080109:261224                                                         
                                                         
            

in DB2 field XXXX_N_SIZE is SMALLINT 2

You cannot suppress the leading zeros in a numeric field when writing it to a workfile. You will have to create an alpha field to hold it and write that to the workfile.

In your define data, add:
1 HOLD-XXXX-N-SIZE (A5)

Before the WRITE WORK 1 at line 22, add:
MOVE LEFT DDM-VIEW.XXXX-N-SIZE TO HOLD-XXXX-N-SIZE

In the WRITE WORK 1 statement, replace DDM-VIEW.XXXX-N-SIZE with HOLD-XXXX-N-SIZE.

Good luck!

1 Like

Thanks a TON Jerome , it worked!!

Ashish

Hi Ashish;

I know you have solved your current problem, but something to consider for the future.

Suppose, instead of N4, you moved the value to an I2 variable, then used that variable when writing to the work file?

This should work (haven’t tried it as yet).