Instantiating Document Objects

This section discusses and provides examples for how to:

  • Instantiate Document objects using package, name, and version.

  • Instantiate Document objects using document keys.

  • Instantiate Document objects for document message types.

Instantiating Document Objects Using Package, Name, and Version

You can instantiate a Document object using the CreateDocument built-in function. Using this approach, you use the Create Document built-in function, and then specify the document package name, the document name, and the document version, as shown in the following example:

&DOC = CreateDocument("Purchasing", "PurchaseOrder", "v1");

Instantiating Document Objects Using Document Keys

The following code example shows instantiating a Document object using the a document key. This approach uses the CreateDocumentKey and CreateDocument built-in functions.

First you instantiate a Document Key object, using the CreateDocumentKey built-in function and passing in the document package name, document name, and document version. You then instantiate a Document object using the CreateDocument built-in function, and pass in the document key.

&DOCKEY = CreateDocumentKey("Purchasing", "PurchaseOrder", "v1");
&DOC = CreateDocument(&DOCKEY);

Instantiating Document Objects for Document Message Types

The following example shows how to instantiate a document object when the document is being used as a message type.

&DOC = &MSG.GetDocument();