|
Hello Brad, RTFM :) Make it 5,0 as in five integer digits = 2 bytes. For example D DS D MHDATA 31002 D MHDATALen 5I 0 OVERLAY(MHDATA) D MHDATAText 31000 OVERLAY(MHDATA:3) Avoid From and To coding in RPG IV unless you have a REALLY good reason. The problem is not the allocated size of storage (the 2 bytes) but RPG's peculiar interpretation of binary -- which admittedly is consistent with the database's view of binary data types. Defining the field as binary puts the sign in the left-most bit instead of the right-most (for packed) or the high 4-bits of the right-most byte (for zoned). RPG allocates 2-bytes for binary fields with 1 to 4 digits and 4 bytes for binary fields with 5 to 9 digits. RPG limits 2-byte binary numbers to a maximum value of 9999 instead of the expected 32767 (for signed and 65535 for unsigned). It limits 4-byte binary numbers to 999,999,999 instead of the expected 2,147,483,647 (and 4,294,967,295). RPG behaves this way because it using decimal numbers internally and assigns a length of 4 to 2-byte binary numbers and a length of 9 to 4-byte binary numbers regardless of the actual amount of storage used thus truncation of the most significant digit can occur. This makes using real integer fields such as those in the file feedback area, API parameters, and VARCHAR structures much harder than it needs to be. The major difference between Binary and Integer data types is that Binary fields can support a decimal point. This is, of course, all described in the RPG Programmer's Reference under Numeric Data Type. In most cases with RPG IV replace all Binary definitions with Integer definitions and life with be much simpler for you. Regards, Simon Coulter. «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«» «» FlyByNight Software AS/400 Technical Specialists «» «» Eclipse the competition - run your business on an IBM AS/400. «» «» «» «» Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 «» «» Fax: +61 3 9419 0175 mailto: shc@flybynight.com.au «» «» «» «» Windoze should not be open at Warp speed. «» «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«» //--- forwarded letter ------------------------------------------------------- > X-Mailer: Internet Mail Service (5.5.2448.0) > Date: Tue, 18 May 99 08:09:32 -0500 > From: "Stone, Brad V (TC)" <bvstone@taylorcorp.com> > To: "'shc@flybynight.com.au'" <shc@flybynight.com.au> > Subject: RE: VARLEN field... what good are they? > > Simon, > > Thanks for the tips. When I declare the field as integer, what size can I > make it? If the field is 2 binary, how can it be any larger? > > The %trim(%len(xx)) was a typo... sorry. > > > Bradley V. Stone > Taylor Corporation - OASIS Programmer/Analyst > bvstone@taylorcorp.com +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-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-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.