× 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.



Scott,

Nothing in you email is new to me, but thank you for the time and effort
you put into your reply.

Apparently I did a poor job of getting across what I wanted to do.

Consider the following example:

     D myNumFld        s             10p0  

     D myDS            DS                  qualified
     D                                9a   inz('Value is:')
     D  myCharFld                    10a   

     C                   eval      myDs.myCharFld =
%edtcde(myNumFld:'X')


What I'd like to be able to do is the following:

     D myNumFld        s             10p0  

     D myDS            DS                  qualified
     D                                9a   inz('Value is:')
     D  myCharFld
like(%size(%edtcde(myNumFld:'X'))

     C                   eval      myDs.myCharFld =
%edtcde(myNumFld:'X')


I'd agree that EVAL and BIFS are the better solution.  But I'm still
wondering if there's any way to do what I'm asking.

Thanks,

Charles Wilt
--
iSeries Systems Administrator / Developer
Mitsubishi Electric Automotive America
ph: 513-573-4343
fax: 513-398-1121
  

> -----Original Message-----
> From: rpg400-l-bounces@xxxxxxxxxxxx 
> [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
> Sent: Wednesday, April 19, 2006 12:47 PM
> To: RPG programming on the AS400 / iSeries
> Subject: Re: Easy way to define a DS char subfield the same 
> size as somenumeric field?
> 
> > I've got a standalone field defined as packed(3,0).
> > Is there an easy way to define a DS subfiled as char(3)?
> 
> That would be CHAR(2), actually.  Packed fields are always digits+1/2 
> bytes long.  In this case, 2 bytes.
> 
> 
> > 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?
> 
>       D char            ds
>       D   packed                       3P 0
> 
> or
> 
>       D                 ds
>       D   char
>       D   packed                       3P 0 overlay(char)
> 
> In either case, the character field is automatically created 
> as 2 bytes 
> long, and you don't have to hard code the size.
> 
> > The DS is used to send out an email message.
> 
> It would NOT make sense to do this in an E-mail message.  
> E-mail messages 
> are text-only, so you'd want to convert the number to 
> human-readable form.
> 
> For example, if you had the packed value -123, this would be 
> stored in 
> memory in a packed field as x'123D'.  That means that your 2 
> character 
> field would be made up of 2 unprintable control characters.  
> You wouldn't 
> want to put that in an e-mail message!
> 
> So I'm thinking to myself, "maybe he meant zoned decimal instead of 
> packed?".  OKay, in that case you'd define it this way:
> 
>       D                 ds
>       D   char
>       D   zoned                        3S 0 overlay(char)
> 
> That'd be closer.  For example, if the zoned field had a 
> value of 19, it'd 
> be stored in memory as x'F0F1F9'.  If you tried to view it as 
> text, it'd 
> be 019 which at least would be printable!  However, it does have that 
> annoying leading zero.   Now consider what happens if you make it a 
> negative number, such as -123.  the bytes are set to x'F1F2D3', which 
> would appear on the screen as 12L, since x'D3' is the EBCDIC letter L.
> 
> Truly, you do NOT want to use a data structure for this.  A 
> data structure 
> just overlays two fields so that they have the same hex byte 
> values.  In 
> reality, you want to convert from the numeric field to a 
> human-readable, 
> nicely formatted, character field.  Not just copy the bytes 
> from one to 
> the other!
> 
> > If there isn't an easy way to do what I want, I'll just get 
> rid of the 
> > DS altogether and use eval + some bifs to build the message.
> 
> That's a MUCH MUCH MUCH better idea.  EVAL and BIFs will make 
> this much 
> easier to write, and using %char() or %editc() you can format 
> the number 
> any way you want.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.