Previous Topic Next topic Print topic


Data item for example 3

The content of the COBOL data item defined in the copybook, s-struct3.cpy, is as follows:

*
* Title: s-struct3.cpy: XML Extensions sample data structure.
*
* Copyright © Micro Focus 2008-2013.
*     All rights reserved.
*
* Version Identification:
*   $Revision$
*   $Date$
*   $URL$
*
01  Address-Struct3.
    02  Time-Stamp    Pic X(23).
    02  Name          Pic X(64)
             Value "Cowboy Hats and More Company".
    02  City          Pic X(32) Value "San Marcos".
    02  State         Pic X(2) Value "TX".
    02  Zip           Pic 9(5) Value 78666.
    02  Country       PIC X(64)
              Value "United States of America".
    02  Address-Lines Pic 9.
    02  Address-Line  Pic X(64)
              Occurs 1 to 5 times Depending on Address-Lines.
01 Struct-Name       Pic X(15) Value "Address-Struct3".
01 Street            PIC X(64) Value
                 "504 Broadway Street".
01 Building          PIC X(64) Value "Building 1".
01 Suite             PIC X(64) Value "Suite 142".

This data item stores company address information. This structure differs from Example 1 Export file and import file in that an OCCURS DEPENDING phrase has been added to the structure. Instead of having separate data-names for Address-1 and Address-2, a variable-length array named Address-Line has been defined. Since Address-Line is variable length, it must be the last data item in the structure. A new data item named Address-Lines has been added just prior to the Address-Line array. Address-Lines is the depending variable for the array Address-Line.

The first field of the structure is a time stamp containing the time that the program was executed. This item is included to assure the person observing the execution of the example that the results are current. The time element in the generated XML document should change each time the example is run and should contain the current time.

Previous Topic Next topic Print topic