| icObjectRowId | input | character | If 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. |
| ilHeaderOnly | input | logical | indicates whether only the main table should be used in the generated XML representation. |
| iiPriority | input | integer | If Priority is different from 0, an additional tag (Priority) will be supported in the header of the Xml string. |
| ozXMLDataset | output | dataset-handle | This parameter should always be passed by-reference, meaning, the dataset handle should be created before the call. |
| oiReturnStatus | output | integer | Return status of the method. |
BLF
QadFinancials
ozXMLDataset:name = replace(replace(vcFcComponentName, "[", "_"), "]", "").
if not vcFcComponentName begins "BCustom["
then do:
/* Fill in the tcObjectIdentifier with the value of the primary key of the object */
<M-16 run GetKeyFields
(input-output vcPrimTable (bcTableName),
output vcPrimKeyFields (ocPrimaryKey),
output vcDummy (ocAlternateKey),
output vcDummy (ocObjectID),
output vcDummy (ocObjectStatus),
output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
find first tFcDynRel where tFcDynRel.tcFcTo = vcPrimTable no-error.
if available tFcDynRel
then do:
create query vhQuery in widget-pool "non-persistent".
vhQuery:forward-only = yes.
vhQuery:set-buffers(tFcDynRel.thFcBuffer).
if icObjectRowId = ""
or icObjectRowId = ?
then vhQuery:query-prepare ("for each t_o" + vcprimTable).
else vhQuery:query-prepare ("for each t_o" + vcPrimTable + " where t_o" + vcPrimTable + ".tc_Rowid = '" + icObjectRowId + "'").
vhQuery:query-open().
vhQuery:get-first().
if not vhQuery:query-off-end
then do viFcCount1 = 1 to num-entries(vcPrimKeyFields):
vcValue = ?.
vhField = ?.
vhField = tFcDynRel.thFcBuffer:buffer-field(entry(viFcCount1,vcPrimKeyFields)) no-error.
if vhField <> ?
then do:
if vhField:data-type = "logical":U
then assign vcValue = (if vhField:buffer-value = yes
then "TRUE":U
else if vhField:buffer-value = no
then "FALSE":U
else "?":U).
else if vhField:data-type = "date":U
then do:
assign vtemp = date (vhField:buffer-value).
assign vcValue = <M-82 DisplayDate (input vtemp (itDate)) in database>.
end.
else if vhField:data-type = "decimal":U
then assign vcValue = <M-61 DisplayDecimal
(input decimal (vhField:buffer-value) (idDecimal),
input vhField:format (icFormat)) in database>.
else assign vcValue = string(vhField:buffer-value).
end.
vcPrimKeyValue = vcPrimKeyValue + (if viFcCount1 = 1 then "" else "|")
+ (if vcValue = ? then "?":U else vcValue).
end.
vhQuery:query-close().
if icObjectRowId = ""
or icObjectRowId = ?
then vlObjectRowidDelete = no.
else do:
vhQuery:query-prepare ("for each t_o" + vcPrimTable + " where t_o" + vcPrimTable + ".tc_Rowid <> '" + icObjectRowId + "'").
vhQuery:query-open().
vhQuery:get-first().
vlObjectRowidDelete = not vhQuery:query-off-end.
vhQuery:query-close().
end.
delete object vhQuery.
vhQuery = ?.
end.
end.
empty temp-table tContextInfo.
create tContextInfo.
assign tContextInfo.tcCBFVersion = "9.2":U
tContextInfo.tiPriority = iiPriority
tContextInfo.tcActivityCode = vcActivityCode
tContextInfo.tcObjectIdentifier = vcPrimKeyValue
tContextInfo.tcOriginator = "user " + vcUserLogin
tContextInfo.tlPartialUpdate = no.
if tContextInfo.tcActivityCode = ""
then do:
<I-53 {bFcRun
&PARAMETERS = "output tContextInfo.tcActivityCode"
&PROCEDURE = "gipr_GetDefaultActivity"}>
end.
<M-14 run XmlObjectDetail (output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
find first tXMLTables where tXMLTables.tcTableName = "ContextInfo" no-error.
if not available tXMLTables
then do:
create buffer vhDSBuffer for table buffer tContextInfo:handle in widget-pool "non-persistent".
create tXMLTables.
assign tXMLTables.tcTableName = "ContextInfo"
tXMLTables.thTableHandle = vhDSBuffer:table-handle
tXMLTables.thBuffer = vhDSBuffer
tXMLTables.tlStatic = yes.
end.
ozXMLDataset:add-buffer(tXMLTables.thBuffer).
<M-17 run DataDescription
(input '' (icRowids),
input '':U (icPkey),
input '' (icObjectIds),
input yes (ilAllTables),
output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
if vlObjectRowidDelete
then do:
for each tXMLTables where not tXMLTables.tlStatic on error undo, throw:
tXMLTables.thBuffer:empty-temp-table().
end.
if not (ilHeaderOnly or can-find (first tCustomRelation))
then do:
<M-26 run DefineCustomRelations (output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
for each tCustomRelation:
for each tFcDynRel where tFcDynRel.tcFcTo = tCustomRelation.tcChildTable:
tFcDynRel.tcParent = tCustomRelation.tcParentTable + ",Custom".
end.
for each tFcDynRel where ("t" + tFcDynRel.tcFcTo) = tCustomRelation.tcChildTable:
tFcDynRel.tcParent = substring(tCustomRelation.tcParentTable,2,-1,"CHARACTER") + ",Custom".
end.
end.
for each tFcDynRel where tFcDynRel.tcFcTo = vcPrimTable on error undo, throw:
<M-44 run GetXmlRepresentationDSAddTable
(input vcPrimTable (icTableName),
input icObjectRowId (ictcRowid),
input '' (ictcParentRowid),
input ilHeaderOnly (ilHeaderOnly),
output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
end.
for each tFcDynRel where tFcDynRel.tcFcTo = vcPrimTable or ilHeaderOnly = no on error undo, throw:
find first tXMLTables where tXMLTables.tcTableName = tFcDynRel.tcFcTo no-error.
if not available tXMLTables
then do:
create buffer vhDSBuffer for table tFcDynRel.thFcBuffer buffer-name ("t" + tFcDynRel.tcFcTo) in widget-pool "non-persistent".
create tXMLTables.
assign tXMLTables.tcTableName = tFcDynRel.tcFcTo
tXMLTables.thTableHandle = vhDSBuffer:table-handle
tXMLTables.thBuffer = vhDSBuffer
tXMLTables.tlStatic = yes.
end.
ozXMLDataset:add-buffer(tXMLTables.thBuffer).
if tFcDynRel.tcParent <> ""
then if entry (2,tFcDynRel.tcParent) = "Custom"
then tFcDynRel.tcParent = "".
end.
assign viFcCount1 = 0.
if not ilHeaderOnly
then for each tFcDynRel on error undo, throw:
find first tXMLTables where tXMLTables.tcTableName = tFcDynRel.tcFcTo.
/* Make sure the code handles the "overriding" primary relations correctly.
These are the cases where the tcParent is filled in */
for each bFcDynrel where
(bFcDynRel.tcFcFrom = tFcDynRel.tcFcTo and bFcDynRel.tcParent = "") or
bFcDynrel.tcparent begins tFcDynRel.tcFcTo + "," on error undo, throw:
find first bXMLTables where bXMLTables.tcTableName = bFcDynRel.tcFcTo.
assign vhRel = ozXMLDataset:add-relation(tXMLTables.thBuffer,
bXMLTables.thBuffer,
"tc_Rowid,tc_ParentRowid",
?,
true)
viFcCount1 = viFcCount1 + 1
vhRel:Name = "ParentChildReference":U + string(viFcCount1).
end.
end.
finally:
if vhQuery <> ? then delete object vhQuery.
end finally.