TAA Tools
EDTVAR2         EDIT VARIABLE 2                        TAACLQM

The Edit Variable 2  tool provides more function than  the EDTVAR tool.
Both  tools  provide  edited values  by  using  an  Edit  Code such  as
specified in RPG.

EDTVAR2 is intended to be used as:

      - A command in a CL program
      - A sub program that can be called
      - A subroutine within an RPG program

A typical use as a command would be:

             DCL       &RTNVAL *CHAR LEN(22)
             EDTVAR2   DECINP(&xx) RTNVAL(&RTNVAL) EDTCDE(1) +

The  DECINP parameter must  be a *DEC type  field.  It can  be up to 15
bytes long, but must have  0 decimals.  The DECPOS  parameter describes
the  number  of decimal  positions  that  should  exist in  the  return

The  return  value must  be  specified as  *CHAR LEN(22).    The edited
value is returned  left adjusted  by default.   Other parameters  allow
you to specify the editing symbols.

An additional  edit code  of W  is supported  to allow  for editing  of
time fields (such as 10:15:00).

When a  date or time field  is used as the  DECINP value, the DATTIMLEN
parameter must describe  a length between  3 and 9 digits.   If  excess
non-zero data exists, an error message is sent.

Using the  EDTVAR2 function as  a CALL or  an RPG subroutine  is useful
if you need  to edit values, but cannot (or prefer  not to) use the RPG
Output  specifications.  See  the later sections on  how to use EDTVAR2
as a sub program or a subroutine.

Differences with other editing tools

  **   The EDTVAR  tool  provides a  command interface  for  use in  CL

  **   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

Demonstration command

A  demonstration command  is  available to  allow you  to  see how  the
functions will perform on various parameters.


A display  file will appear and  you can enter various  values.  F6 may
used to  access  the DSPEDTCDE  display  to help  determine  the  valid
values and what the result should be.

