Start of README v1.3

This describes the purpose and components of /COPYBOOK and how to download, install, use and execute the /COPYBOOK preprocessor command.

PURPOSE
/COPYBOOK allows developers on AS400 to work on sources with greater flexibility and makes more efficient use of existing source members.
It does this by facilitating a copybook to be merged in using line numbers.  In other words, portions of a source member may be copied into another at compile time, rather than a complete member.
A range of lines in a source member can be copied.  It is no longer necessary to isolate the copy source in a separate member.
Furthermore, DDS sources can now be copied.  For example, the subfile control statements from one screen file can be copied into another screen file at compile time.  Likewise, screen banners need only be defined in one screen file and copied as required into other screens.


RSTLIB
To restore the saved library, first create a save file on the AS400.  Use FTP with binary to upload the file to the save file you created.
You may then move the contents to a library or libraries of your choice.


METHOD
There are two steps.  Step 1 is the inclusion of the preprocessor /COPYBOOK in the target source member.  Step 2 is to execute the ADP command, which processes the /COPYBOOK command to expand the source and then to (optionally) compile the expanded source.

  1. /COPYBOOK in Source Member
  2. When using /COPYBOOK in an RPG fixed-format source line or a DDS line, a * is expected in position 7.  This forces SEU to regard the line as a comment.  /COPYBOOK must be in positions 8 - 16.  Alternatively, when using /COPYBOOK on free-fromat RPG line, a // is expected in positions 8 - 9.  /COPYBOOK is then expected in positions 10 - 18.

    The format of the /COPYBOOK statement is /COPYBOOK LIBRARY/FILE,MEMBER:ffff-tttt
    or /COPYBOOK FILE,MEMBER:ffff-tttt
    or /COPYBOOK MEMBER:ffff-tttt
    or /COPYBOOK MEMBER

    One space is required between /COPYBOOK and the next character.

    LIBRARY and FILE are optional.
    If LIBRARY is omitted, the name of the library in which the source file containing member with the /COPYBOOK statement is inserted.
    If FILE is omitted, the name of the source file containing member with the /COPYBOOK statement is inserted.

    If no line number range is given, all of the member is copied.

    All alphabetic entries may be keyed in either UPPER or lower case or a combination.
    All alphabetic entries are converted to UPPERCASE.

    If a number is given on its own, the mémber is copied from that line to the end.

    Up to 99 /COPYBOOK statements may be nested.

    A member may not call itself or one higher in the nested hierarchy.


  3. ADP Preprocessor Command
  4. This describes the ADP command as it is supplied.  You may change this, and the related cl ADP6 to suit your own compile environment - as long as you keep the parameters to ADP5 in the same sequence and with the same lengths and types.
    ADP is the preprocessor command.  It reads the lines in the input source member, expands the /COPYBOOK statements as appropriate and, by default, writes the expanded source out to file ADOUTPUT in library QTEMP.
    The member name and the input file name are required.
    If you wish to compile the expanded source immediately after expanding, you may supply the relevant compiler command.
    Similarly, if you wish to retain the expaned output, or write it to another location, you may change the output parameters as required.
    NOTE ... it is necessary to recompile the ADP command prior to first use.


COMPONENTS
The file you download is called MCKABTSAVF.  This is an AS400 save file, the output of a SAVLIB.
The library which was saved is called MCKABT.  There are four objects in this library - ADP5, ADP6, ADP and ADPSOURCE.  NOTE ... it is necessary to recompile the ADP command prior to first use.
ADP5 is the executable which reads in the source member containing the /COPYBOOK statement(s) and writes the expanded source out to file ADPOUTPUT.  ADP6 is a CL program which calls ADP5.  ADP is the command which in turn calls ADP6.  File ADPSOURCE contains the source members for ADP6 and ADP.
You may change these to suit your own compile environment - as long as you keep the parameters to ADP5 in the same sequence and with the same lengths and types.


8 Mar 2010
©2010 McKay Software Services Ltd
END of README v1.3