Populating and Retrieving Document Data

This chapter provides an overview of populating and retrieving document data and shows examples of how to use PeopleCode to:

Click to jump to parent topicUnderstanding Populating and Retrieving Document Data

PeopleSoft provides a Document class that contains built-in functions and methods that enable you to populate and retrieve document data.

This chapter provides PeopleCode examples for your reference.

Note. The Document class is described in detail in the PeopleTools PeopleBook: PeopleCode API Reference.

The Document class provides PeopleCode for populating documents. It also provides PeopleCode for reading data from primitive, compound, and collection elements.

Document PeopleCode specific to Integration Broker messages is described in the PeopleTools PeopleBook: Integration Broker.

See Also

Document Classes

Sending and Receiving Messages

Click to jump to parent topicPopulating Document Data

The following pseudo code is an example of populating a document using the CreateDocumentKey built-in function.

This function enables you to pass a document key into the CreateDocument built-in function, which then gives you the document.

Local Document &DOC; Local DocumentKey &DOCKEY; Local Primitive &PRIM; /* Populating Document Object */ &DOCKEY = CreateDocumentKey("Purchasing", "PurchaseOrder", "v1"); &DOC = CreateDocument(&DOCKEY); &COM = &DOC.DocumentElement; &COM.GetPropertyByName("Language_Code").Value = "ENG"; &COM_TRID = &COM.GetPropertyByName("TransactionId"); &COM_TRID.GetPropertyByName("issuer").Value = "PSFT"; &COM_TRID.GetPropertyByName("TransactionId").Value = "26435383"; &COM_BILLTO = &COM.GetPropertyByName("BillTo"); &COM_BILLTO.GetPropertyByName("name").Value = "Robby Naish"; &COM_BILLTO.GetPropertyByName("number").Value = "234"; &COM_BILLTO.GetPropertyByIndex(3).Value = "Alpine"; &COM_BILLTO.GetPropertyByIndex(4).Value = "4"; &COM_BILLTO.GetPropertyByName("city").Value = "Hood River"; &PRIM = &COM_BILLTO.GetPropertyByName("state"); &PRIM.Value = "Oregon"; &COM_BILLTO.GetPropertyByName("zipcode"); &PRIM.Value = "97031"; &COM_SHIPTO = &COM.GetPropertyByName("ShipTo"); &COM_SHIPTO.GetPropertyByName("name").Value = "Naish Sails"; &COM_SHIPTO.GetPropertyByName("number").Value = "123"; &COM_SHIPTO.GetPropertyByIndex(3).Value = "High Wind"; &COM_SHIPTO.GetPropertyByIndex(4).Value = "1"; &COM_SHIPTO.GetPropertyByName("city").Value = "Hood River"; &COM_SHIPTO.GetPropertyByName("state").Value = "Oregon"; &COM_SHIPTO.GetPropertyByName("zipcode").Value = "97031"; &COll_ITEMS = &COM.GetPropertyByName("item_collection"); &COM_ITEM = &COll_ITEMS.CreateItem(); &COM_ITEM.GetPropertyByName("items").Value = "4.2 Sail"; &COM_ITEM.GetPropertyByName("sku").Value = "s12322"; &COM_ITEM.GetPropertyByName("price").Value = "450"; &COM_ITEM.GetPropertyByName("quantity").Value = "2"; &nRet = &COll_ITEMS.AppendItem(&COM_ITEM); &COM_ITEM = &COll_ITEMS.CreateItem(); &COM_ITEM.GetPropertyByIndex(1).Value = "Mast"; &COM_ITEM.GetPropertyByName(2).Value = "m485765"; &COM_ITEM.GetPropertyByName(3).Value = "550"; &COM_ITEM.GetPropertyByName(4).Value = "3"; &nRet = &COll_ITEMS.AppendItem(&COM_ITEM); &COM_ITEM = &COll_ITEMS.CreateItem(); &COM_ITEM.GetPropertyByName("items").Value = "Boom"; &COM_ITEM.GetPropertyByName("sku").Value = "b9754"; &COM_ITEM.GetPropertyByName("price").Value = "375"; &COM_ITEM.GetPropertyByName("quantity").Value = "2"; &nRet = &COll_ITEMS.AppendItem(&COM_ITEM);

Click to jump to parent topicRetrieving Document Data

The following pseudo code is an example of retrieving data out of a compound element using the GetPropertyByName and GetPropertyByIndex methods:

&COM = &DOC.DocumentElement; &LNG_Code = &COM.GetPropertyByName("Language_Code").Value; &COM_TRID = &COM.GetPropertyByName("TransactionId"); &data = &COM_TRID.GetPropertyByName("issuer").Value; &data = &COM_TRID.GetPropertyByName("TransactionId").Value; &COM_BILLTO = &COM.GetPropertyByName("BillTo"); &data = &COM_BILLTO.GetPropertyByName("name").Value; &data = &COM_BILLTO.GetPropertyByName("number").Value; &data = &COM_BILLTO.GetPropertyByIndex(3).Value; &data = &COM_BILLTO.GetPropertyByIndex(4).Value; &data = &COM_BILLTO.GetPropertyByName("city").Value; &data = &COM_BILLTO.GetPropertyByName("state").Value; &data = &COM_BILLTO.GetPropertyByName("zipcode").Value; &COM_SHIPTO = &COM.GetPropertyByName("ShipTo"); &PRIM = &COM_SHIPTO.GetPropertyByName("name"); &data = &PRIM.Value; &data = &COM_SHIPTO.GetPropertyByName("number"); &data = &PRIM.Value; &data = &COM_SHIPTO.GetPropertyByIndex(3).Value; &data = &COM_SHIPTO.GetPropertyByIndex(4).Value; &data = &COM_SHIPTO.GetPropertyByName("city").Value; &data = &COM_SHIPTO.GetPropertyByName("state").Value; &data = &COM_SHIPTO.GetPropertyByName("zipcode").Value; &COll_ITEMS = &COM.GetPropertyByName("item_collection"); For &i = 1 To &COll_ITEMS.GetCount &COM_ITEM = &COll_ITEMS.GetItem(&i); &data = &COM_ITEM.GetPropertyByName("items").Value; &data = &COM_ITEM.GetPropertyByName("sku").Value; &data = &COM_ITEM.GetPropertyByName("price").Value; &data = &COM_ITEM.GetPropertyByName("quantity").Value; End-For;