project BLF > class BCompany > method Calculate

Description

Add code here to initialize the calculated fields of the class temp-tables after loading existing records from the application database.


Parameters


oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bcompany.p)

<ANCESTOR-CODE>

assign vcListSharedSetTypeCode  = <M-9 GetSharedSetTypes () in BCompany>.

for each tCompany on error undo, throw:

    if vlDataLoadKeepPrevious and can-find (tAlreadyCalculatedRecords where
             tAlreadyCalculatedRecords.tcTableName = "Company" and
             tAlreadyCalculatedRecords.tc_Rowid = tCompany .tc_Rowid)
    then next.

    /* ============================ */
    /* Company SharedSet properties */
    /* ============================ */
    for each tCompanySharedSet on error undo, throw:
        <Q-6 run SharedSetByIDCodeType (all) (Read) (NoCache)
           (input '':U, (SharedSetCode)
            input ?, (SharedSetIsActive)
            input '':U, (SharedSetTypeCode)
            input tCompanySharedSet.SharedSet_ID, (SharedSetID)
            output dataset tqSharedSetByIDCodeType) in BSharedSet >
        find tqSharedSetByIDCodeType where 
             tqSharedSetByIDCodeType.tiSharedSet_ID = tCompanySharedSet.SharedSet_ID
             no-error.
        if available tqSharedSetByIDCodeType
        then do:
           assign tCompanySharedSet.tcSharedSetCode     = tqSharedSetByIDCodeType.tcSharedSetCode
                  tCompanySharedSet.tcSharedSetTypeCode = tqSharedSetByIDCodeType.tcSharedSetTypeCode.
           /* retrieve traslated string */
           assign vcSharedSetTypeTranslated = "":U.
          
            do viSharedSetCounter = num-entries(vcListSharedSetTypeCode, chr(2)) to 1 by -2:
  	            if entry(viSharedSetCounter, vcListSharedSetTypeCode, chr(2)) = tCompanySharedSet.tcSharedSetTypeCode
                then do:
                    assign tCompanySharedSet.tcSharedSetTypeTranslated = entry(viSharedSetCounter - 1, vcListSharedSetTypeCode, chr(2)).
                    leave.
                end.
            end. /* do viIndex = num-entries(vcSharedSetTypeCodes, chr(2)) to 1 by -2: */
        end.
    end.
    
    /* ============================ */
    /* Company SharedSet creation   */
    /* ============================ */
    do viSharedSetCounter = num-entries(vcListSharedSetTypeCode,chr(2)) to 1 by -2 :
        if not can-find (first tCompanySharedSet where 
                               tCompanySharedSet.tc_ParentRowid        = tCompany.tc_Rowid and
                               tCompanySharedSet.tc_Status            <> "D":U             and
                               tCompanySharedSet.tcSharedSetTypeCode   = entry(viSharedSetCounter,vcListSharedSetTypeCode,chr(2)))
        then do :
             <M-2 run AddDetailLine (input  'CompanySharedSet':U (icTable), 
                        input  tCompany.tc_Rowid (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BCompany>
            assign tCompanySharedSet.tcSharedSetTypeCode       = entry(viSharedSetCounter,vcListSharedSetTypeCode,chr(2)) 
                   tCompanySharedSet.tcSharedSetTypeTranslated = entry(viSharedSetCounter - 1, vcListSharedSetTypeCode, chr(2)).
        end. /* if not can-find */
    end. /* do */
    
end.