|
"Wilt, Charles" wrote: > > I've got a standalone field defined as packed(3,0). > > Is there an easy way to define a DS subfiled as char(3)? > > In other words, given any specific numeric field, how can a define a > corresponding character field large enough to hold the numeric data > without having to hardcode the subfield size? > It's possible, but kind of kludgy. Instead of defining the field directly, you define it by overlaying an 1-byte array whose dimension is the size you want. D msgDs ds D numChar D numCharA 1a dim(%len(num)) D overlay(numChar) numChar = %editc(num : 'X') If you might need a sign and/or decimal point, D msgDs ds D numChar D numCharA 1a dim(%len(num)) D overlay(numChar) D 2a overlay(numChar:*next) numChar = %char(num) (In the case of a message, you'd probably want to use concatenation rather than a data structure; otherwise it wouldn't look nice with a small value. "There are 2 pieces of pie")
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.