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



All,

I was able to do what I needed.  Here is how I accomplished it:

C     WHFLDD        SUBST(P)  JOESD:STRPOS  HOLDFLD         
                                                            
C/EXEC SQL                                                  
C+             set :hexfld = substr(hex(:HOLDFLD),1  ,20)   
C/END-EXEC                                                  
                                                            
C     WHFLDD        SUBST(P)  HEXFLD:1      HOLDFLD         

This result doesn't have the decimal position right now. But I am close
to having that done as well.


Thanks for all the suggestions!!

Curt


message: 5
date: Wed, 31 May 2006 14:56:45 -0400
from: Barbara Morris <bmorris@xxxxxxxxxx>
subject: Re: Moving Packed Data

Curt Vancalster wrote:

We are trying to keep track of all changes that are made in our master
files.  Currently we are journaling these files (Data Mirror).  I
create
a file of all changes to a file using the DSPJRN *OUTFILE cmd.  I then
create a file using the DSPFFD *OUTFILE cmd on the file the user wants
to see what changes were made.  I use the DSPFFD file to find out how
to
substring the data that came from the DSPJRN cmd to create a "|"
delimited file.  The problem comes when some of the data from the
DSPJRN
are packed.  This is because one of the files we are journaling has a
field that is packed.

...

Curt, it sounds like you want to take a packed string like x'01234D'
with an implied say 2 decimal positions and get a string with the value
'-12.34'.  Is that correct?

If so, using LBCPYNV would be only the first step.  It would get you
'01234' (or rather, '01234M' for the negative value), but you would have
to do some more work to get it edited with the sign and decimal point. 
You could do that with the edit APIs QECCVTEC and QECEDIT; in that case,
you could stick with your packed data, and skip the extra step of
getting the zoned value.

Or, here's another way that doesn't use any APIs.  (It's not tested, so
there might be some off-by-one errors in the substrings.)

D packedView    ds               qualified
D  num                 63p 0
D zonedView     ds               qualified
D  num                 63s 0
D display       s     100a       varying
D LEN           c                63
D DECIMALS      c                31

  // get the packed data in a numeric field                         
  packedView = *allx'00';                                           
  evalr packedView = packedView + %subst(yourData : start : len);   
                                                                  
  // edit the value 
  // (this assumes no more than 31 integer or decimal places in the
packed values)
  if decpos > 0;                                                    
     display = %trim(%char(%dec(packedView.num / %inth(10 ** decpos)
                         : LEN :
DECIMALS)));                              
     // get rid of extra trailing decimal zeros            
     display = %subst(display                              
                    : 1                                    
                    : %len(display) - (DECIMALS - decpos));      
  else;                                                             
     display = %trim(%char(packedView.num));                        
  endif;



------------------------------


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.