project BLF > class Database Component > method DumpXmlToLongchar

Description

Write an XML representation of the database object(s) currently in memory to a longchar.
This XML representation uses the standard schema found in <server installation folder>/xml/<class>.xsd.


Parameters


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
icObjectRowIdinputcharacterIf you want to restrict dumped data to a single object, pass the rowid of the object.
Otherwise leave blanc, and all objects in memory will be dumped.
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)
opXmlRepresentationoutputlongchar
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method BEventDaemonQueue.CreateEvent


program code (program1/database.p)

create x-document vhDocument in widget-pool "non-persistent".

<M-40 run PopulateXDocument
   (input  icObjectRowId (icObjectRowId), 
    input  ilHeaderOnly (ilHeaderOnly), 
    input  ilSuppressEmptyFields (ilSuppressEmptyFields), 
    input  iiPriority (iiPriority), 
    input  ilWriteXMLSchema (ilWriteXMLSchema), 
    input  ilExportForInput (ilExportForInput), 
    input  vhDocument (ihDocument), 
    output viFcReturnSuper (oiReturnStatus)) in database>    
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

assign vlFcOk = vhDocument:save("longchar", opXmlRepresentation) no-error.

if not vlFcOk         or
   error-status:error or
   error-status:num-messages > 0
then do:
    assign vcErrors = "".

    do viCount1 = 1 to error-status:num-messages:
        if vcErrors <> ""
        then assign vcErrors = vcErrors + chr(2).

        assign vcErrors = vcErrors + error-status:get-message(viCount1).
    end.

    <M-55 run SetMessage
       (input  #T-31'Unable to Save XML as Longchar':255(778664708)T-31# (icMessage), 
        input  '' (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E' (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'blf-129673':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in database>

    if vcErrors <> ""
    then do viCount1 = 1 to num-entries(vcErrors, chr(2)):

        <M-43 run SetMessage
           (input  entry(viCount1, vcErrors, chr(2)) (icMessage), 
            input  '' (icArguments), 
            input  '' (icFieldName), 
            input  '' (icFieldValue), 
            input  'E' (icType), 
            input  3 (iiSeverity), 
            input  '' (icRowid), 
            input  'blf-597100':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in database>    
    end.

    assign oiReturnStatus = -1.
end.

finally:
    if vhDocument <> ? then delete object vhDocument.
end finally.