Description
This method is called from within the generic code to create an XML representation of a component instance.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program1/database.p)
if not available tContextInfo
then find first tContextInfo no-error.
if not available tContextInfo
then do:
create tContextInfo.
assign tContextInfo.tlPartialUpdate = no.
end.
/* add company code (not below parent node, but before parent node) */
<Q-1 run CompanyPrim (all) (Read) (NoCache)
(input viCompanyId, (LookupCompanyId)
input '', (CompanyCode)
output dataset tqCompanyPrim) in BCompany >
find first tqCompanyPrim where
tqCompanyPrim.tiCompany_ID = viCompanyId no-error.
if available tqCompanyPrim
then do:
assign tContextInfo.tcCompanyCode = tqCompanyPrim.tcCompanyCode.
end.
/* determine a pipe separated list of companies involved
- if the main table has no Company_ID and SharedSet_ID fields, the list of all company codes should be retrieved
- if the main table has a Company_ID field, then only that company code should be retrieved
- if the main table has a SharedSet_ID field, then the company codes that are linked to the shared set should be retrieved.
*/
find first tFcDynRel where tFcDynRel.tcFcFrom = "" no-error.
if available tFcDynRel
then do:
assign vhBuffer = tFcDynRel.thFcBuffer.
assign vhCYID = vhBuffer:buffer-field("Company_ID":U)
vhSSID = vhBuffer:buffer-field("SharedSet_ID":U) no-error.
if valid-handle(vhCYID)
or valid-handle(vhSSID)
then do:
create query vhQuery in widget-pool "non-persistent".
vhQuery:forward-only = yes.
vhQuery:set-buffers(vhBuffer).
vhQuery:query-prepare("for each ":U + vhBuffer:name).
vhQuery:query-open().
vhQuery:get-first().
do while not vhQuery:query-off-end:
if valid-handle(vhCYID)
then if not can-do (vcCYList,string(vhCYID:buffer-value))
then do:
assign vcCYList = vcCYList + ",":U + string(vhCYID:buffer-value).
<Q-5 run CompanyPrim (all) (Read) (NoCache)
(input integer(vhCYID:buffer-value), (LookupCompanyId)
input '', (CompanyCode)
output dataset tqCompanyPrim) in BCompany >
for each tqCompanyPrim on error undo, throw:
if lookup(tqCompanyPrim.tcCompanyCode,vcInvolvedCompanyCodes,"|":U) = 0
then assign vcInvolvedCompanyCodes = vcInvolvedCompanyCodes + "|":U + tqCompanyPrim.tcCompanyCode.
end.
end.
if valid-handle(vhSSID)
then if not can-do (vcCYList,string(vhSSID:buffer-value))
then do:
assign vcCYList = vcCYList + ",":U + string(vhSSID:buffer-value).
<Q-6 run CompanySharedSetBySharedSet (all) (Read) (NoCache) (input integer(vhSSID:buffer-value), (SharedSetId)
input 0, (CompanyId)
output dataset tqCompanySharedSetBySharedSet) in BCompany >
for each tqCompanySharedSetBySharedSet on error undo, throw:
if lookup(tqCompanySharedSetBySharedSet.tcCompanyCode,vcInvolvedCompanyCodes,"|":U) = 0
then assign vcInvolvedCompanyCodes = vcInvolvedCompanyCodes + "|":U + tqCompanySharedSetBySharedSet.tcCompanyCode.
end.
end.
vhQuery:get-next().
end.
vhQuery:query-close().
delete object vhQuery.
vhQuery = ?.
end.
else do:
<Q-4 run CompanyPrim (all) (Read) (NoCache)
(input 0, (LookupCompanyId)
input '', (CompanyCode)
output dataset tqCompanyPrim) in BCompany >
for each tqCompanyPrim on error undo, throw:
assign vcInvolvedCompanyCodes = vcInvolvedCompanyCodes + "|":U + tqCompanyPrim.tcCompanyCode.
end.
end.
assign tContextInfo.tcInvolvedCompanyCodes = substring (vcInvolvedCompanyCodes,2,-1,"CHARACTER":U).
end.
finally:
empty temp-table tqCompanyPrim.
empty temp-table tqCompanySharedSetBySharedSet.
if vhQuery <> ? then delete object vhQuery.
end finally.