project BLF > class Database Component > method ApiDumpXmlRepresentation

Description

Write an XML file with the object data of one or more database objects.
This XML file uses the standard schema found in <server installation folder>/xml/<class>.xsd.
It can be used as input for method ApiMaintainByXML and for the XML daemon.


Parameters


icRowidsinputcharacterComma separated list of rowids of objects to include in the XML file
icFileinputcharacterFull path name of the file in which the XML should be dumped.
ilHeaderOnlyinputlogicalWhen true, only the main table will be included 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 added in the header of the XML object.
ilWriteXMLSchemainputlogicalWhen true, also 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 identified by icRowids 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)
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method BSystem.ApiDumpDefaultSecurity


program code (program3/database.p)

<M-1 run DataLoad
   (input  icRowids (icRowids), 
    input  '':U (icPkeys), 
    input  '':U (icObjectIds), 
    input  '':U (icFreeform), 
    input  false (ilKeepPrevious), 
    output viFcReturnSuper (oiReturnStatus)) in database>

if viFcReturnSuper < 0 or
   oiReturnStatus  = 0
then assign oiReturnStatus = viFcReturnSuper.

if oiReturnStatus < 0
then return.

<M-2 run DumpXmlRepresentation
   (input  icFile (icFile), 
    input  ilHeaderOnly (ilHeaderOnly), 
    input  ilSuppressEmptyFields (ilSuppressEmptyFields), 
    input  iiPriority (iiPriority), 
    input  ilWriteXMLSchema (ilWriteXMLSchema), 
    input  icObjectRowId (icObjectRowId), 
    input  ilExportForInput (ilExportForInput), 
    output viFcReturnSuper (oiReturnStatus)) in database>

if viFcReturnSuper < 0 or
   oiReturnStatus  = 0
then assign oiReturnStatus = viFcReturnSuper.

if oiReturnStatus < 0
then return.


Sample code: how to call this method through RPCRequestService (QXtend Inbound)

define temp-table ttContext no-undo
    field propertyQualifier as character
    field propertyName as character
    field propertyValue as character
    index entityContext is primary unique
        propertyQualifier
        propertyName
    index propertyQualifier
        propertyQualifier.

define dataset dsContext for ttContext.

define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.

/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
       ttContext.propertyValue = "database".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiDumpXmlRepresentation".
create ttContext.
assign ttContext.propertyName = "applicationId"
       ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
       ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
       ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
       ttContext.propertyValue = "".

/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/database.apidumpxmlrepresentation.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icRowids = <parameter value>
       vhParameter::icFile = <parameter value>
       vhParameter::ilHeaderOnly = <parameter value>
       vhParameter::ilSuppressEmptyFields = <parameter value>
       vhParameter::iiPriority = <parameter value>
       vhParameter::ilWriteXMLSchema = <parameter value>
       vhParameter::icObjectRowId = <parameter value>
       vhParameter::ilExportForInput = <parameter value>.

/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").

if not vhServer:connected()
then do:
    message "Could not connect AppServer" view-as alert-box error title "Error".
    return.
end.

/* Run */
assign vhContextDS = dataset dsContext:handle.

run program/rpcrequestservice.p on vhServer
    (input-output dataset-handle vhContextDS by-reference,
           output dataset-handle vhExceptionDS,
     input        dataset-handle vhInputDS by-reference,
     input-output dataset-handle vhInputOutputDS by-reference,
           output dataset-handle vhOutputDS).

/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).

if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).

/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.

if valid-handle(vhInputDS)
then delete object vhInputDS.

if valid-handle(vhOutputDS)
then delete object vhOutputDS.

if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.