project QadFinancials > class BPosting > method InitialValues

Description

Add code here to initialize the calculated fields of a 'new' record (= a record that must be created in the application database) in a class temp-table.


Parameters


icTableNameinputcharacterName of the database table of which a record is created in the class temp-table.
oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bposting.p)

<ANCESTOR-CODE>
    
    
    if icTableName = "Posting":U
    then assign tPosting.Company_ID                  = viCompanyId
                tPosting.PostingSystemDate           = today
                tPosting.tcLocalCurrency             = vcCompanyLC
                tPosting.PostingOriginIsExternal     = false
                tPosting.PostingOriginReference      = '':U
                tPosting.PostingOriginDocument       = '':U
                tPosting.PostingOriginDocumentType   = '':U
                tPosting.PostingOriginTransType      = '':U
                tPosting.PostingOriginDaybookCode    = '':U
                tPosting.PostingOriginDaybookNumber  = '':U
                tPosting.PostingVerifyStatus         = {&APPROVESTATUSTRANS-INITIAL}
                tPosting.PostingApproveStatus        = {&APPROVESTATUSTRANS-INITIAL}
                tPosting.tlSaveAsTemplate            = false
                tPosting.CreatorUsr_ID               = viUsrId
                tPosting.tcUsrLogin = vcUserLogin.
    
    
    if icTableName = "PostingLine":U
    then do:
        Find btPosting where
             btPosting.tc_rowid = tPostingLine.tc_ParentRowid
             no-error.
        if available btPosting
        then assign tPostingLine.Company_ID = btPosting.Company_ID
                    tPostingLine.Posting_ID = btPosting.Posting_ID.
        /* ======================================================================================================================= */
        /* Do not use tc_ParentRowid/tc_rowid in this condition as we explicitely indicate that a certain index should be used and */ 
        /* this index holds Posting_ID and PostingLineSeq  - with many thanks to GNL for doing all the tests on this approach :))  */
        /* This index is an index that is not defined on db-level but only in the class-table in CB. We first tried to create the  */
        /* index on tc_parentrowid+PostingLineSeq but this is not yet possible due to a bug in CB - we thus created an index on    */
        /* Posting_ID+PostingLineSeq                                                                                               */  
        /* ======================================================================================================================= */
        Find Last btPostingLine where 
                  btPostingLine.Posting_ID  = tPostingLine.Posting_ID and
                  btPostingLine.tc_Status  <> "D":U 
                  use-index PostingIDLineSeq 
                  no-lock no-error.
        assign tPostingLine.PostingLineSequence          = (if available btPostingLine then btPostingLine.PostingLineSequence + 1 else 1)
               tPostingLine.PostingLineOriginLineNbr     = 0
               tPostingLine.tlSkipCOAValForPeriodCosting = false.         
    end. /* if icTableName = "PostingLine":U */
    
    
    if icTableName = "PostingVat":U
    then assign tPostingVat.PostingVatInOut        = {&VATINOUT-OUTPUT}
                tPostingVat.PostingVatTransType    = {&VATTRANSACTIONTYPE-SALES}
                tPostingVat.PostingVatTaxTransType = {&VATTAXTRANSACTIONTYPE-APVOUCHER}.