Hi Thomas,
When you write code that reads directly into a data structure, the 
system does a block copy from the record buffer to the program.  Since 
this block copy doesn't look at the individual field definitions, it 
won't produce a decimal data error.
You could then interrogate each field one-by-one to determine which (if 
any) produce an error.  If you decide to try this, I definitely suggest 
moving the read logic into a subprocedure -- it'd be too cumbersome to 
put in-line with the rest of your code.
For example:
     FMYFILE    IF   E           K DISK
     D Record_t        ds                  likerec(MYRECFMT:*INPUT)
         .
         .
     P ReadMyfile      B
     D ReadMyfile      PI             1n
     D    Rec                              likeds(Record_t)
     D Temp            ds                  likeds(Record_t)
      /free
        read MYFILE Temp;
        if %eof;
           return *OFF;
        endif;
        monitor;
          Rec.Field1 = Temp.Field1;
        on-error;
          LogError('Decimal data error in Field1');
          Rec.Field1 = 0;
        endmon;
        monitor;
          Rec.Field2 = Temp.Field2;
        on-error;
          LogError('Decimal data error in Field2');
          Rec.Field2 = 0;
        endmon;
        monitor;
          Rec.Field3 = Temp.Field3;
        on-error;
          LogError('Decimal data error in Field3');
          Rec.Field3 = 0;
        endmon;
        return *ON;
      /end-free
     P                 E
This code is off the top of my head, and I haven't compiled or tested 
it, so I may have made a mistake somewhere.  But hopefully you get the 
idea.
With that procedure in place, you'd simply call
       ReadMyFile( MyRec );
when you want to read a record.  Any fields with decimal data errors 
would be logged (you'd have to write a LogError() procedure to do that) 
and the log would tell you the exact field name (though, you'd probably 
want to add more info to identify the actual record, as well) then the 
values converted to zero.
Hope that helps.
Thomas Garvey wrote:
Hi,
Has anyone had any experience handling decimal data errors at the field
level?  I know you can trap for the decimal data error that happens when a
record is read that contains a decimal data error in one of the field
values, and I know you can set the FIXNBR parameter on the RPG compile to
automatically fix numeric values that are bad.  But I want to know which
specific field(s) in the record were bad.  It's OK that the compiler will
fix them for me, but I want to know which field(s) in the record were fixed.
Any ideas?
Best Regards,
 
Thomas Garvey
630-462-3991
As an Amazon Associate we earn from qualifying purchases.