|
>> How can I read data saved in COMP-6 format.
Iy has been a _very_ long time since I last had to code this and I don't
have access to a system right now so I can't test it - so this may not be
quite right but hopefully you'll get the idea.
You need one set of these field definitions for each different sized field
you need to process.
Working-storage section.
01 Work-Area.
* Define intermediate result field as length of Comp-6 + 1 decimal
* e.g. If original was 9(3)V9(2) this should be S9(3)V9(3).
05 Temp-result Pic S9(6)V9 Comp-3 value zero.
* Redefine field to map all _except_ last byte as char
05 Filler redefines Temp-result.
10 Comp6-AsChar Pic X(3).
10 Filler Pic X.
* Define final result with correct size/type - note no decimals
05 Final-result Pic S9(6) Comp-3.
Procedure Division.
Start-here.
* assume original contains X'123456'
Move Original-field-AsChar to Comp6-AsChar.
* Temp-result now contains X'1234560s' s = the sign nibble
Move Temp-result to Final-result.
* Final-result now contains X'0123456s' the correct value
* - the MOVE drops the decimal place!
Let me know if this works for you.
+---
| This is the COBOL/400 Mailing List!
| To submit a new message, send your mail to COBOL400-L@midrange.com.
| To subscribe to this list send email to COBOL400-L-SUB@midrange.com.
| To unsubscribe from this list send email to COBOL400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---END
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.