project QadFinancials > class BBusinessRelation > method DumpBusinessRelationForConsolid

Description

This method will load the BusinessRelation that need to be dumped and dump them in a XML file.


Parameters


icBusinessRelationIDListinputcharacter
icDumpFileinputcharacter
icConsolCompanyinputcharacter
bcCountryIDListinput-outputcharacter
bcAddressTypeIDListinput-outputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BConsolidDump.AdditionalUpdatesPosting


program code (program1/bbusinessrelation.p)

If oiReturnStatus = 0
Then Assign oiReturnStatus = -98.

<M-1 run DataLoad (input  ? (icRowids),
                   input  icBusinessRelationIDList (icPkeys),
                   input  ? (icObjectIds),
                   input  ? (icFreeform),
                   input  False (ilKeepPrevious),
                   output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.

Assign bcCountryIDList     = Replace(bcCountryIDList,    Chr(4),',':U).
Assign bcAddressTypeIDList = Replace(bcAddressTypeIDList,Chr(4),',':U).

For Each tBusinessRelation:

    Assign
        tBusinessRelation.BusinessRelation_ID        = 0
        tBusinessRelation.CorporateGroup_ID          = 0
        tBusinessRelation.tcCorporateGroupCode       = '':U
        tBusinessRelation.Lng_ID                     = 0
        tBusinessRelation.BusinessRelationIsDomRestr = false
        tBusinessRelation.Domain_ID                  = 0
        tBusinessRelation.BusinessRelationIsActive  = True.

    For Each tAddress Where
             tAddress.tc_ParentRowid = tBusinessRelation.tc_Rowid:

        Assign
            tAddress.Lng_ID              = 0
            tAddress.tcLngCode           = '':U
            tAddress.tcLngDescription    = '':U
            tAddress.State_ID            = 0
            tAddress.tcStateCode         = '':U
            tAddress.tcStateDescription  = '':U
            tAddress.County_ID           = 0
            tAddress.tcCountyCode        = '':U
            tAddress.tcCountyDescription = '':U.

        If Not Can-do(bcCountryIDList + ",0":U, String(tAddress.Country_ID))
        Then Assign bcCountryIDList = bcCountryIDList + ',':U + String(tAddress.Country_ID).

        If Not Can-do(bcAddressTypeIDList + ",0":U, String(tAddress.AddressType_ID))
        Then Assign bcAddressTypeIDList = bcAddressTypeIDList + ',':U + String(tAddress.AddressType_ID).

        Assign
            tAddress.Address_ID     = 0
            tAddress.Country_ID     = 0
            tAddress.AddressType_ID = 0.

        For Each tContact Where
                 tContact.tc_ParentRowid = tAddress.tc_Rowid:
            Delete tContact.
        End.

    End. /* For Each tAddress Of tBusinessRelation */

    For Each tBusRelationSafDefault Where
             tBusRelationSafDefault.tc_ParentRowid = tBusinessRelation.tc_Rowid:
        Delete tBusRelationSafDefault.
    End.

    For Each tVatNumber Where
             tVatNumber.tc_ParentRowid = tBusinessRelation.tc_Rowid:
        Delete tVatNumber.
    End.

End. /* For Each tBusinessRelation */

Assign bcCountryIDList      = Replace(Trim(bcCountryIDList,    ',':U),',':U,Chr(4)).
Assign bcAddressTypeIDList  = Replace(Trim(bcAddressTypeIDList,',':U),',':U,Chr(4)).

<M-2 run DumpXmlRepresentation
   (input  icDumpFile (icFile),
    input  no (ilHeaderOnly),
    input  no (ilSuppressEmptyFields),
    input  0 (iiPriority),
    input  no (ilWriteXMLSchema),
    input  ? (icObjectRowId),
    output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.

create X-DOCUMENT vhDoc in widget-pool "non-persistent".
create X-NODEREF vhRoot in widget-pool "non-persistent".
create X-NODEREF vhNode in widget-pool "non-persistent".
create X-NODEREF vhNode2 in widget-pool "non-persistent".
create X-NODEREF vhValue in widget-pool "non-persistent".

vhDoc:load ("FILE":U, icDumpFile, no) no-error.

do viCnt = 1 to vhDoc:num-children:
    vhDoc:get-child(vhRoot,viCnt).
    if vhRoot:local-name = "object":U
    Then Leave.
end.
do viCnt = 1 to vhRoot:num-children:
    vhRoot:get-child(vhNode,viCnt).
    if vhNode:local-name   = "CompanyCode":U and
       vhNode:num-children = 1
    then do:
        vhNode:get-child(vhValue,1).
        if vhValue:name = "#text":U
        then do:
            vhValue:node-value = icConsolCompany.
        End.
    end.

    if vhNode:local-name   = "classRepresentation":U
    Then Do:
        vhDoc:create-node-namespace (vhNode2, "com.softcell.componentbuilder.class":U, "priority":U, "element":U).
        vhNode2:namespace-prefix = "cb":U.
        vhRoot:insert-before (vhNode2, vhNode).

        vhDoc:CREATE-NODE (vhValue, "", "TEXT":U).
        vhValue:NODE-VALUE = "210":U.
        vhNode2:APPEND-CHILD (vhValue).

        /*this is a must otherwise crash*/
        Assign viCnt = viCnt + 1.
    End.
end.

vhDoc:save ("file":U, icDumpFile) no-error.

delete object vhValue.
delete object vhNode2.
delete object vhNode.
delete object vhRoot.
delete object vhDoc.

<M-3 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.

If oiReturnStatus = -98
Then Assign oiReturnStatus = 0.