TAA Tools
MOVDECCHR       MOVE DECIMAL TO CHARACTER              TAACLRF

The  Move Decimal  to  Character command  moves  a *DEC  value  (packed
data)   to   a   *CHAR  LEN(8)   variable   and   retains  the   packed
representation.   The value  is right adjusted  in the return variable.
This allows the data  to be passed to  other functions which require  a
packed representation.

MOVDECCHR  is  the inverse  function  of  MOVCHRDEC.   MOVDECCHR  would
typically  be  used when  you have  a *DEC  variable  that you  want to
place into a string as a packed value.

You cannot  concatenate a  *DEC variable  into a  string.   If you  use
CHGVAR from  *DEC to *CHAR, the  packed representation is lost  and the
data   becomes   a  character   representation   (eg   X'123F'  becomes
X'F1F2F3').

Assume you want to  create a string of  data containing a packed  field
which will  be passed to a  HLL program and  written to the  data base.
There  is no  CL function  to convert  a  packed representation  of the
data to the same length *CHAR variable.

MOVDECCHR  allows you  to create  an 8  byte character field  which you
can then substring  into to extract  the packed bytes.   The data  will
be right adjusted into the *CHAR variable.

Typical coding would be as follows:

             DCL          &DEC *DEC LEN(5 0)
             DCL          &CHROUT *CHAR LEN(8)
             DCL          &STRING *CHAR LEN(100)
              .
             MOVDECCHR    CHROUT(&CHROUT) DECINP(&DEC)
             CHGVAR       %SST(&STRING nn 3) %SST(&CHROUT 6 3)

If the  &DEC field contained  12345, the packed  decimal representation
would  be X'12345F'.  After MOVDECCHR,  the &CHROUT field would contain
X'000000000012345F'.  The  last 3 bytes  would be moved  to a  location
within the &STRING variable.

The DECINP  parameter is defined  as *DEC LEN(15  0).  This  allows for
any *DEC  variable to be input  that has 0 decimal  positions.  See the
DECINP  parameter  discussion  for  handling  variables  with   decimal
positions.

MOVDECCHR escape messages you can monitor for
---------------------------------------------

None.  Escape messages from based on functions will be re-sent.

Command parameters                                    *CMD
------------------

   CHROUT        The return  variable that  will contain the  converted
                 value.    The  variable  must  be  declared  as  *CHAR
                 LEN(8).    The  packed  representation  will  be right
                 adjusted.

   DECINP        The decimal input value  to be converted.  It  must be
                 a *DEC  variable of up  to 15 digits with  0 decimals.

                 You  can  handle decimal  variables that  have  one or
                 more decimal positions by  multiplying.  For  example,
                 if you  want to  have a *DEC  LEN(13 3)  variable, you
                 could  multiply the existing  value by  1000 and place
                 the result  in a  *DEC LEN(13  0) variable.   The  new
                 variable   could   be   specified   for   the   DECINP
                 parameter.

Restrictions
------------

Because the  command returns a  CL variable, it  may only be  used in a
CL program.

Prerequisites
-------------

None.

Implementation
--------------

None, the tool is ready to use.

Objects used by the tool
------------------------

   Object        Type    Attribute      Src member    Src file
   ------        ----    ---------      ----------    ----------

   MOVDECCHR     *CMD                   TAACLRF       QATTCMD
   TAACLRFR      *PGM       RPG         TAACLRFR      QATTRPG
					

Added to TAA Productivity tools September 1, 2004


Home Page Up to Top