project BLF > class Database Component > method PopulateXDocument

Description

Populate the passed document handle with an XML representation of the database object(s) currently in memory.
This XML representation uses the standard schema found in <server installation folder>/xml/<class>.xsd.


Parameters


icObjectRowIdinputcharacterIf you want to restrict dumped data to a single object, pass the rowid of the object.
Otherwise leave blank, and all objects in memory will be dumped.
ilHeaderOnlyinputlogicalindicates whether only the main table should be used in the generated XML representation.
ilSuppressEmptyFieldsinputlogicalWhen true, blank fields will be removed from the XML Representation. Blank means empty string, or unknown value for all other data types. Zero is not considered an empty value.
When false, no fields will be removed.
When unknown value, fields with value identical to the default value of that column will be removed. If actual value is the unknown value, and the default value is not unknown value, this unknown value will not be removed.
iiPriorityinputintegerIf Priority is different from 0, an additional tag (Priority) will be supported in the header of the Xml string.
ilWriteXMLSchemainputlogicalAlso include the metaschema in the XML file
ilExportForInputinputlogicalWhen exporting an XML file to be used for direct input, some fields should be suppressed in the output:
tContextInfo.tcInvolvedCompanyCodes
tContextInfo.tcCorrelationId
tContextInfo.tcObjectIdentifier
all '*_ID' fields
all 'tc_Status' fields
(BLF-1908)
ihDocumentinputhandle
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method database.DumpXmlRepresentation
method database.DumpXmlToLongchar


program code (program1/database.p)

if ilSuppressEmptyFields = yes
then assign vlSuppressDefault = no
            vlSuppressEmpty   = yes.
else if ilSuppressEmptyFields = no
then assign vlSuppressDefault = no
            vlSuppressEmpty   = no.
else assign vlSuppressDefault = yes
            vlSuppressEmpty   = no.

create dataset vhDS in widget-pool "non-persistent".

<M-12 run GetXmlRepresentationDataset
   (input  icObjectRowId (icObjectRowId), 
    input  ilHeaderOnly (ilHeaderOnly), 
    input  iiPriority (iiPriority), 
    output vhDS by-reference (ozXMLDataset), 
    output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

vhDS:Write-xml("handle", ihDocument, true, ?, ?, ilWriteXMLSchema, false, false, vlSuppressDefault). 

if ilExportForInput
then do:
    create x-noderef vhBusObject in widget-pool "non-persistent".
    create x-noderef vhTable in widget-pool "non-persistent".
    create x-noderef vhField in widget-pool "non-persistent".
    ihDocument:get-child(vhBusObject,1).
    do viCount1 = 1 to vhBusObject:num-children:
        vhBusObject:get-child(vhTable,viCount1).
        if vhTable:name = "tContextInfo"
        then do viCount2 = vhTable:num-children to 1 by -1:
            vhTable:get-child(vhField,viCount2).
            if can-do("tcInvolvedCompanyCodes,tcCorrelationId,tcObjectIdentifier,tcOriginator",vhField:name)
            then vhTable:remove-child(vhField).
        end.
        else do:
            <M-13 run DumpXmlRemoveFieldsNotForInput  (input  vhTable (ihTableNode)) in database>
        end.
    end.
end.

if vlSuppressEmpty
then do:
    <M-32 run HandleSuppressEmptyFields
       (input  ihDocument (ihParent), 
        output viFcReturnSuper (oiReturnStatus)) in database>
    if viFcReturnSuper <> 0
    then oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0
    then return.
end.

finally:
    if vhDS <> ?
    then do:
        /* dynamic temp-tables in the dataset will be deleted in the finally block of AdditionalUpdates */
        vhDS:clear().
        delete object vhDS.
    end.
    if vhBusObject <> ? then delete object vhBusObject.
    if vhTable <> ? then delete object vhTable.
    if vhField <> ? then delete object vhField.
end finally.