Populating Document Data

This section discusses and provides examples for how to:

  • Populate documents from messages.

  • Populate document using rowsets.

  • Populate message segments with documents.

Populating Documents from Messages

The following example shows how to use the CreateMessage built-in function to populate a document from a message:

&MSG = CreateMessage(Operation.PURCHASE_ORDER);
&DOC = &MSG.GetDocument();

Populating Documents Using Rowsets

The following example shows using the CreateMessage built-in function and the Document class to populate a document using a rowset:

Local Message &MSG;
Local Document &DOC;

&MSG = CreateMessage(Operation.PURCHASE_ORDER);
&DOC = &MSG.GetDocument();

/* Get Rowset */
&Rowset = &DOC.GetRowset();

/* populate rowset like any other rowset

/* update document with popualted rowset * /
&nRet = &DOC.UpdateFromRowset(&Rowset);

If (&nRet) = True Then
   %IntBroker.Publish(&MSG);
End-If;

Populating Message Segments with Documents

The following example shows code for populating message segments with documents.

After you code to populate a segment, set the following statement to NULL to release memory:

&DOC = null;

Then, set the following statement to TRUE to manage memory and guarantee that only one segment is in memory at a given time:

&DOC = &MSG.GetDocument(true);

If you do not following these coding guidelines, memory will get filled with data from all segments in the message.

The previous statements are in emphasis in the following example:

Declare Function PopulateDocument PeopleCode QE_FLIGHTDATA.QE_ACNUMBER Field⇒
Formula;
Local Document &DOC;

&MSG = CreateMessage(Operation.FLIGHTPLAN_DOC);

/*pass in true to get ownership of the object*/
/
&DOC = &MSG.GetDocument(true);

/*popualte the docment with data */
PopulateDocument(&DOC, 1);

/*create a new segment */
&MSG.CreateNewSegment();

/* null out object to release memory */
&DOC = null;&DOC = &MSG.GetDocument(true);
PopulateDocument(&DOC, 2);
&MSG.CreateNewSegment();&DOC = null;
&DOC = &MSG.GetDocument(true);
PopulateDocument(&DOC, 3);

/* publish segmented Message (3 segments) */
%IntBroker.Publish(&MSG);