project QadFinancials > class BAccountingInterface > method FillProDsChartOfAccnt

Description

This method is used to generate prodataset for Chart of Account Report.


Parameters


ohChartOfAccntoutputhandleHandle for Chart of Account Prodataset.
icGLAccntStructureinputcharacterGL Account Structure.
iiBudgetLevelinputintegerBudget Level.
icReportStructBSinputcharacterReport Sturcture of Balance Sheet Report.
icReportStructISinputcharacterReport Structure of Income Statement Report.
icCOACrossRefCodeinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAccountingInterface.BulidProDataSet


program code (program3/baccountinginterface.p)

assign oiReturnStatus = -98.
/* Empty temp-tables which will be used later */
empty temp-table tReport.
empty temp-table tChartOfAccnt.
/* Do validation of BudgetLevel */
if iiBudgetLevel < 0 or iiBudgetLevel > 8
then do:
    assign oiReturnStatus = -1.
    <M-13 run SetMessage
       (input  #T-4'The budget level must be an integer between 0 and 8 if you want to export the Chart of Account file.':200(59873)T-4# (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  '':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-6122':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
    return.
end. /* if iiBudgetLevel < 0 or iiBudgetLevel > 8 */

/* to create a temp table, due to EDI limitation */
create tReport.
assign tReport.tiReportID = 1.


if icCOACrossRefCode <> "" and icCOACrossRefCode <> ?
then do:
    <Q-79 run COACrossRefByAll (all) (Read) (NoCache)
       (input ?, (COACrossRefID)
        input viDomainID, (SourceDomainID)
        input ?, (TargetDomainID)
        input ?, (AltCOAStructID)
        input icCOACrossRefCode, (COACrossRefCode)
        input {&COACROSSREFTYPE-ALTERNATE}, (COACrossRefType)
        input ?, (COACrossRefIsActive)
        input ?, (SourceDomainCode)
        input ?, (TargetDomainCode)
        input ?, (AltCOAStructCode)
        output dataset tqCOACrossRefByAll) in BCOACrossRef >
    find first tqCOACrossRefByAll no-error.
    if not available tqCOACrossRefByAll
    then do:
        <M-80 run SetMessage
           (input  #T-81'Invalid Alternate COA cross reference code.':255(52845713)T-81# (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-9643':U:U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
        assign oiReturnStatus = -1.
        return.
    end.
end. /* if icCOACrossRefCode <> "" and icCOACrossRefCode <> ? */

/* Start an instance of BGLReport in order to invoke its method */
if viBBudgetID = 0 or viBBudgetID = ?
then do:
    <I-35 {bFcStartAndOpenInstance
         &CLASS                = "BBudget"}>
end.
else do:
    <I-36 {bFcStartInstance
         &CLASS                = "BBudget"}>
end.

<Q-52 run GLByCode  (Start) in BGL >
<Q-66 run GLBySSOthers  (Start) in BGL >
<Q-67 run AltCOAStructDetByGroupID  (Start) in BAltCOAStruct >

/* Get the BS Budget WBS records */
empty temp-table ttmpBudgetWBS.
assign vhFcComponent = ?.
assign viBudPrimID = 0.
<M-39 run ApiGetBudgetWBS
   (input  viBudPrimID (iiBudgetID), 
    input  icReportStructBS (icBudgetCode), 
    input  0 (iiProjectID), 
    input  '' (icProjectCode), 
    input  0 (iiCostCentreID), 
    input  '' (icCostCentreCode), 
    input  no (ilSkipLevelOneNodes), 
    input  no (ilSkipJointOperResNodes), 
    input  no (ilSkipOverheadNodes), 
    input  no (ilSkipDraftNodes), 
    input  no (ilSkipPureRevenueNodes), 
    input  no (ilSkipPureCostNodes), 
    input  '' (icRestrictedBusComponent), 
    input  no (ilAssignBudgetWBSIsSelectable), 
    output ttmpBudgetWBS (tViewBudgetWBS), 
    output viBudPrimID (oiBudgetID), 
    output oiReturnStatus (oiReturnStatus)) in BBudget>
/* If the user hasn't specified a report structure then return an error */
if not can-find(first ttmpBudgetWBS where ttmpBudgetWBS.tlBudgetIsReportStruct = yes)
then do:
    <M-42 run SetMessage
       (input  #T-42'Invalid BS report structure entered':255(693659995)T-42# (icMessage), 
        input  '' (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E' (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-9494':U (icFcMsgNumber), 
        input  #T-43'You must enter a valid report structure in the selection criteria for this report':255(999890326)T-43# (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output oiReturnStatus (oiReturnStatus)) in BAccountingInterface>
    assign oiReturnStatus = -1.
    <I-104 {bFcCloseInstance
         &CLASS           = "BBudget"}>
    return.
end. /* if not can-find(first ttmpBudgetWBS where */

for each ttmpBudgetWBS where ttmpBudgetWBS.tcFDSType = "GL":U:
    if ttmpBudgetWBS.tiAltCOAGroup_ID <> 0
    then do:
        /* Get the whole sub-AltCOAStruct of the Alternate COA Group */
        <Q-65 run AltCOAStructDetByGroupID (all) (Read) (NoCache)
           (input ttmpBudgetWBS.tiAltCOAGroup_ID, (AltCOAStructGroupID)
            input tqCOACrossRefByAll.tiAltCOAStruct_ID, (AltCOAStructID)
            output dataset tqAltCOAStructDetByGroupID) in BAltCOAStruct >
        for each tqAltCOAStructDetByGroupID /*where
            tqAltCOAStructDetByGroupID.tiAltCOAStruct_ID = tqCOACrossRefByAll.tiAltCOAStruct_ID*/ :
            create tChartOfAccnt.
            assign
                tChartOfAccnt.tcAccntNo          = tqAltCOAStructDetByGroupID.tcAltCOAStructDetCode
                tChartOfAccnt.tcAccntName        = tqAltCOAStructDetByGroupID.tcAltCOAStructDetDescription
                tChartOfAccnt.tiAccntLevel       = tqAltCOAStructDetByGroupID.tiAltCOAStructDetLevel
                tChartOfAccnt.tcSubAccntFlag     = '0'
                tChartOfAccnt.tcSubAccntItem     = ''
                tChartOfAccnt.tcAccntType        = ttmpBudgetWBS.tcBudgetWBSCategory
                tChartOfAccnt.tcUnitOfMeasure    = ''
                tChartOfAccnt.tcBalanceDirection = ''
                tChartOfAccnt.tiReportID         = 1.
        end.
    end. /* if ttmpBudgetWBS.tiAltCOAGroup_ID <> 0 */

    else if num-entries(ttmpBudgetWBS.tcBudgetWBSFDSList) > 0
    then do:
        do viCount = 1 to num-entries(ttmpBudgetWBS.tcBudgetWBSFDSList):
            assign vcGLCodeTemp = entry(viCount, ttmpBudgetWBS.tcBudgetWBSFDSList).
            <Q-46 run GLByCode (all) (Read) (NoCache)
               (input viCompanyId, (CompanyId)
                input vcGLCodeTemp, (GLCode)
                output dataset tqGLByCode) in BGL >
            find first tqGLByCode no-error.
            if not available tqGLByCode
            then next.

            create tChartOfAccnt.
            assign
                tChartOfAccnt.tcAccntNo       = tqGLByCode.tcGLCode
                tChartOfAccnt.tcAccntName     = tqGLByCode.tcGLDescription
                tChartOfAccnt.tiAccntLevel    = 0
                tChartOfAccnt.tcSubAccntFlag  = '0'
                tChartOfAccnt.tcSubAccntItem  = ''
                tChartOfAccnt.tcAccntType     = tqGLByCode.tcGLCategory
                tChartOfAccnt.tcUnitOfMeasure = ''
                tChartOfAccnt.tiReportID      = 1.
            if tqGLByCode.tlGLIsDebitAccount = yes
            then assign tChartOfAccnt.tcBalanceDirection = #T-47'DR':2(4525)T-47#.
            else assign tChartOfAccnt.tcBalanceDirection = #T-48'CR':2(4524)T-48#.

            /* Initialize some variables for loop */
            assign
                vii = 1
                vilength = 0
                vlisdone = no
                tChartOfAccnt.tiAccntLevel = 0. 
            /* Logic to judge the level */
            repeat while vii <= num-entries(icGLAccntStructure):
                assign vilength = vilength + integer(entry(vii, icGLAccntStructure)).
                if vilength >= length(tqGLByCode.tcGLCode, 'CHARACTER') and vlisdone = no
                then do:
                    assign
                        tChartOfAccnt.tiAccntLevel = vii
                        vlisdone = yes.
                end.
                assign vii = vii + 1.
            end. /* repeat while vii <= num-entries(icGLAccntStructure): */
            if tChartOfAccnt.tiAccntLevel = 0
            then do:
                assign oiReturnStatus = -1.
                <M-51 run SetMessage
                   (input  #T-51'The GL accounting structure is invalid.':40(59874)T-51# (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'QadFin-9495':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
                <I-103 {bFcCloseInstance
                     &CLASS           = "BBudget"}>
                return.
            end. /* if tChartOfAccnt.tiAccntLevel = 0 */
        end. /* do vicount = 1 to num-entries(ttmpBudgetWBS.tcBudgetWBSFDSList) */
    end. /* else if num-entries(ttmpBudgetWBS.tcBudgetWBSFDSList) > 0 */

    else if (ttmpBudgetWBS.tcBudgetWBSFDSFromcode <> ""  and
             ttmpBudgetWBS.tcBudgetWBSFDSToCode   <> "") or
             ttmpBudgetWBS.tiBudgetGroup_ID       <> 0
    then do:
        if ttmpBudgetWBS.tiBudgetGroup_ID <> 0
        then do:
            <Q-64 run GLBySSOthers (all) (Read) (NoCache)
               (input viCompanyId, (CompanyId)
                input ?, (FromGLCode)
                input ?, (ToGLCode)
                input ttmpBudgetWBS.tiGLSharedSet_ID, (GLSharedSetID)
                input ?, (MatchingGLCode)
                input ?, (GLCode)
                input ttmpBudgetWBS.tiBudgetGroup_ID, (BudgetGroupID)
                output dataset tqGLBySSOthers) in BGL >
        end.
        else do:
            <Q-63 run GLBySSOthers (all) (Read) (NoCache)
               (input viCompanyId, (CompanyId)
                input ttmpBudgetWBS.tcBudgetWBSFDSFromCode, (FromGLCode)
                input ttmpBudgetWBS.tcBudgetWBSFDSToCode, (ToGLCode)
                input ttmpBudgetWBS.tiGLSharedSet_ID, (GLSharedSetID)
                input ?, (MatchingGLCode)
                input ?, (GLCode)
                input ?, (BudgetGroupID)
                output dataset tqGLBySSOthers) in BGL >
        end.

        for each tqGLBySSOthers:
            <Q-59 run GLByCode (all) (Read) (NoCache)
               (input viCompanyId, (CompanyId)
                input tqGLBySSOthers.tcGLCode, (GLCode)
                output dataset tqGLByCode) in BGL >
            find first tqGLByCode no-error.
            if not available tqGLByCode
            then next.

            create tChartOfAccnt.
            assign
                tChartOfAccnt.tcAccntNo       = tqGLByCode.tcGLCode
                tChartOfAccnt.tcAccntName     = tqGLByCode.tcGLDescription
                tChartOfAccnt.tiAccntLevel    = 0
                tChartOfAccnt.tcSubAccntFlag  = '0'
                tChartOfAccnt.tcSubAccntItem  = ''
                tChartOfAccnt.tcAccntType     = tqGLByCode.tcGLCategory
                tChartOfAccnt.tcUnitOfMeasure = ''
                tChartOfAccnt.tiReportID      = 1.
            if tqGLByCode.tlGLIsDebitAccount = yes
            then assign tChartOfAccnt.tcBalanceDirection = #T-56'DR':2(4525)T-56#.
            else assign tChartOfAccnt.tcBalanceDirection = #T-57'CR':2(4524)T-57#.

            /* Initialize some variables for loop */
            assign
                vii = 1
                vilength = 0
                vlisdone = no
                tChartOfAccnt.tiAccntLevel = 0. 
            /* Logic to judge the level */
            repeat while vii <= num-entries(icGLAccntStructure):
                assign vilength = vilength + integer(entry(vii, icGLAccntStructure)).
                if vilength >= length(tqGLByCode.tcGLCode, 'CHARACTER') and vlisdone = no
                then do:
                    assign
                        tChartOfAccnt.tiAccntLevel = vii
                        vlisdone = yes.
                end.
                assign vii = vii + 1.
            end. /* repeat while vii <= num-entries(icGLAccntStructure): */
            if tChartOfAccnt.tiAccntLevel = 0
            then do:
                assign oiReturnStatus = -1.
                <M-60 run SetMessage
                   (input  #T-61'The GL accounting structure is invalid.':40(59874)T-61# (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'QadFin-9641':U:U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
                <I-102 {bFcCloseInstance
                     &CLASS           = "BBudget"}>
                return.
            end. /* if tChartOfAccnt.tiAccntLevel = 0 */
        end. /* for each tqGLBySSOthers */
    end. /* else if ttmpBudgetWBS.tcBudgetWBSFDSFromcode <> "" and */
end. /* for each ttmpBudgetWBS where ttmpBudgetWBS.tcFDSType = "GL":U */

/* Get the IS Budget WBS records */
empty temp-table ttmpBudgetWBS.
assign vhFcComponent = ?.
assign viBudPrimID = 0.
<M-82 run ApiGetBudgetWBS
   (input  viBudPrimID (iiBudgetID), 
    input  icReportStructIS (icBudgetCode), 
    input  0 (iiProjectID), 
    input  '' (icProjectCode), 
    input  0 (iiCostCentreID), 
    input  '' (icCostCentreCode), 
    input  no (ilSkipLevelOneNodes), 
    input  no (ilSkipJointOperResNodes), 
    input  no (ilSkipOverheadNodes), 
    input  no (ilSkipDraftNodes), 
    input  no (ilSkipPureRevenueNodes), 
    input  no (ilSkipPureCostNodes), 
    input  '' (icRestrictedBusComponent), 
    input  no (ilAssignBudgetWBSIsSelectable), 
    output ttmpBudgetWBS (tViewBudgetWBS), 
    output viBudPrimID (oiBudgetID), 
    output oiReturnStatus (oiReturnStatus)) in BBudget>
/* If the user hasn't specified a report structure then return an error */
if not can-find(first ttmpBudgetWBS where ttmpBudgetWBS.tlBudgetIsReportStruct = yes)
then do:
    <M-83 run SetMessage
       (input  #T-91'Invalid IS report structure entered':255(188984953)T-91# (icMessage), 
        input  '' (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E' (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-9595':U:U (icFcMsgNumber), 
        input  #T-92'You must enter a valid report structure in the selection criteria for this report':255(999890326)T-92# (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output oiReturnStatus (oiReturnStatus)) in BAccountingInterface>
    assign oiReturnStatus = -1.
    <I-101 {bFcCloseInstance
         &CLASS           = "BBudget"}>
    return.
end. /* if not can-find(first ttmpBudgetWBS where */

for each ttmpBudgetWBS where ttmpBudgetWBS.tcFDSType = "GL":U:
    if ttmpBudgetWBS.tiAltCOAGroup_ID <> 0
    then do:
        /* Get the whole sub-AltCOAStruct of the Alternate COA Group */
        <Q-84 run AltCOAStructDetByGroupID (all) (Read) (NoCache)
           (input ttmpBudgetWBS.tiAltCOAGroup_ID, (AltCOAStructGroupID)
            input tqCOACrossRefByAll.tiAltCOAStruct_ID, (AltCOAStructID)
            output dataset tqAltCOAStructDetByGroupID) in BAltCOAStruct >
        for each tqAltCOAStructDetByGroupID /*where
            tqAltCOAStructDetByGroupID.tiAltCOAStruct_ID = tqCOACrossRefByAll.tiAltCOAStruct_ID*/ :
            create tChartOfAccnt.
            assign
                tChartOfAccnt.tcAccntNo          = tqAltCOAStructDetByGroupID.tcAltCOAStructDetCode
                tChartOfAccnt.tcAccntName        = tqAltCOAStructDetByGroupID.tcAltCOAStructDetDescription
                tChartOfAccnt.tiAccntLevel       = tqAltCOAStructDetByGroupID.tiAltCOAStructDetLevel
                tChartOfAccnt.tcSubAccntFlag     = '0'
                tChartOfAccnt.tcSubAccntItem     = ''
                tChartOfAccnt.tcAccntType        = ttmpBudgetWBS.tcBudgetWBSCategory
                tChartOfAccnt.tcUnitOfMeasure    = ''
                tChartOfAccnt.tcBalanceDirection = ''
                tChartOfAccnt.tiReportID         = 1.
        end.
    end. /* if ttmpBudgetWBS.tiAltCOAGroup_ID <> 0 */

    else if num-entries(ttmpBudgetWBS.tcBudgetWBSFDSList) > 0
    then do:
        do viCount = 1 to num-entries(ttmpBudgetWBS.tcBudgetWBSFDSList):
            assign vcGLCodeTemp = entry(viCount, ttmpBudgetWBS.tcBudgetWBSFDSList).
            <Q-85 run GLByCode (all) (Read) (NoCache)
               (input viCompanyId, (CompanyId)
                input vcGLCodeTemp, (GLCode)
                output dataset tqGLByCode) in BGL >
            find first tqGLByCode no-error.
            if not available tqGLByCode
            then next.

            create tChartOfAccnt.
            assign
                tChartOfAccnt.tcAccntNo       = tqGLByCode.tcGLCode
                tChartOfAccnt.tcAccntName     = tqGLByCode.tcGLDescription
                tChartOfAccnt.tiAccntLevel    = 0
                tChartOfAccnt.tcSubAccntFlag  = '0'
                tChartOfAccnt.tcSubAccntItem  = ''
                tChartOfAccnt.tcAccntType     = tqGLByCode.tcGLCategory
                tChartOfAccnt.tcUnitOfMeasure = ''
                tChartOfAccnt.tiReportID      = 1.
            if tqGLByCode.tlGLIsDebitAccount = yes
            then assign tChartOfAccnt.tcBalanceDirection = #T-93'DR':2(4525)T-93#.
            else assign tChartOfAccnt.tcBalanceDirection = #T-94'CR':2(4524)T-94#.

            /* Initialize some variables for loop */
            assign
                vii = 1
                vilength = 0
                vlisdone = no
                tChartOfAccnt.tiAccntLevel = 0. 
            /* Logic to judge the level */
            repeat while vii <= num-entries(icGLAccntStructure):
                assign vilength = vilength + integer(entry(vii, icGLAccntStructure)).
                if vilength >= length(tqGLByCode.tcGLCode, 'CHARACTER') and vlisdone = no
                then do:
                    assign
                        tChartOfAccnt.tiAccntLevel = vii
                        vlisdone = yes.
                end.
                assign vii = vii + 1.
            end. /* repeat while vii <= num-entries(icGLAccntStructure): */
            if tChartOfAccnt.tiAccntLevel = 0
            then do:
                assign oiReturnStatus = -1.
                <M-86 run SetMessage
                   (input  #T-95'The GL accounting structure is invalid.':40(59874)T-95# (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'QadFin-9651':U:U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
                <I-100 {bFcCloseInstance
                     &CLASS           = "BBudget"}>
                return.
            end. /* if tChartOfAccnt.tiAccntLevel = 0 */
        end. /* do vicount = 1 to num-entries(ttmpBudgetWBS.tcBudgetWBSFDSList) */
    end. /* else if num-entries(ttmpBudgetWBS.tcBudgetWBSFDSList) > 0 */

    else if (ttmpBudgetWBS.tcBudgetWBSFDSFromcode <> ""  and
             ttmpBudgetWBS.tcBudgetWBSFDSToCode   <> "") or
             ttmpBudgetWBS.tiBudgetGroup_ID       <> 0
    then do:
        if ttmpBudgetWBS.tiBudgetGroup_ID <> 0
        then do:
            <Q-87 run GLBySSOthers (all) (Read) (NoCache)
               (input viCompanyId, (CompanyId)
                input ?, (FromGLCode)
                input ?, (ToGLCode)
                input ttmpBudgetWBS.tiGLSharedSet_ID, (GLSharedSetID)
                input ?, (MatchingGLCode)
                input ?, (GLCode)
                input ttmpBudgetWBS.tiBudgetGroup_ID, (BudgetGroupID)
                output dataset tqGLBySSOthers) in BGL >
        end.
        else do:
            <Q-88 run GLBySSOthers (all) (Read) (NoCache)
               (input viCompanyId, (CompanyId)
                input ttmpBudgetWBS.tcBudgetWBSFDSFromCode, (FromGLCode)
                input ttmpBudgetWBS.tcBudgetWBSFDSToCode, (ToGLCode)
                input ttmpBudgetWBS.tiGLSharedSet_ID, (GLSharedSetID)
                input ?, (MatchingGLCode)
                input ?, (GLCode)
                input ?, (BudgetGroupID)
                output dataset tqGLBySSOthers) in BGL >
        end.

        for each tqGLBySSOthers:
            <Q-89 run GLByCode (all) (Read) (NoCache)
               (input viCompanyId, (CompanyId)
                input tqGLBySSOthers.tcGLCode, (GLCode)
                output dataset tqGLByCode) in BGL >
            find first tqGLByCode no-error.
            if not available tqGLByCode
            then next.

            create tChartOfAccnt.
            assign
                tChartOfAccnt.tcAccntNo       = tqGLByCode.tcGLCode
                tChartOfAccnt.tcAccntName     = tqGLByCode.tcGLDescription
                tChartOfAccnt.tiAccntLevel    = 0
                tChartOfAccnt.tcSubAccntFlag  = '0'
                tChartOfAccnt.tcSubAccntItem  = ''
                tChartOfAccnt.tcAccntType     = tqGLByCode.tcGLCategory
                tChartOfAccnt.tcUnitOfMeasure = ''
                tChartOfAccnt.tiReportID      = 1.
            if tqGLByCode.tlGLIsDebitAccount = yes
            then assign tChartOfAccnt.tcBalanceDirection = #T-96'DR':2(4525)T-96#.
            else assign tChartOfAccnt.tcBalanceDirection = #T-97'CR':2(4524)T-97#.

            /* Initialize some variables for loop */
            assign
                vii = 1
                vilength = 0
                vlisdone = no
                tChartOfAccnt.tiAccntLevel = 0. 
            /* Logic to judge the level */
            repeat while vii <= num-entries(icGLAccntStructure):
                assign vilength = vilength + integer(entry(vii, icGLAccntStructure)).
                if vilength >= length(tqGLByCode.tcGLCode, 'CHARACTER') and vlisdone = no
                then do:
                    assign
                        tChartOfAccnt.tiAccntLevel = vii
                        vlisdone = yes.
                end.
                assign vii = vii + 1.
            end. /* repeat while vii <= num-entries(icGLAccntStructure): */
            if tChartOfAccnt.tiAccntLevel = 0
            then do:
                assign oiReturnStatus = -1.
                <M-90 run SetMessage
                   (input  #T-98'The GL accounting structure is invalid.':40(59874)T-98# (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'QadFin-9564':U:U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
                <I-99 {bFcCloseInstance
                     &CLASS           = "BBudget"}>
                return.
            end. /* if tChartOfAccnt.tiAccntLevel = 0 */
        end. /* for each tqGLBySSOthers */
    end. /* else if ttmpBudgetWBS.tcBudgetWBSFDSFromcode <> "" and */
end. /* for each ttmpBudgetWBS where ttmpBudgetWBS.tcFDSType = "GL":U */

<Q-53 run GLByCode  (Stop) in BGL >
<Q-68 run GLBySSOthers  (Stop) in BGL >
<Q-69 run AltCOAStructDetByGroupID  (Stop) in BAltCOAStruct >

/* Close the instance */
<I-38 {bFcCloseInstance
     &CLASS           = "BBudget"}>


/* Use prodataset to encapsulate the temp-table */
/*
create dataset ohChartOfAccnt in widget-pool "non-persistent".
ohChartOfAccnt:set-buffers(buffer tReport:handle, buffer tChartOfAccnt:handle).
ohChartOfAccnt:add-relation(buffer tReport:handle, buffer tChartOfAccnt:handle,'tiReportID,tiReportID',?,true).
ohChartOfAccnt:name = {&EXPORTREPORTCODE-KJKM}.
*/

create dataset ohChartOfAccnt in widget-pool "non-persistent". 
create buffer vhReport for table buffer tReport:handle in widget-pool "non-persistent".
create buffer vhChartOfAccnt for table buffer tChartOfAccnt:handle in widget-pool "non-persistent".
ohChartOfAccnt:set-buffers(vhReport, vhChartOfAccnt).
ohChartOfAccnt:add-relation(vhReport, vhChartOfAccnt, 'tiReportID,tiReportID', ?, true).
ohChartOfAccnt:name = {&EXPORTREPORTCODE-KJKM}.


if oiReturnStatus = -98
then assign oiReturnStatus = 0.