project QadFinancials > class BBudgetLinkCommitment > method AdditionalUpdatesCreateDelete

Description

AdditionalUpdatesCreateDelete


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBudgetLinkCommitment.AdditionalUpdates


program code (program6/bbudgetlinkcommitment.p)

/* ============================================================================================= */
/* For every tBudgetLinkCommit that is created, a BudgetLink record will be created or updated.  */
/* ============================================================================================= */


/* ================================================================ */
/* Set Return-status = Default-error                                */
/* ================================================================ */
assign oiReturnStatus = -98.
    
/* ===================== */
/* Empty the temp-tables */
/* ===================== */
empty temp-table tApiBudgetLinkFromCommitments.                 
                
/* ======================================= */
/* Go through all new instance records     */
/* ======================================= */
for each tBudgetLinkCommit where 
         tBudgetLinkCommit.tc_Status = "N":U or
         tBudgetLinkCommit.tc_Status = "D":U
         no-lock :
    create tApiBudgetLinkFromCommitments.
    buffer-copy tBudgetLinkCommit
                except  tc_rowid 
                        tc_parentrowid
                        tc_status
                        BudgetLinkCommit_ID
                to tApiBudgetLinkFromCommitments
    /* This field has to be unique */
    assign tApiBudgetLinkFromCommitments.tc_Rowid = tBudgetLinkCommit.tc_Rowid + string(tBudgetLinkCommit.POLine_ID).
     /* Inverse the Amount/Qty for a delete */
    if tBudgetLinkCommit.tc_Status = "D":U
    then assign tApiBudgetLinkFromCommitments.BudgetLinkCommitQTY = tApiBudgetLinkFromCommitments.BudgetLinkActualQTY * -1
                tApiBudgetLinkFromCommitments.BudgetLinkCommitTC  = tApiBudgetLinkFromCommitments.BudgetLinkActualTC * -1.
end. /* for each */

/* ======================================================================== */
/* No further processing needed if these are no BudgetLinkCommits to update */
/* ======================================================================== */
if not can-find (first tApiBudgetLinkFromCommitments)
then do :
    assign oiReturnStatus = 0.
    return.
end. /* if not can-find (first tBudgetCheckInfoWBSQBA) */

/* ================================================================ */
/* Call a method in BBudgetLinkAcutal that will create new records  */
/* ================================================================ */
if viBBudgetLinkBLComID = 0 or viBBudgetLinkBLComID = ?
    
then do:
    <I-2 {bFcStartAndOpenInstance
            &ADD-TO-TRANSACTION = "true"
            &CLASS              = "BBudgetLink"}>    
end. /* if viBBudgetLinkBLComID = 0  */

else do:
    <I-3 {bFcOpenInstance
            &CLASS           = "BBudgetLink"}>    
end. /* not if viBBudgetLinkBLComID = 0 */

<M-4 run ApiCreateOrUpdateBudgetLink (input  tApiBudgetLinkFromCommitments (tApiBudgetLink), 
                                      output viLocalReturnStatus (oiReturnStatus)) in BBudgetLink>

<I-5 {bFcCloseInstance
            &CLASS           = "BBudgetLink"}>
                       
if viLocalReturnStatus <> 0 
then do :
    assign oiReturnStatus = viLocalReturnStatus.
    if oiReturnStatus < 0 then return.
end. /* if viLocalReturnStatus <> 0 */

/* ================================================================ */
/* Set Return-status = OK                                           */
/* ================================================================ */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.