project QadFinancials > class BPosting > method ApiStdMaintainTTCreatetApiSafFromPosting

Description

ApiStdMaintainTTCreatetApiSafFromPosting: method that will create tApiSafFromPosting records for every SAF that is used in the postings of the current instance so they can be used to create these SAFs in the db later on in the flow


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.ApiStdMaintainMultiTT
method BPosting.ApiStdMaintainTT


program code (program9/bposting.p)

    
    /* ==================================================================================================================== */
    /* ApiStdMaintainTTCreatetApiSafFromPosting: method that will create tApiSafFromPosting records for every SAF that is   */
    /* used in the postings of the current instance so they can be used to create these SAFs in the db later on in the flow */
    /* ==================================================================================================================== */
    
    /* ========================================================================================== */
    /* Create a tApiSafFromPosting record - if it doesn't yet exist -  for every Saf that is used */
    /* in this posting and that does not exist as a SAF in the db.                                */
    /* These tApiSafFromPosting records will be the basis for creating new SAF records in the db. */
    /* With this mechanism we support an in-flight create of SAFs for external postings           */
    /* ========================================================================================== */
    for each tPosting where 
             tPosting.PostingOriginIsExternal = true ,
        each tPostingLine where 
             tPostingLine.tc_ParentRowid = tPosting.tc_Rowid , 
        each tPostingSaf where
             tPostingSaf.tc_ParentRowid      = tPostingLine.tc_Rowid and 
             tPostingSaf.tc_status          <> "D":U                 and 
             tPostingSaf.tcSafCode          <> "":U                  and 
             tPostingSaf.tcSafCode          <> ?                     and 
             tPostingSaf.tcSafConceptCode   <> "":U                  and 
             tPostingSaf.tcSafConceptCode   <> ?                     and
             tPostingSaf.tcSafStructureCode <> "":U                  and
             tPostingSaf.tcSafStructureCode <> ?
             break by tPostingSaf.tcSafConceptCode
                   by tPostingSaf.tcSafCode
             on error undo, throw :
        if first-of (tPostingSaf.tcSafCode)
        then do :
            <Q-7 assign vlFcQueryRecordsAvailable = SafPrim (NoCache)
               (input ?, (SafID)
                input tPostingSaf.tcSafCode, (SafCode)
                input tPostingSaf.tcSafConceptCode, (SafConceptCode)) in BSaf>
            if vlFcQueryRecordsAvailable = false and
               not can-find(first tApiSafFromPosting where
                                  tApiSafFromPosting.tcSafConceptCode  = tPostingSaf.tcSafConceptCode and
                                  tApiSafFromPosting.SafCode           = tPostingSaf.tcSafCode)
            then do:
                create tApiSafFromPosting.
                assign tApiSafFromPosting.SafCode          = tPostingSaf.tcSafCode
                       tApiSafFromPosting.SafDescription   = tApiSafFromPosting.SafCode
                       tApiSafFromPosting.tcSafConceptCode = tPostingSaf.tcSafConceptCode
                       tApiSafFromPosting.SafIsActive      = true
                       tApiSafFromPosting.tc_Rowid         = string(rowid(tApiSafFromPosting)).
            end. /* if vlFcQueryRecordsAvailable = false and */
        end. /* first-of (tPostingSaf.tcSafCode) */
    end. /* for each tPosting where */