project QadFinancials > class BPostingSafHist > method CreatePostingSafHistRecord

Description

Method to check existence of a PostingSafCombined record. Create it (and the PostingSafHist records) if it doesn't exist yet. This method receives three variables with maximum 5 saf-id's and it returns the PostingSafCombinedID.


Parameters


icGLSafIDsinputcharacterComma-seperated list of Saf-id's with parent-type = GL
icCostCentreSafIDsinputcharacterComma-seperated list of Saf-id's with parent-type = CostCentre
icProjectSafIDsinputcharacterComma-seperated list of Saf-id's with parent-type = Project
iiGLSafStructureIDinputintegerGLSafStructureID
iiProjectSafStructureIDinputintegerProjectSafStructureID
iiCostCentreSafStructureIDinputintegerCostCentre SafStructure ID
oiPostingSafCombinedIDoutputintegerPostingSafCombined_ID
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPostingHist.UpdatePostingHist


program code (program6/bpostingsafhist.p)

/* ============================================================================================ */
/* !!!!!!!!!!!!!!!!!!!!!!     NOTE        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* Method BHistoryDaemonProcesoor:PerformWorkItemDIRECT() and its sub-methods hold similar code */
/* with the same functionality where the same result is obtained but by using direct db actions */
/* So when chnaging some code here, the similar change has to be made in there as well          */
/* ============================================================================================ */



/* ====================================================================================================== */
/* This method creates PostingSAFHist and PostingSafCombined                                              */

/*    input icCostCentreSafIDs                                                                            */
/*          icGLSafIDs                                                                                    */
/*          icProjectSafIDs                                                                               */
/*          iiCostCentreSafStructureID                                                                    */
/*          iiGLSafStructureID                                                                            */
/*          iiProjectSafStructureID                                                                       */

/*    output oiPostingSafCombinedID                                                                       */
/*           tPostingSafCombined                                                                          */
/*           tPostingSafHist                                                                              */

/* ====================================================================================================== */
                                                                                                            
assign oiPostingSafCombinedId    = 0.

<M-2 run AddDetailLine
   (input  'PostingSafCombined':U (icTable), 
    input  '':U (icParentRowid), 
    output oiReturnStatus (oiReturnStatus)) in BPostingSafHist>
if oiReturnStatus <> 0
then return.

assign tPostingSafCombined.Project1Saf_ID            = integer(entry(1, icProjectSafIDs))     
       tPostingSafCombined.Project2Saf_ID            = integer(entry(2, icProjectSafIDs))     
       tPostingSafCombined.Project3Saf_ID            = integer(entry(3, icProjectSafIDs))     
       tPostingSafCombined.Project4Saf_ID            = integer(entry(4, icProjectSafIDs))     
       tPostingSafCombined.Project5Saf_ID            = integer(entry(5, icProjectSafIDs))     
       tPostingSafCombined.CostCentre1Saf_ID         = integer(entry(1, icCostCentreSafIDs))  
       tPostingSafCombined.CostCentre2Saf_ID         = integer(entry(2, icCostCentreSafIDs)) 
       tPostingSafCombined.CostCentre3Saf_ID         = integer(entry(3, icCostCentreSafIDs)) 
       tPostingSafCombined.CostCentre4Saf_ID         = integer(entry(4, icCostCentreSafIDs)) 
       tPostingSafCombined.CostCentre5Saf_ID         = integer(entry(5, icCostCentreSafIDs)) 
       tPostingSafCombined.GL1Saf_ID                 = integer(entry(1, icGLSafIDs))         
       tPostingSafCombined.GL2Saf_ID                 = integer(entry(2, icGLSafIDs))         
       tPostingSafCombined.GL3Saf_ID                 = integer(entry(3, icGLSafIDs))         
       tPostingSafCombined.GL4Saf_ID                 = integer(entry(4, icGLSafIDs))         
       tPostingSafCombined.GL5Saf_ID                 = integer(entry(5, icGLSafIDs))
       tPostingSafCombined.ProjectSafStructure_ID    = iiProjectSafStructureID
       tPostingSafCombined.CostCentreSafStructure_ID = iiCostCentreSafStructureID
       tPostingSafCombined.GLSafStructure_ID         = iiGLSafStructureID

       oiPostingSafCombinedId                        = tPostingSafCombined.PostingSafCombined_ID.
    
/* ProjectSafID's */
do viCount = num-entries(icProjectSafIDs) to 1 by -1:
    if integer(entry(viCount, icProjectSafIDs)) > 0
    then do:
        <M-3 run AddDetailLine (input  'PostingSafHist':U (icTable), 
                    input  tPostingSafCombined.tc_Rowid (icParentRowid), 
                    output oiReturnStatus (oiReturnStatus)) in BPostingSafHist>
        if oiReturnStatus <> 0
        then return.

        assign tPostingSafHist.Saf_ID                = integer(entry(viCount, icProjectSafIDs))
               tPostingSafHist.PostingSafCombined_ID = tPostingSafCombined.PostingSafCombined_ID.
    end.
end.

/* CostCentreSafID's */
do viCount = num-entries(icCostCentreSafIDs) to 1 by -1:
    if integer(entry(viCount, icCostCentreSafIDs)) > 0
    then do:
        <M-4 run AddDetailLine (input  'PostingSafHist':U (icTable), 
                    input  tPostingSafCombined.tc_Rowid (icParentRowid), 
                    output oiReturnStatus (oiReturnStatus)) in BPostingSafHist>
        if oiReturnStatus <> 0
        then return.

        assign tPostingSafHist.Saf_ID                = integer(entry(viCount, icCostCentreSafIDs))
               tPostingSafHist.PostingSafCombined_ID = tPostingSafCombined.PostingSafCombined_ID.
    end.
end.

/* GLSafID's */
do viCount = num-entries(icGLSafIDs) to 1 by -1:
    if integer(entry(viCount, icGLSafIDs)) > 0
    then do:
        <M-5 run AddDetailLine (input  'PostingSafHist':U (icTable), 
                    input  tPostingSafCombined.tc_Rowid (icParentRowid), 
                    output oiReturnStatus (oiReturnStatus)) in BPostingSafHist>
        if oiReturnStatus <> 0
        then return.

        assign tPostingSafHist.Saf_ID                = integer(entry(viCount, icGLSafIDs))
               tPostingSafHist.PostingSafCombined_ID = tPostingSafCombined.PostingSafCombined_ID.
    end.
end.