TAA Tools

 RTVFLDARR      RETRIEVE FIELD ARRAY                     TAADBHF

 The Retrieve  Field Array  command retrieves  an array  of field  names
 that  exist in  a physical file  or a  single format  logical file.   A
 corresponding  multiple  occurrence  data  structure  is  also returned
 with the detail information  about each field.   Up to 199 fields in  a
 file  are supported  with  the basic  method.   Up  to  998 fields  are
 supported with an optional technique.

 Although  a command  exists  for the  basic method,  it cannot  be used
 because the  size of  the multiple  occurrence  data structure  exceeds
 the size of the largest variable allowed in a CL program.

 The intended use  of the tool is in  a HLL program where  the CPP would
 be used directly.

 RTVFLDARR escape messages you can monitor for
 ---------------------------------------------

       TAA9891    The file is not a physical or logical file.
       TAA9892    More than 199 fields exist (see later discussion).
       TAA9893    The file has more than one format.

 Escape messages from system commands will be re-sent.

 Sample RPG code for Basic Method (up to 199 fields)
 ---------------------------------------------------

 The following  RPG code shows the intended use and  is in a format that
 may be copied to an RPG program:

      E* Define array and multiple occurrence DS used by RTVFLDARR
      E                    FLN       200 10
      IFLNDS       DS
      I                                        12000 FLN
      I* CPP for RTVFLDARR
      I              'TAATOOL/TAADBHFR'    C         GETFLD
      I* Externally described DS supplied by RTVFLDARR
      IFLDDS     E DSTAADBHFP                200
      .
      .
      C* Call CPP of RTVFLDARR
      C                     CALL GETFLD                     Rtv fld arr
      C                     PARM           FILE   10        File
      C                     PARM           LIB    10        Library
      C                     PARM           FLNDS            Field names
      C                     PARM           FLDDS            Field info

 Do one of the following sets of code depending on your needs:

      C****************************************************************
      C*                                                              *
      C*      Access every DS entry.  The field name is in WHFLDE.    *
      C*                                                              *
      C****************************************************************
      C                     Z-ADD0         FX      30       Inlz index
      C           GETFLD    TAG                             Get field
      C                     ADD  1         FX               Bump index
      C           FX        OCUR FLDDS                      Set occur
      C           WHFLDE    IFNE *BLANKS                    Some field
      C*
      C* Use the field names in the mult occur DS such as WHFTXT.
      C*
      C                     GOTO GETFLD                     Loop back
      C                     ENDIF                           Some field


      C****************************************************************
      C*                                                              *
      C*      Access a single field name and the corresponding        *
      C*         DS fields                                            *
      C*                                                              *
      C****************************************************************
      C* To access a single field name
      C                     Z-ADD1         FX      30       Inlz
      C           FIELD     LOKUPFLN,FX                   20 Lookup
      C* If not found, handle error condition
      C  N20                DO                              Not found
      C*
      C*
      C                     ENDDO                           Not found
      C* Name was found, position mult occurrence DS
      C           FX        OCUR FLDDS
      C* Use the field names in the mult occur DS such as WHFTXT.

 A second format which  uses the field names  WUxxx instead of WHxxx  is
 also available by  the name of TAADBHFQ.   It is intended for  use when
 two files will be processed and both need the RTVFLDARR function.

 Accessing a file with more than 199 fields using the Basic Method
 -----------------------------------------------------------------

 If  a  file has  more  than 199  fields,  the first  199  may still  be
 accessed  with the Basic Method.   You must place  'GT199' in the first
 5 positions  of the  FLNDS  data structure.   This  specifies that  the
 TAA9892 escape message will not be sent.

 There is  no indication that  the file has  more than than  199 fields.
 To  determine this,  use  a command  like RTVDBFA.   and  the MAXFIELDS
 parameter.

 Accessing a file with up to 998 fields using the Optional Method
 ----------------------------------------------------------------

 The optional  method allows a  file to  have up  to 998  fields.   Note
 that this  method can  be used  for files  with fields  from 1 to  998.
 The following RPG III code may be used:

      E                    FLN       999 10                 Field names
      IFLNDS       DS
      I                                        19990 FLN
      I* Externally described DS supplied by RTVFLDARR
      IFLDDS     E DSTAADBHFP                999
      I              'TAATOOL/TAADBHFR2'   C         GETFLD
      .
      .
      C* Call CPP of RTVFLDARR
      C                     CALL GETFLD                     Rtv fld arr
      C                     PARM           FILE   10        File
      C                     PARM           LIB    10        Library
      C                     PARM           FLNDS            Field names
      C                     PARM           FLDDS            Field info

 The process of the data is the same as for the Basic Method.

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

 Note  that while  the command form  exists, it  cannot be  used because
 the size of the FIELDINFO return  variable exceeds the largest size  of
 a CL variable.   The command is  intended only for documentation.   The
 function must be accessed using a HLL program.

    FILE          The  qualified  name  of  the  physical  file  or  the
                  logical  file with  a single  format to  be retrieved.
                  The library defaults  to *LIBL.   *CURLIB may also  be
                  specified.

    FIELDS        The  array which contains  the field  names.   It must
                  be  declared  as 2000  bytes  and contains  up  to 199
                  field names.   The  first blank  field name  indicates
                  the end.

    FIELDINFO     The   multiple   occurrence    data   structure   that
                  describes  the  detail field  information.    The data
                  structure is  intended  to  be  defined  by  the  file
                  TAADBHFP  and  will  contain  199   occurrences.    If
                  retrieved  to  an   RPG  program  (by  using  the  CPP
                  directly),   it  is  not  necessary  to  describe  the
                  length of the entire data structure.

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

 The command  cannot  be used  in a  CL program  because  the length  of
 FIELDINFO exceeds the largest size CL variable.

 Only  a file with  a single  format may  be named.   This  includes any
 physical file or a logical file with a single format.

 Only  a file with a  single format may  be named with  up to 199 fields
 for the Basic Method.

 A file with up to 999 fields may be named for the Optional Method.

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

    RTVFLDARR     *CMD                      TAADBHF        QATTCMD
    TAADBHFR      *PGM          RPG         TAADBHFR       QATTRPG
    TAADBHFR2     *PGM          RPG         TAADBHFR2      QATTRPG
    TAADBHFP      *FILE         PF          TAADBHFP       QATTDDS
    TAADBHFQ      *FILE         PF          TAADBHFQ       QATTDDS

Added to TAA Productivity Tools May 1, 1996


Home Page

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