|
>> How the can I read unsigned packed decimal data. Is there any special
>> data type in RPG to handle this type of data.
Simple answer No. Complicated answer ....
Amazingly enough when I read this note I had literally just finshed coding
an example of how to do this in COBOL!! Here is the same thing in RPG IV -
untested 'cos I have no AS/400 here right now.
You need one of these sets of field definitions for each size/shape of
unsigned value you are processing. The secret lies in treating it as
character when defining it on the file (or however you receive it).
Here's the code - let me know if it works for you.
D WorkArea Ds
* Define intermediate result as length of original + 1 decimal
* e.g. If original was 5 long with 2 decimal this should be 6P 3
D TempResult 6P 3 Inz
* Redefine field to map all _except_ last byte as char
D UnsPkAsChar 3a Overlay(TempResult)
* Define final result with correct size/type
D FinalResult 5P 2
* assume original contains X'123456'
C Move OrigFldAsChar UnsPkAsChar
* Temp-result now contains X'1234560s' s = the sign nibble
C Eval FinalResult = TempResult
* Final-result now contains X'0123456s' the correct value
* - the Eval drops extra the decimal place!
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
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.