project QadFinancials > class BAPMatching > method InitInstance

Description

This method can be extended with code to execute when an instance of a business class is started.

PreCondition

This method is executed when a new instance of the business class is started, or when a draft instance is opened (in that case a new instance is started which is a copy of the draft instance).


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program/bapmatching.p)

<ANCESTOR-CODE>
    
/* ==================================================================================================================== */
/* Set initial value for a data-item that is used to fill the rowid of records in a temp-table that is passed to the UI */
/* ==================================================================================================================== */
assign viRowidPendingVoucherAPM    = -2147483648
       viRowidPendingVoucherTaxAPM = -2147483648.

/* ==================================================================================================================== */
/* Add new public, inst-dep data-item vlAutoSelectDefaultValue that indicates whether the flag 'Auto se;ect' on the     */
/* filter area of the form should be default on or off. Filled in method InitInstance after the ancestor-tag            */
/* ==================================================================================================================== */
<Q-1 run AccountsPayableCtrlByDomain (all) (Read) (NoCache)
   (input vcDomainCode, (DomainCode)
    output dataset tqAccountsPayableCtrlByDomain) in BMfgAccountPayableCtrl >
find first tqAccountsPayableCtrlByDomain where 
           tqAccountsPayableCtrlByDomain.tcapc_domain = vcDomainCode
           no-lock no-error.
if available tqAccountsPayableCtrlByDomain
then assign vlAutoSelectDefaultValue     = tqAccountsPayableCtrlByDomain.tlapc_vchr_all
            vlRecalculateTaxDefaultValue = tqAccountsPayableCtrlByDomain.tlapc_recalc_tax.
else assign vlAutoSelectDefaultValue     = no
            vlRecalculateTaxDefaultValue = no.


/* ================================================================================================================================ */
/* Get version of operational                                                                                                       */
/* ================================================================================================================================ */
<M-75 run StartCacher
   (output vhFcComponent (ohCacher), 
    output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then leave.
    
<M-55 run GetIntegerValueFromSession
   (input  viSessionID (iiSessionId), 
    input  'MfgProMajorVersion':U (icDataItemName), 
    output viMfgProMajorVersionBAPM (oiValue), 
    output viFcReturnSuper (oiReturnStatus)) in Cacher>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then leave.

<M-87 run GetIntegerValueFromSession
   (input  viSessionID (iiSessionId), 
    input  'MfgProMinorVersion':U (icDataItemName), 
    output viMfgProMinorVersionBAPM (oiValue), 
    output viFcReturnSuper (oiReturnStatus)) in Cacher>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then leave.

/* ==================================================================================================================== */
/* Check, if fiscal receiving is activated                                                                              */
/* ==================================================================================================================== */
if viMfgProMajorVersionBAPM   > 3 /* Meaning eB3 */ or 
   (viMfgProMajorVersionBAPM  = 3 /* Meaning eB3 */ and 
    viMfgProMinorVersionBAPM >= 7 /* Meaning SP7 */ )
then do:
    <Q-78 run POAccountingControlByDomainV01 (all) (Read) (NoCache)
       (input vcDomainCode, (Domain)
        output dataset tqPOAccountingControlByDomainV01) in BMfgPOAccountingControl>

    find first tqPOAccountingControlByDomainV01 where
               tqPOAccountingControlByDomainV01.tcpoc_domain = vcDomainCode.

    if available tqPOAccountingControlByDomainV01
    then assign vlDomainIsFiscalConfirm = tqPOAccountingControlByDomainV01.tlpoc_fiscal_confirm.
    else assign vlDomainIsFiscalConfirm = false.
end. /* if viMfgProMajorVersionBAPM   > 3 /* Meaning eB3 */ or */

<Q-2 run LacCtrlByDomain (all) (Read) (NoCache)
   (input vcDomainCode, (Domain)
    output dataset tqLacCtrlByDomain) in BMfgLogisticAccControl >
find first tqLacCtrlByDomain where 
           tqLacCtrlByDomain.tclac_domain = vcDomainCode
           no-lock no-error.
if available tqLacCtrlByDomain
then assign vlBlankSupplDefaultValue        = tqLacCtrlByDomain.tllac_blank_suppliers
            vlBlankSupplDefaultValueEnabled = tqLacCtrlByDomain.tllac_blank_suppliers.
else assign vlBlankSupplDefaultValue        = no
            vlBlankSupplDefaultValueEnabled = no.

/* ======================================================================== */
/* When consecutive numbering is enabled, a temporary number should be used */
/* ======================================================================== */
<Q-56 run DomainPropertyForNumbering (all) (Read) (NoCache)
   (input viDomainID, (DomainId)
    output dataset tqDomainPropertyForNumbering) in BDomainProperty >
find tqDomainPropertyForNumbering where
     tqDomainPropertyForNumbering.tiDomain_ID = viDomainID
     no-lock no-error.
if not available tqDomainPropertyForNumbering
then do:
    assign vcMessage      = trim(substitute(#T-3'Could not find a DomainProperty record for domain ID &1.':255(750397887)T-3#, string(viDomainID) ))
           oiReturnStatus = -3.
    <M-26 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'S':U (icType), 
        input  2 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-467312':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
    return.
end. /* if not available tqDomainPropertyForNumbering */
    
assign vlMatchingDomainIsConsecutNr  = tqDomainPropertyForNumbering.tlDomainPropertyIsConsecutNr
       vlMatchingDomainIsPopupInvNr  = tqDomainPropertyForNumbering.tlDomainPropertyIsPopupInvNr
       vlMatchingDomainIsChronolNr   = tqDomainPropertyForNumbering.tlDomainPropertyIsChronolNr
       vcMatchingDomainNonChronError = tqDomainPropertyForNumbering.tcDomainPropertyNonChronErr.
       
/* ======================================================================================================================= */       
/* check if WHT is used on domain, and store that in an instance dependant class data item with keep as state data on true */
/* then this can be checked on ui to know when to enable/disable                                                           */       
/* ======================================================================================================================= */
<Q-58 run DomainPropertyByDomain (all) (Read) (NoCache)
   (input viDomainID, (DomainID)
    output dataset tqDomainPropertyByDomain) in BDomainProperty>
find first tqDomainPropertyByDomain where
           tqDomainPropertyByDomain.tiDomain_ID = viDomainID
           no-lock no-error.
if not available tqDomainPropertyByDomain
then do:
    assign vcMessage      = trim(substitute(#T-88'Current Domain (ID = &1) not found.':150(451196453)T-88#, string(viDomainID)))
           oiReturnStatus = -1.
    <M-31 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-444748':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
    return.
end.

assign vlDomainISWHT = tqDomainPropertyByDomain.tlDomainPropertyIsWHT.