TAA Tools

 ZEDIT           Z EDIT CODE RPG SUBROUTINE             TAARPGZ

 The Z Edit Code  RPG Subroutine tool provides two  subroutines that can
 be  copied into  a program  for stripping  leading  zeros off  a field.
 ZEDITL  left adjusts  the data.   ZEDITR right  adjusts the  data.  The
 subroutines are helpful when  you cannot or prefer  not to use the  RPG
 output specs.

 The specific  code considers any value  equal or less than  X'F0' to be
 a  zero.  Therefore,  if you  move a value  that is less  than 15 bytes
 (the size of ZEDITF), the leading blanks will also be truncated.

 If a zero value exists, a single zero is returned.

 The same  type  of  interface is  used  for both  programs,  but  MOVEL
 should  be  used  for  ZSHFTL  and MOVE  should  be  used  for  ZSHFTR.
 Padding  with blanks should  occur on the  first MOVE or  MOVEL and use
 EXSR to either ZEDITL  or ZEDITR.   The result is  then placed back  in
 the ZSHFLD field and you would move the result to your field.

      C                     MOVE xxx       ZEDITF    P      Field to edt
      C                     EXSR ZEDITL                     Editing subr
      C                     MOVELZEDITF    yyy              Move out

 The following RPG  code is in  a form ready to  be copied to an  RPG or
 RPG IV

 ZEDITL Subroutine (Left adjust) RPG III Code
 --------------------------------------------

      C                     MOVE xxx       ZEDITF    P      Field to edt
      C                     EXSR ZEDITL                     Editing subr
      C                     MOVELZEDITF    yyy              Move out
      C****************************************************************
      C*                                                              *
      C*     ZEDITL Subroutine - Does a Z Edit left adjusted.         *
      C*              Input and output to field ZEDITF.               *
      C*                                                              *
      C****************************************************************
      C           ZEDITL    BEGSR                           ZEDIT subr
      C                     DO   14                         Do 14 times
      C                     MOVELZEDITF    ZEDTL1  1        Move left
      C           ZEDTL1    CABGT'0'       ZEDTLE           Branch
      C                     MOVE ZEDITF    ZEDTLX 14        Drop one
      C                     MOVELZEDTLX    ZEDITF 15        Move back
      C                     MOVE ' '       ZEDITF           Move last
      C                     ENDDO                           Do 14 times
      C           ZEDTLE    ENDSR                           ZEDIT subr
      C****************************************************************

 ZEDITR Subroutine (Right adjust) RPG III Code
 ---------------------------------------------

      C                     MOVE xxx       ZEDITF    P      Field to edt
      C                     EXSR ZEDITR                     Editing subr
      C                     MOVE ZEDITF    yyy              Move out
      C****************************************************************
      C*                                                              *
      C*     ZEDITR Subroutine - Does a Z Edit right adjusted.        *
      C*              Input and output to field ZEDITF.               *
      C*                                                              *
      C****************************************************************
      C           ZEDITR    BEGSR                           ZEDIT subr
      C                     Z-ADD0         ZEDTRC  30       Count field
      C                     DO   14                         Do 14 times
      C                     MOVELZEDITF    ZEDTR1  1        Move left
      C           ZEDTR1    CABGT'0'       ZEDTRE           Branch
      C                     MOVE ZEDITF    ZEDTRX 14        Drop one
      C                     MOVELZEDTRX    ZEDITF 15        Move back
      C                     MOVE ' '       ZEDITF           Move last
      C                     ADD  1         ZEDTRC           Bump count
      C                     ENDDO                           Do 14 times
      C           ZEDTRE    TAG                             End shift
      C                     DO   ZEDTRC                     Do n times
      C                     MOVE ZEDITF    ZEDTRY 16        Add one
      C                     MOVELZEDTRY    ZEDITF           Move left
      C                     ENDDO                           Do n times
      C                     ENDSR                           ZEDIT subr
      C****************************************************************

 ZEDITL Subroutine (Left adjust) RPG IV Code
 -------------------------------------------

      C****************************************************************
      C*                                                              *
      C*     ZEDITL Subroutine - Does a Z Edit left adjusted.         *
      C*              Input and output to field ZEDITF.               *
      C*                                                              *
      C****************************************************************
      C     ZEDITL        BEGSR
      C                   DO        14
      C                   MOVEL (P) ZEDITF        ZEDTL1            1
      C     ZEDTL1        CABGT     '0'           ZEDTLE
      C                   MOVE      ZEDITF        ZEDTLX           14
      C                   MOVEL     ZEDTLX        ZEDITF           15
      C                   MOVE      ' '           ZEDITF
      C                   ENDDO
      C     ZEDTLE        ENDSR
      C****************************************************************

 ZEDITR Subroutine (Right adjust) RPG IV Code
 --------------------------------------------

      C****************************************************************
      C*                                                              *
      C*     ZEDITR Subroutine - Does a Z Edit right adjusted.        *
      C*              Input and output to field ZEDITF.               *
      C*                                                              *
      C****************************************************************
      C     ZEDITR        BEGSR
      C                   Z-ADD     0             ZEDTRC            3 0
      C                   DO        14
      C                   MOVEL     ZEDITF        ZEDTR1            1
      C     ZEDTR1        CABGT     '0'           ZEDTRE
      C                   MOVE      ZEDITF        ZEDTRX           14
      C                   MOVEL     ZEDTRX        ZEDITF           15
      C                   MOVE      ' '           ZEDITF
      C                   ADD       1             ZEDTRC
      C                   ENDDO
      C     ZEDTRE        TAG
      C                   DO        ZEDTRC
      C                   MOVE      ZEDITF        ZEDTRY           16
      C                   MOVEL     ZEDTRY        ZEDITF
      C                   ENDDO
      C                   ENDSR
      C****************************************************************

 Other editing functions
 -----------------------

 For more complex editing needs, see the EDTVAR2 and EDTVAR3 tools.

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

 None.

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

 None.

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

 None, the code is ready to be copied.

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

 None.

Added to TAA Productivity Tools May 1, 1997


Home Page

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