project BLF > class Database Component > method XmlColumnDetail

Description

This method is called from within the generic code to create an XML representation of a component instance. It is called for each column in the component that is represented in the XML document.
In this method, one can add method calls to other components for sub-representations. For example: customer information on an order object.

/** EXAMPLE CODE
assign oiReturnStatus = -98.

case icTableName :
when "order":U
then case icColumnName :
when "custnum":U
then do :
if not available torder or
rowid(tOrder) <> ihBuffer:rowid
then buffer tOrder:find-by-rowid(ihBuffer:rowid) no-error.
if available tOrder
then do :
run XMLrepresentation (input torder.custnum (icKey),
input 'customer.name':U (icColumns),
input ihCurrentNode (ihStartingNode),
output viFcReturnSuper (oiReturnStatus)) in bOrder
end.
end.
end case.
end case.
assign oiReturnStatus = viFcReturnSuper.
**/


Parameters


icTableNameinputcharacterName of the (class) table to which the column belongs.
icColumnNameinputcharacterName of the concerning column
ihBufferinputhandleHandle to the table buffer
ihFieldinputhandle
ihParentNodeinputhandleHandle to the current XML node.
ilSuppressEmptyFieldsinputlogicalif true, the empty fields will be dropped out of the xml representation.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method XML.ConvertTableToXmlSingleTable


program code (program1/database.p)

if icTableName  begins "CustomTable":U
or icColumnName begins "CustomShort":U
or icColumnName begins "CustomCombo":U
or icColumnName begins "CustomLong":U
or icColumnName begins "CustomNote":U
or icColumnName begins "CustomDate":U
or icColumnName begins "CustomInteger":U
or icColumnName begins "CustomDecimal":U
or icColumnName begins "QADC0":U
or icColumnName begins "QADD0":U
or icColumnName begins "QADT0":U
then do:
    find first tCustomFieldsDefined where
               tCustomFieldsDefined.tcTableName = icTableName no-error.
    if not available tCustomFieldsDefined
    then do:
        create tCustomFieldsDefined.
        assign tCustomFieldsDefined.tcTableName = icTableName.
    
        <Q-1 run GetCustomFieldsForTable (all) (Read) (NoCache)
           (input 't':U + icTableName, (TableName)
            input vcFcComponentName, (ComponentName)
            output dataset tqCustomFieldsForTable) in BCustomField >
    
        if icTableName begins "CustomTable":U
        then do:
            <Q-2 run GetCustomFieldsForTable (all) (Append) (NoCache)
               (input vcFcComponentName + ':t':U + icTableName, (TableName)
                input vcFcComponentName, (ComponentName)
                output dataset tqCustomFieldsForTable) in BCustomField >
        end.
        
        for each tqCustomFieldsForTable on error undo, throw:
            assign tCustomFieldsDefined.tcFieldNames     = tCustomFieldsDefined.tcFieldNames + ",":U
                                                         + entry (2,tqCustomFieldsForTable.tcCustomFieldFieldName,".":U)
                   tCustomFieldsDefined.tcFieldLabels    = tCustomFieldsDefined.tcFieldLabels + ",":U
                                                         + tqCustomFieldsForTable.tcCustomFieldColumnLabel
                   tCustomFieldsDefined.tcFieldDataTypes = tCustomFieldsDefined.tcFieldDataTypes + ",":U
                                                         + tqCustomFieldsForTable.tcCustomFieldDataType.
        end.
    end.
    
    assign viFcCount1 = lookup (icColumnName, tCustomFieldsDefined.tcFieldNames).

    if viFcCount1 > 0
    then do:
        vlSuppress = no.
        
        if ilSuppressEmptyFields = yes
        then do:
            if ihField:data-type = "character"
            then vlSuppress = (ihField:buffer-value = "" or ihField:buffer-value = ?).
            else vlSuppress = (ihField:buffer-value = ?).
        end.
        else
        if ilSuppressEmptyFields = ?
        then do:
            if ihField:data-type = "character"
            then vlSuppress = (ihField:buffer-value = "").
            else if ihField:data-type = "integer"
                 or ihField:data-type = "decimal"
            then vlSuppress = (ihField:buffer-value = 0).
            else vlSuppress = (ihField:buffer-value = ?).
        end.
        
        if vlSuppress
        then ihParentNode:delete-node.
        else ihParentNode:set-attribute ("label":U, entry(viFcCount1,tCustomFieldsDefined.tcFieldLabels)).
    end.
    /* if the custombusiness fields is not activated, the node will be deleted */
    /* QAD reserved fields should not be deleted */
    else if icColumnName begins "Custom"
    then ihParentNode:delete-node.
end.