TAA Tools

 EDTVAR       EDIT VARIABLE                     TAACLPC

 The EDTVAR  command is designed  to allow numeric  values to be  edited
 within a  CL program.  This  allows the values to  appear more readable
 in messages and other functions.

 For  example, assume you  have a count  field within a  CL program that
 should be displayed in an  impromptu message.  The field must  first be
 converted to a character field and is then normally displayed as:

          0003127 records read

 The EDTVAR command:

   **   Converts the decimal value to character

   **   Performs editing based on an edit code (the default is J)

   **   Provides for an optional leading currency symbol

 The typical command usage would appear as:

         DCL        &WORK22 *CHAR LEN(22)
         DCL        &COUNT *DEC LEN(5 0)
          .
          .
         CHGVAR     &COUNT (&COUNT + 1)
          .
          .
                    /* When count is complete */
         EDTVAR     CHROUT(&WORK22) NUMINP(&COUNT)
         SNDPGMMSG  MSG(&WORK22 ' records read')

 The CHROUT  variable must be  defined as *CHAR  LEN(22).  The  value is
 left  adjusted into the variable.  To  trim off the trailing blanks you
 need *TCAT.  The message would read:

          3,127 records read

 EDTVAR  supports  an  EDTCDE  parameter  which  defaults  to  J.    The
 standard edit code values  of 1 2 3 4 A B C  D J K L M N O P  Q Y and Z
 are supported.   'W' is also supported as a  time value edit with colon
 separators (e.g.  8:00:00).

 For edit codes J K  L M, a minus sign  will always appear to the  right
 if the variable is negative.

 For edit  codes A  B C D,  the 'CR'  symbol will  always appear to  the
 right  if the variable  is negative.   The number of  decimal positions
 is specified by the NBRDEC

 For  edit codes N  O P Q, a  minus sign will always  appear to the left
 if the variable is negative.

 The number of  decimal positions is  specified by the NBRDEC  parameter
 and not the definition of the field within the program.

 Editing occurs  as per the QDECFMT  and QCURSYM system values  plus the
 addition of the 'W' edit code.

 There are a few rules when using EDTVAR:

   **   The  numeric   input  field  must  be  defined  with  0  decimal
        positions.   The  length  of the  field  can  be from  1  to  15
        digits.   The number of decimal  positions in the  edited answer
        is  controlled by  the NBRDEC parameter.   If  you are  adding a
        field which  has decimal  positions,  you must  change it  to  a
        zero decimal field.   For example, if you have  a variable which
        is defined  with 2 decimal positions, you  would have to convert
        it by multiplying by 100 such as:

                 DCL      &AMT2    *DEC LEN(7 2)
                 DCL      &AMT0    *DEC LEN(7 0)
                 DCL      &WORK22  *CHAR LEN(22)
                  .
                  .
                 CHGVAR   &AMT0 (&AMT2 * 100) /* Treat as 0 decimals */
                  .
                  .
                 EDTVAR   CHROUT(&WORK22) NUMINP(&AMT0) NBRDEC(2)

   **   The  NBRDEC  parameter will  insert  the decimal  symbol  in the
        answer.

   **   The character  output  field  must be  defined  as 22  bytes  in
        length.    This allows  for  the  largest  decimal value  to  be
        edited.

   **   The  Edit Codes W,  Y and Z  require the NBRDEC  parameter to be
        0.

 The output field  is always left  adjusted.  When  used with  messages,
 you  will normally  want to  trim the  trailing blanks  off the  output
 field by use of either the *TCAT or *BCAT concatenation operator.

 The  Y edit  code is  not sensitive  to  the format  of the  date (e.g.
 MMDDYY).  It  just strips  off the leading  zero (if  any) and  inserts
 the separator  character.  A  7 digit date  (CYYMMDD) is valid  to edit
 with the Y edit code.

 Differences with other editing tools
 ------------------------------------

   **   The  EDTVAR2  tool  provides  for  editing from  within  an  RPG
        program  when you cannot  or do not  want to use  the RPG output
        specs.  Digit sizes up to 15 digits are supported.

   **   The EDTVAR3  tool provides  the  same function  as EDTVAR2,  but
        allows for 30 digit field sizes.

   **   The ZEDIT tool  is documentation only and includes  the RPG code
        to be  used as a subroutine to strip  off the leading zeros of a
        field.

 Using the CPP directly
 ----------------------

 The following sample RPG code may be used to call the CPP directly.

      C* Your code to set the parameters such as:
      C                     Z-ADD38715     NUMVAR
      C                     Z-ADD2         NBRDEC
      C                     MOVE 'J'       EDTCDE
      C                     MOVE '*NO '    LDGSYM
      C* Call EDTVAR TAA Tool using CPP
      C*   The value is returned in the CHAR22 field name
      C                     CALL 'TAACLPCC'
      C                     PARM           CHAR22 22
      C                     PARM           NUMVAR 150
      C                     PARM           NBRDEC  10
      C                     PARM           EDTCDE  1
      C                     PARM           LDGSYM  4

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

    CHROUT        Character  output.    It  must  be  defined  as  *CHAR
                  LEN(22).  This  is the largest possible  output if the
                  input  is  15 digits  and all  editing  characters are
                  inserted.  The output is left adjusted.

    NUMINP        Numeric input.   It  must be  defined as  *DEC  LEN(nn
                  0).   Any length  up to  15 digits  can be  converted,
                  but the number of decimal positions must be 0.

    NBRDEC        Number  of decimals.   Default  of  0.   This controls
                  where  the decimal symbol will  appear.  The number of
                  decimal positions  in the  input field  must be  zero.
                  If  not, the  positions to  the right  of  the decimal
                  are  truncated.  This value must  be zero for the edit
                  codes of W, Y or Z.

    EDTCDE        The Edit Code to be  used.  The values 1  2 3 4 A B  C
                  D J K L  M N O P Q  W Y and Z are allowed.   W is used
                  for  colon separators on time  values (e.g.  8:10:05).
                  The other values  have primarily  the same  definition
                  as the  system  supplied values.   J  is the  default.
                  The  W, Y  and  Z values  may only  be  specified with
                  NBRDEC(0).    If  you  are  using  EDTVAR  for message
                  text, you  should  avoid the  edit  codes that  return
                  zero balances as all blanks.

    LDGSYM        Leading  currency  symbol.    Default of  *NO.    This
                  allows  a   leading  currency  symbol  (based  on  the
                  QCURSYM system value).

 TAACLPCC2 Program
 -----------------

 Because the  EDTVAR  command  is  used frequently,  a  sub  program  is
 provided  which is  specified as  CHGPGM USEADPAUT(*NO).   This  allows
 you  to  use EDTVAR  in  a  CL program  that  adopts  authority without
 concern for library list security implications.

 Only two parameters are supported.  You should specify the CALL as:

          CALL    PGM(TAATOOL/TAACLPCC2) PARM(&CHROUT &NUMINP)

   **   The &CHROUT value must be declared as *CHAR LEN(22).

   **   The &NUMINP value must be declared as *DEC LEN(15 0).

 The two  parameters  are passed  to  the  EDTVAR command.    The  other
 parameters on EDTVAR use the defaults.

 If  you  have any  other  requirements,  you  need to  write  your  own
 sub-program.

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

 None

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

 The following TAA Tools must be on your system:

          SNDESCMSG       Send escape message

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

 None, the tool is ready to use.

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

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

    EDTVAR        *CMD                      TAACLPC        QATTCMD
    TAACLPCC      *PGM          CLP         TAACLPCC       QATTCL
    TAACLPCC2     *PGM          CLP         TAACLPCC2      QATTCL

Added to TAA Productivity Tools April 1, 1995


Home Page

Last modified on November 19, 2014 © 1995, 2014 - TAA Tools, Inc.