Creating a document

Top  Previous  Next

You can create an empty document using the DOCUMENT CREATE command, and then build the contents with subsequent DOCUMENT INSERT commands, or use DOCUMENT CREATE to create and build the document in one step. DOCUMENT CREATE has a mandatory DOCTOKEN parameter requiring a 16-byte data-area. The document handler domain uses the DOCTOKEN operand to return a token, which is used to identify the document on subsequent calls. The following example creates an empty document, and returns the token in the variable MYDOC:

EXEC CICS DOCUMENT CREATE
                  DOCTOKEN(MYDOC)

To create a document with data, use the DOCUMENT CREATE command in any of the following ways:

Using the BINARY option
Using the TEXT option
Using the FROMDOC option to copy an existing document
Using the TEMPLATE option. "Setting up document templates".

The BINARY option

Use this option to add to the document the contents of a data-area that must not undergo conversion to a client code page when the data is sent.

EXEC CICS DOCUMENT CREATE
                  DOCTOKEN(MYDOC)
             BINARY(DATA-AREA)

The TEXT option

Use this option to add the specified contents to the document. For example, if you define a character string variable called DOCTEXT and initialise it to "This is an example of text to be added to a document", you can use the following command to create a document consisting of this text string:

EXEC CICS DOCUMENT CREATE
                  DOCTOKEN(MYDOC)
             TEXT(DOCTEXT) LENGTH(53)

The FROMDOC option

To copy an existing document into a new document, you can use the DOCUMENT CREATE command with the FROMDOC option. The following example shows this:

EXEC CICS DOCUMENT CREATE
                  DOCTOKEN(MYDOC2)
                         FROMDOC(MYDOC)

This results in two identical documents, each containing the text This is an example of text to be added to a document.