project QadFinancials > class BCompanyProperty > method UpdateCompanyProperty

Description

UpdateCompanyProperty


Parameters


tCompanyPropertyRefForUpdatesinputtemp-tableCompany property table
icActivityCodeinputcharacterActivity Code
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCompany.AdditionalUpdates


program code (program1/bcompanyproperty.p)

for each tCompanyPropertyRefForUpdates where 
         tCompanyPropertyRefForUpdates.tc_Status <> "":U:
    
    find first tCompanyProperty where
               tCompanyProperty.CompanyProperty_ID = tCompanyPropertyRefForUpdates.CompanyProperty_ID 
               no-error.
    if not available tCompanyProperty
    then do:
        if tCompanyPropertyRefForUpdates.tc_status = "N":U
        /* create a new record */
        then do:
            <M-1 run AddDetailLine (input  'CompanyProperty':U (icTable), 
                        input  '':U (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
            if viFcReturnSuper <> 0
            then do:
                /* error handling */
                <M-5 run SetMessage
          (input  #T-11'This detail line could not be added. Cannot create the entity property.':80(1306)t-11# (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'D':U (icType), 
           input  2 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-33':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
                assign oiReturnStatus = -1.
                return.
            end.
        end.
        /* load the existing record */
        else do:
            <M-2 run DataLoad
          (input  '':U (icRowids), 
           input  string(tCompanyPropertyRefForUpdates.CompanyProperty_ID) (icPkeys), 
           input  '':U (icObjectIds), 
           input  '' (icFreeform), 
           input  yes (ilKeepPrevious), 
           output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
            if viFcReturnSuper <> 0
            then do:
                /* error handling */
                <M-6 run SetMessage
          (input  #T-12'The data could not be loaded. Cannot display the entity property.':80(1307)t-12# (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'D':U (icType), 
           input  2 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-34':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
                assign oiReturnStatus = -1.
                return.
            end.
            if not available tCompanyProperty 
            then do:
                if can-find(first tCompanyProperty where tCompanyProperty.CompanyProperty_ID = tCompanyPropertyRefForUpdates.CompanyProperty_ID) 
                then do:
                    find first tCompanyProperty where tCompanyProperty.CompanyProperty_ID = tCompanyPropertyRefForUpdates.CompanyProperty_ID no-error.
                end.
                else do:
                    <M-8 run SetMessage
          (input  #T-13'The data has been successfully loaded but the entity property record is not available.':100(1308)t-13# (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'D':U (icType), 
           input  2 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-114':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>                    assign oiReturnStatus = -1.
                    return.                    
                end.
            end.
        end.
        
        if not available tCompanyProperty
        then do:
            /* errror handling */
            <M-7 run SetMessage
          (input  #T-14'Entity property is not available.':80(1309)t-14# (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'D':U (icType), 
           input  2 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-35':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
            assign oiReturnStatus = -1.
            return.
        end.
    end. /* if tCompanyPropery is not available */
    if tCompanyPropertyRefForUpdates.tc_status = "D":U
    then assign tCompanyProperty.tc_status = "D":U.
    else do:
        buffer-copy tCompanyPropertyRefForUpdates except CompanyProperty_ID tc_Rowid tc_ParentRowid to tCompanyProperty.
                   
        if tCompanyProperty.tcCurrencyCode <> "":U and 
           tCompanyProperty.tcCurrencyCode <> ?    and
           tCompanyProperty.tcCurrencyCode <> "?":U
        then do:
            <Q-15 run CurrencyPrim (all) (Read) (NoCache)
               (input tCompanyProperty.tcCurrencyCode, (CurrencyCode)
                input 0, (Currency_ID)
                output dataset tqCurrencyPrim) in BCurrency >
            find first tqCurrencyPrim no-error.
            if available tqCurrencyPrim
            then assign tCompanyProperty.Currency_ID = tqCurrencyPrim.tiCurrency_ID.
            else assign tCompanyProperty.Currency_ID = ?.
        end.   
    end.
end. /* for each */


<M-3 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

<M-4 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.