× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.