| ihComponent | input | handle | Handle to the calling component instance. |
| icColumns | input | character | Comma separated list of names of the columns that need a representation in the XML. The format of the names is "table.columnname". If the parameter value is left blank, the system assumes that ALL the columns should be represented. |
| ihStartingNode | input | handle | Handle to the node in the XML document under which the information should be put. |
| icTableName | input | character | |
| icParentRowid | input | character | Rowid of the parent table record. |
| ilHeaderOnly | input | logical | If true, only the main table will be stored in the xml representation. |
| ilSuppressEmptyFields | input | logical | if true, all the empty fields will be suppressed in the xml representation. empty fields mean: - for character fields: blank value - for date fields: the unknown value |
| oiReturnStatus | output | integer | Return status of the method. |
BLF
if oiReturnStatus = 0
then oiReturnStatus = -98.
If icParentRowid = ?
Then Assign icParentRowid = '':U.
find bDynRelParent where bDynRelParent.tcFcTo = icTableName no-error.
create X-NODEREF vhTableNode in widget-pool "non-persistent".
create X-NODEREF vhRowsNode in widget-pool "non-persistent".
assign vhDocument = ihStartingNode:owner-document
vhBuffer = bDynRelParent.thFcBuffer.
assign vhParentRowid = vhbuffer:buffer-field("tc_Rowid":U) no-error.
create query vhQuery in widget-pool "non-persistent".
vhQuery:forward-only = yes.
vhQuery:add-buffer(vhBuffer).
if icParentRowid = ""
then vhQuery:Query-prepare("for each ":U + vhBuffer:Name).
else if bDynRelParent.tcFcFrom = ""
then if bDynRelParent.tcFcRel = ""
then vhQuery:Query-prepare("for each ":U + vhBuffer:Name).
else vhQuery:Query-prepare("for each ":U + vhBuffer:Name + " where ":U + vhBuffer:Name + ".tc_Rowid = ~"":U + icParentRowid + "~"":U).
else vhQuery:Query-prepare("for each ":U + vhBuffer:Name + " where ":U + vhBuffer:Name + ".tc_ParentRowid = ~"":U + icParentRowid + "~"":U).
vhQuery:query-open().
vhQuery:get-first().
if not vhQuery:QUERY-OFF-END
then do:
vhDocument:create-node-namespace (vhRowsNode,"com.softcell.componentbuilder.class":U,'t':U + icTableName + "Rows":U,"ELEMENT":U).
vhRowsNode:namespace-prefix = "cb":U.
ihStartingNode:Append-child (vhRowsNode).
end.
do while not vhQuery:QUERY-OFF-END :
vhDocument:create-node-namespace (vhTableNode,"com.softcell.componentbuilder.class":U,'t':U + icTableName,"ELEMENT":U).
vhTableNode:namespace-prefix = "cb":U.
vhRowsNode:APPEND-CHILD (vhTableNode).
do viCnt = 1 to vhBuffer:NUM-FIELDS :
assign vhField = vhBuffer:buffer-field(viCnt).
if (icColumns <> "" and
not can-do(icColumns,substring(vhBuffer:Name,4,-1,"CHARACTER":U) + ".":U + vhField:name))
or can-do("tc_rowid,tc_parentrowid":U, vhField:name)
then NEXT.
if ilSuppressEmptyFields
then do:
if vhField:data-type = "date":U and vhField:buffer-value = ?
then next.
if vhField:data-type = "character":U and (vhField:buffer-value = "":U or vhField:buffer-value = ?)
then next.
end.
<M-2 run AddXmlNode (input vhTableNode (ihParent),
input vhField:name (icNodeName),
input vhField (ihField),
output vhFieldNode (ohFieldNode),
output viFcReturnSuper (oiReturnStatus)) in XML>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
vhQuery:query-close().
delete object vhQuery.
return.
end.
assign vhdatabaseInst = ihComponent.
<M-1 run XmlColumnDetail (input icTableName (icTableName),
input vhField:name (icColumnName),
input vhBuffer (ihBuffer),
input vhField (ihField),
input vhFieldNode (ihParentNode),
input ilSuppressEmptyFields (ilSuppressEmptyFields),
output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
vhQuery:query-close().
delete object vhQuery.
return.
end.
delete object vhFieldNode.
end.
assign vhdatabaseInst = ihComponent.
<M-4 run XmlTableDetail (input icTableName (icTableName),
input vhBuffer (ihBuffer),
input vhTableNode (ihParentNode),
output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
vhQuery:query-close().
delete object vhQuery.
return.
end.
if ilHeaderOnly = false
then for each bDynRelChild where
(bDynRelChild.tcFcFrom = bDynRelParent.tcFcTo and
bDynRelChild.tcParent = "") or
bDynRelChild.tcParent begins (bDynRelParent.tcFcTo + ","):
<M-5 run ConvertTableToXmlSingleTable (input ihComponent (ihComponent),
input icColumns (icColumns),
input vhTableNode (ihStartingNode),
input bDynRelChild.tcFcTo (icTableName),
input (if valid-handle(vhParentRowid) then vhParentRowid:buffer-value else '') (icParentRowid),
input ilHeaderOnly (ilHeaderOnly),
input ilSuppressEmptyFields (ilSuppressEmptyFields),
output viFcReturnSuper (oiReturnStatus)) in XML>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
vhQuery:query-close().
delete object vhQuery.
return.
end.
end.
vhQuery:get-next().
end.
vhQuery:query-close().
delete object vhQuery.
if oiReturnStatus = -98
then assign oiReturnStatus = 0.