Command parameters                                    *CMD

   DECINP        The data to  be edited.   It must be a  decimal field.
                 It may  be up to 15  bytes in length, but  must have 0
                 decimals.  It may be a negative value.

                 Note  that  if you  call  the CPP  directly,  you must
                 pass a *DEC  LEN(15 0) field  (it cannot be  shorter).

   RTNVAL        The  edited  value  to   be  returned.    It  must  be
                 specified  as  *CHAR  LEN(22).    The  value  is  left
                 adjusted by default.

   EDTCDE        The edit code  to be  used.   The default is  Z.   The
                 RPG  edit codes  (1,2,3,4,A,B,C,D,J,K,L,M,N,O,P,Q  and
                 X,Y,Z)  are supported.   Also supported is  W which is
                 intended for time  field editing  (such as  10:15:00).

   DECPOS        The number of  decimal positions in the  edited value.
                 The default  is 0.   If W, Y,  or Z is  specified, the
                 number of decimal positions must be 0.

   DATTIMLEN     The  length of a  date or time field.   The default is
                 6.  This value  is only used for  a W or Y  edit code.

                 If excess  non-zero values exist, an  error message is
                 sent.    For  example,  if  1234567  is  passed to  be
                 edited   with   DATTIMLEN(6),   an   excess   non-zero
                 character exists and an error message is sent.

   RIGHTADJ      A  *YES/*NO value  for  whether  to right  adjust  the
                 edited  value.    The  default  is  *NO  meaning  left
                 adjust.  *YES causes the  value to be right  adjusted.

   DECSYM        The character to  be used as  a decimal point.   A '.'
                 is the default.

   SEPSYM        The character  to be used as the  separator symbol.  A
                 ',' is the default.

   DATSYM        The  character  to  be  used  as  the  date  separator
                 symbol.  A  '/' is  the default.   This value is  only
                 used with the Y edit code.

   TIMSYM        The  character  to  be  used  as  the  time  separator
                 symbol.   A ':'  is the  default.  This  value is only
                 used with the W edit code.

   SETLR         The setting  of  LR when  the RPG  processing  program
                 returns.  The  default is *ON meaning  the RPG program
                 is closed each time it returns.

                 *OFF  may be  specified to keep  the RPG  program open
                 when it  returns.   This  is  appropriate if  you  are
                 going to make repeated use of the EDTVAR2 command.

                 *ONIMMED may  be specified  if you  want to close  the
                 RPG  program  without  performing  any editing.    The
                 intent  of *ONIMMED  is if  you have  kept the program
                 open for repeated  editing and now  want to close  the

Using the EDTVAR2 functions as a sub program (TAACLQMR)

An  externally described  data structure  is provided  to allow  you to
define  most  of the  fields  to be  passed to  the  EDTVAR2 processing
program.  At  a minimum, you  must move the  data to  be edited to  the
DECINP field  before calling the TAACLQMR  program.  The  edited output
field  is returned in the  ZEOUT field which  is the first  22 bytes of
the data structure.

Typical RPG code would look like:

     I* EDTVAR2 TAA Tool DS for editing a decimal field
     C*                                                              *
     C*   The following code is for the TAA Productivity Tools       *
     C*     EDTVAR2 Tool.  TAACLQMR edits a 15,0 field named DECINP  *
     C*     The EDTDS parameter is for the externally described      *
     C*     data structure TAACLQMP to pass options such as the      *
     C*     edit code, decimal symbol, etc.                          *
     C*     ZEOUT is the return field with the edited value.         *
     C*                                                              *
     C                     MOVE 'x'       ZEEDTC           Edit code
     C                     MOVE xxx       DECINP           Dec input
     C                     CALL 'TAACLQMR'                 Entry
     C                     PARM           DECINP 150       Decimal inpt
     C                     PARM           EDTDS            Ext descrbed
     C                     MOVELZEOUT     xxx              Output field

Note that  you must  pass a  15 digit  0 decimal  field  as the  DECINP

You  may optionally  move values  to  the other  ZEnnn  fields such  as
ZEEDTC  and  ZEDECP before  calling  the program  to  specify the  edit
code, number of decimal positions, etc.

A  sample use  of the code  exists in the  TAACLQMR4 RPG  member in the
TAA Archive.   You may access  the source by first  using CPYTAA.   The
typical  solution would be  to copy  the source  to QATTRPG  in TAATOOL
where it could then be copied into any program.

TAACLQMR4  is a working  program, but has  no function other  than as a
test vehicle.   If you  call the  program, a display  will appear  with
the edited value.  Use F3 to end the program.

The  following fields  exist  in the  data  structure  (all fields  are

     Field name    Length    if blank     Description
     ----------    ------    --------     -----------

      ZEOUT         22                    Edited return value
      ZEEDTC         1          Z         Edit code
      ZEDECP         1          0         Decimal positions
      ZEDTLN         1          6         Date/time length
      ZEADJR         1          b         Right adjust (b or R)
      ZEDECS         1          .         Decimal symbol
      ZESEPS         1          ,         Decimal separator
      ZEDATS         1          /         Date separator symbol
      ZETIMS         1          :         Time separator symbol
      ZESTLR         8          *ON       Set LR
      ZERSVD        62                    Reserved

Using the EDTVAR2 function as an RPG subroutine

The intent  of the EDTVAR2 function as a  subroutine is if your program
needs to edit thousands  of times and  the Call to  the sub program  is
too inefficient.

Calling a sub  program is not  significant overhead if you  return with
LR off.   You do  not need to  consider the subroutine  approach unless
you are doing a large amount of editing.

The  TAACLQMR3 source in the TAA Archive can  be copied out to a member
using CPYTAA  such as to  file QATTRPG in  TAATOOL.   You may then  use
the  SEU  browse/copy  function  to  access the  TAACLQMR3  source  and
follow the instructions which are marked as C*++ comments.

You should only copy in the code and not the C*++ comments.

Only  a few comments appear in the  subroutine in order to minimize the
amount of source  to be included.   For a  better understanding of  how
the logic  of the subroutine  works, see the  TAACLQMR source  which is
the processing function for the EDTVAR2 command.

TAACLQMR3  is a working  program, but has  no function other  than as a
test vehicle.   If you  call the  program, a display  will appear  with
the edited value.  Use F3 to end the program.


There are  minor  differences with  the Y  edit code  handling of  very
short or long fields.


The following TAA Tools must be on your system:

     DSPEDTCDE       Display edit code
     SNDESCMSG       Send escape message


None, the tool is ready to use.

Objects used by the tool

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

   EDTVAR2       *CMD                   TAACLQM       QATTCMD
   DMOEDTVAR2    *CMD                   TAACLQM2      QATTCMD
   TAACLQMC      *PGM       CLP         TAACLQMC      QATTCL
   TAACLQMC2     *PGM       CLP         TAACLQMC2     QATTCL
   TAACLQMR      *PGM       RPG         TAACLQMR      QATTRPG
   TAACLQMR3     *PGM       RPG         TAACLQMR3     QATTRPG
   TAACLQMR4     *PGM       RPG         TAACLQMR4     QATTRPG
   TAACLQMP      *FILE      PF          TAACLQMP      QATTDDS

The  TAACLQMR3 program  is the  source  to be  copied if  you  want the
EDTVAR2  function as a subroutine.   The program can  be called, but is
only used for testing.

The  TAACLQMR4  source  is  a  sample  of  how  to  call  the  TAACLQMR
processing program  as a sub program.   The program can  be called, but
is only used for testing.


EDTVAR2     Cmd
   TAACLQMC   CL pgm

   TAACLQMC2   CL pgm
       TAACLQMD    Display file

Added to TAA Productivity tools May 1, 1996

Home Page Up to Top