RGTADJVAR       RIGHT ADJUST VARIABLE                  TAACLTD

 The Right Adjust Variable command  takes a value such as '23      ' and
 adjusts  it  to  '       23'.    RGTADJVAR  is  intended for  character
 variables  that  contain decimal  values.   Both character  and decimal
 return variables are  supported.  A  value such as '-23,112.38    '  is
 also  valid.   Options exist  to  determine if  special characters  are
 valid.

 See the ADJVAR tool for adjusting character values.

 The following is typical code:

              DCL        &INPUT *CHAR LEN(22)
              DCL        &OUTDEC *DEC LEN(15 0)
               .
              RGTADJVAR  INPUT(&INPUT) OUTDEC(&OUTDEC)

 If the  INPUT value was '123,456.78        ', the OUTDEC value would be
 '     12345678' as  the decimal format  and separator characters  would
 be ignored.

 An OUTCHR  return variable  is also  available and  would return  '
 123456.78'.   This  value could be  moved to  a *DEC LEN(9  2) variable
 for further processing.

 Rules
 -----

   **   The INPUT variable  may be up  to 22 characters  in length,  but
        may not exceed 15 digits.

   **   The OUTDEC variable must be *DEC LEN(15 0).

   **   The OUTCHR variable must  be *CHAR LEN(17).  This  allows for 15
        digits, a decimal format character, and a minus sign.

   **   Decimal  and separator characters  are determined by  the DECFMT
        of  the job such  as USA=blank means  a decimal format character
        of '.' and a separator character of ','.

   **   A minus sign must precede or  follow the value such as '-12    '
        or '12-  '.

   **   A  'CR' symbol  may exist  to the  immediate right  of  the data
        such  as '123CR     ' if  ALWCR(*YES) is  specified.   The value
        will be treated as negative.

   **   A decimal format character must be to the left of a digit.

   **   A list  of up  to  10 characters  may be  entered that  will  be
        bypassed.  This is intended for money symbols such as '$'.

   **   The  code  checks  for   invalid  characters,  multiple  decimal
        format  characters,  and multiple  minus  signs.   If  separator
        characters are valid  by ALWSEP(*YES),  any separator  character
        found is ignored.

   **   Blanks may  not appear to  the left of  a digit such  as '    12
        '.

 RGTADJVAR escape messages you can monitor for
 ---------------------------------------------

       CPF9898    Invalid input.  Text describes the error

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

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

    INPUT         The  input  value to  be  right adjusted.    Up to  22
                  bytes  may  exist.   The data  must be  left justified
                  such as '123     '.

    ALWMINUS      A *YES/*NO value  for whether a  minus sign should  be
                  considered a  valid value.   *YES is the default.   No
                  error  occurs if a  minus sign  does not exist.   If a
                  minus exists, the  OUTCHR field  with have a  trailing
                  minus and the OUTDEC field will be negative.

                  *NO may  be specified  to cause  an error  if a  minus
                  sign exists.

    ALWDEC        A   *YES/*NO  value  for  whether   a  decimal  format
                  character (such as '.')  should be considered a  valid
                  value.   *YES is the  default.  No  error occurs if  a
                  decimal format character does not exist.

                  *NO may  be specified to  cause an error  if a decimal
                  format character exists.

    ALWSEP        A  *YES/*NO  value  for  whether  a  separator  format
                  character (such as  ',') should be considered  a valid
                  value.   *YES is  the default.   No error occurs  if a
                  separator format character does not exist.

                  *NO   may  be  specified  to  cause   an  error  if  a
                  separator format character exists.

    ALWCR         A *YES/*NO value for whether  a 'CR' symbol may  exist
                  to the right of  the digits such as '123CR     '.  *NO
                  is  the  default.    If  a  CR  value  exists,  it  is
                  considered an error.

                  *YES may  be  specified  to allow  the  CR  symbol  to
                  exist  and  if   it  does,  the  data   is  considered
                  negative.   No  error  occurs if  a CR  symbol  is not
                  found.

    BYPCHRLST     A  list of  up to  10 characters  may be  entered that
                  will be bypassed  such as '$'.   The default is  *NONE
                  meaning   any   non-recognized   character   will   be
                  considered an error.

                  This  is primarily intended  for a  money value symbol
                  (could be 2 characters), but  could be used to  bypass
                  a string of characters  such as 'US$123.45      ' Just
                  enter   the   list   as   a   character  value   (case
                  sensitive).

    OUTDEC        The  adjusted  return  decimal  value.    This  is  an
                  optional  return  variable   that  if  used   must  be
                  specified as *DEC LEN(15 0).

    OUTCHR        The  adjusted  return  decimal  value in  a  character
                  field.   This is  an optional return  variable that if
                  used must  be specified  as  *CHAR LEN(17).   This  is
                  large  enough   to  contain   15  digits,   a  decimal
                  separator character and a trailing minus sign.

                  The  major intent of  this field is that  if the INPUT
                  data has a  number of  decimal positions,  the use  of
                  OUTDEC  will  ignore  the  decimal  positions  as  the
                  return  field must  be *DEC LEN(15  0).   Using OUTCHR
                  allows a  following CHGVAR  command to  move the  data
                  to a  variable  declared with  decimal positions  such
                  as *DEC LEN(9 2).


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

 Because RGTADJVAR  returns variables, the  command may only  be used in
 a CL program.

 See  the previous comments about the rules  for valid input and how the
 output is formatted.

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

 The following TAA Tools must be on your system:

      RTVVALA         Retrieve value attributes
      SNDESCINF       Send escape information
      SNDESCMSG       Send escape message

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

 None, the tool is ready to use.

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

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

    RGTADJVAR     *CMD                   TAACLTD       QATTCMD
    TAACLTDC      *PGM       CLP         TAACLTDC      QATTCL

Added to TAA Productivity Tools October 15, 2008


Home Page

Powered by AS/400Powered by AS/400 Last modified on October 10, 2008 © 1995, 2008 - Jim Sloan, Inc.