TAA Tools
WRTSRC       WRITE SOURCE STATEMENTS TO A SOURCE MEMBER      TAASRCG

The Write  Source  command allows  writing a  source  statement into  a
source member.   An entire record  can be added or  updated.  Positions
within  the record can also  be specified to allow  an easier entry for
fixed form languages.

No delete function  is supported (you  could consider making a  comment
out of an existing statement).

WRTSRC can  be of  value when  you have some  minimal amount  of source
that  must be created  or modified from  within a CL  program.  Typical
source types to  be modified would be  DDS or Reformat  specifications.

Assume you want  to dynamically create a  file using the format  of the
DSPFD  member output file  and specify a  key on the  number of records
field (MBNRCD)  in descending  sequence.   The model  file in  QSYS  is
QAFDMBR with a  format name of QWHFDMBR.   You must have a  source file
and  add a  member to  it.   Then  you can  use the  WRTSRC  command to
create the DDS.  Typical coding would be as follows:

     CRTSRCPF    FILE(QTEMP/SOURCE)
     ADDPFM      FILE(QTEMP/SOURCE) MBR(MBRFIL)
     WRTSRC      SRCFILE(QTEMP/SOURCE) MBR(MBRFIL) ACTION(*ADD) STMT('-
     A          R QWHFDMBR                  FORMAT(QSYS/QAFDMBR)')
     WRTSRC      SRCFILE(QTEMP/SOURCE) MBR(MBRFIL) ACTION(*ADD) STMT('-
     A          K MBNRCD                    DESCEND')
     WRTSRC      SRCFILE(QTEMP/SOURCE) MBR(MBRFIL) ACTION(*END)
     CRTPF       FILE(QTEMP/MBRFIL) SRCFILE(QTEMP/SOURCE)
     DSPFD       FILE(xxx) TYPE(*MBR) OUTPUT(*NONE) FILEATR(*PHY) +
                   OUTFILE(QTEMP/MBRFIL)

The  source  file is  created and  a member  is added.   The  first two
WRTSRC commands  write DDS specifications  to the  file for the  format
and key  record.  The WRTSRC command  assumes that you are  going to do
more  than  one  operation,  so  the  third  WRTSRC  command  specifies
ACTION(*END) which  closes the  file/member.   The  CRTPF command  then
creates the file and the DSPFD command outputs into the file.

The DDS that was created would look like:

     A          R QWHFDMBR                  FORMAT(QSYS/QAFDMBR)
     A          K MBNRCD

In the  previous, example  the STMT  parameter was  used on WRTSRC  and
the  statement was  written with  the exact  number of  blanks required
for the fixed format entry of DDS.   Another alternative is to use  the
POSn and  TXTn keywords on  the WRTSRC command.   The first  two WRTSRC
commands could have been written as:

     WRTSRC      SRCFILE(QTEMP/SOURCE) MBR(MBRFIL) ACTION(*ADD) +
                   POS1(6)  TXT1('A') +
                   POS2(17) TXT2('R QWHFDMBR') +
                   POS3(45) TXT3('FORMAT(QSYS/QAFDMBR)')
     WRTSRC      FILE(QTEMP/SOURCE) MBR(MBRFIL) ACTION(*ADD) +
                   POS1(6)  TXT1('A') +
                   POS2(17) TXT2('K MBNRCD')
                   POS3(45) TXT3('DESCEND')

When the  POSn and TXTn  keywords are used,  the statement is  built up
in  a work area and then written to the  source file.  Up to 4 POSn and
TXTn keywords may  be specified.   Each TXTn field can  be 29 bytes  in
length  and is  truncated  to the  last  character entered.   The  STMT
keyword  can also be used.   The STMT value becomes  the base entry for
the statement and the TXTn values overlay the statement.

Multiple member processing
--------------------------

WRTSRC  will  allow  you  to  update  multiple  members  without  using
ACTION(*END).  For example,  you can change a record  in MBR1, change a
record  in  MBR2,  and  then use  ACTION(*END)  to  each  member.   The
updating program has only one  file open at a  time, but senses that  a
change in lib/file/member has  occurred.  It would close  the currently
open file and reopen the new file.

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

   SRCFILE       The  qualified name  of the  source  file to  be used.
                 The  library defaults to *LIBL.   The source file must
                 exist prior to  the use of  WRTSRC.  The maximum  size
                 source  file  of 240  bytes  (228  bytes  of data)  is
                 supported.

   MBR           The  member to be used.   The member must exist before
                 the use of WRTSRC.

   RELRCD        The relative  record  number  of  the  source  record.
                 The default is  *NEXT which works in  conjunction with
                 the  ACTION(*ADD) default to  add a new  record to the
                 file.     A  relative   record  number   is   normally
                 specified for update operations.

                 For update  operations, if  your SEU sequence  numbers
                 all end  in .00 such  as 86.00 and you  want to update
                 that  record,  the  parameter should  be  specified as
                 RELRCD(86).

   ACTION        The action  code  to be  used.   The  default is  *ADD
                 meaning to add a record at the end of the member.

                 *UPD  allows an existing  record to  be updated.   You
                 may  specify one or more of  the POSn/TXTn keywords to
                 modify some  of the  positions of  an existing  source
                 record.

                 *RPL may be  specified to totally replace  an existing
                 source record.

                 *END  should  be  specified  when  there  are no  more
                 changes to  be made  to the  member.   When the  first
                 use  of  WRTSRC  occurs,  the  member  is  opened  and
                 remains  open  for   other  records  to  be  added  or
                 changed.     When  no  more  action  is  desired,  the
                 ACTION(*END) specification  should  be used  to  cause
                 the file be closed normally.

   STMT          The  source statement  to be  used.   This  acts as  a
                 base  statement which can  be further  modified by the
                 POSn/TXTn  parameters.     The  POSn/TXTn   parameters
                 overlay the  STMT value  for the  positions specified.
                 If  STMT is  specified  with ACTION(*UPD),  the entire
                 statement will  be replaced.   Normally,  STMT  should
                 not be  used with  ACTION(*UPD).   If a total  replace
                 of   an   existing   statement  is   needed,   specify
                 ACTION(*RPL).

   POS2          The  first  position  to be  modified  with  the value
                 from the TXT1 parameter.

   TXT1          The value to  be placed  into the statement  beginning
                 at  the POS1 parameter  value.   The value  entered is
                 scanned   from  the  right   to  determine  the  first
                 non-blank position.   This  determines the  number  of
                 positions  to be  moved.    See the  later  discussion
                 about  overlaying data.   Up to  29 characters  may be
                 entered.

   POS2          The second position to be modified.

   TXT2          The second value to be placed in the record.

   POS3          The third position to be modified.

   TXT3          The third value to be placed in the record.

   POS4          The fourth position to be modified.

   TXT4          The fourth value to be placed in the record.

If the STMT  keyword is  used, the  value is used  as a  base to  begin
building the  source  statement from.   If  ACTION(*UPD) is  specified,
the existing source statement is used as a base.

The TXTn keywords  are processed in order so  it is possible to overlay
the  results of one  with the next TXTn.   If you  request to move data
beyond position 228 of the statement, an escape message will occur.

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

   WRTSRC        *CMD                      TAASRCG        QATTCMD
   TAASRCGC      *PGM          CLP         TAASRCGC       QATTCL
   TAASRCGR      *PGM          RPG         TAASRCGR       QATTRPG
					

Added to TAA Productivity tools April 1, 1995


Home Page Up to Top