project QadFinancials > class BFRWColumnGroup > method ValidateComponentPreResequence

Description

Pre validation method.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BFRWColumnGroup.ValidateComponentPre


program code (program1/bfrwcolumngroup.p)

/* ================================================================================= *
 * RESEQUENCING                                                                      *
 * Use can change sequence of the columns. System is always starting sequence from 1 *
 * with step 1. As sequence is part of unique index, we cannot change/create a new   *
 * column with the same sequence as already existes in database. So first we have to *
 * delete original records and then create a-new records. As deleted records  are    *
 * processed first during saving, this saves records correctly                       *
 * See also additional code for changing of the sequence sign in ValidateComponent   *
 * ================================================================================= */
/* Mark all original records as deleted and for current set create new records */
empty temp-table tDeletedColDet.

for each t_sFRWCol where
         t_sFRWCol.tc_Status <> "D":U:

    assign vcCurrentRecordList = "":U.

    for each t_sFRWColDet where
             t_sFRWColDet.tc_ParentRowid = t_sFRWCol.tc_Rowid and
             t_sFRWColDet.tc_Status     <> "D":U
        break by t_sFRWColDet.FRWColDetSeq:

        assign vcCurrentRecordList = vcCurrentRecordList
                                   + (if vcCurrentRecordList <> "":U
                                      then chr(2)
                                      else "":U)
                                   + t_sFRWColDet.tc_Rowid.

        if t_sFRWColDet.tc_Status <> "N":U
        then do:
            find first tFRWColDet where tFRWColDet.tc_Rowid = t_sFRWColDet.tc_Rowid no-error.
            if available tFRWColDet then 
                assign tFRWColDet.tc_Status = "D":U.

            assign t_sFRWColDet.tc_Status = "D":U.
        end.

    end. /* for each t_sFRWColDet where */ 

    for each t_sFRWColDet where
             t_sFRWColDet.tc_ParentRowid = t_sFRWCol.tc_Rowid and
             t_sFRWColDet.tc_Status     <> "N":U:
        
        if lookup(t_sFRWColDet.tc_Rowid, vcCurrentRecordList, chr(2)) = 0
        then next.

        <M-91 run AddDetailLine
           (input  'FRWColDet':U (icTable), 
            input  t_sFRWCol.tc_Rowid (icParentRowid), 
            output viFcReturnSuper (oiReturnStatus)) in BFRWColumnGroup>
        if(t_sFRWColDet.FRWColDetColumnType = 'COMP') then
        do:
            create tDeletedColDet.
            assign tDeletedColDet.tiDelColDetID = t_sFRWColDet.FRWColDet_ID
                   tDeletedColDet.tcDelColDetRowID = t_sFRWColDet.tc_rowid
                   tDeletedColDet.tiNewColDetID = tFRWColDet.FRWColDet_ID
                   tDeletedColDet.tcNewColDetRowID = tFRWColDet.tc_rowid.
        end.         
   
        if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then return.


        buffer-copy t_sFRWColDet 
             except t_sFRWColDet.FRWColDet_ID
                    t_sFRWColDet.tc_ParentRowid
                    t_sFRWColDet.tc_Rowid
                    t_sFRWColDet.tc_Status
                 to tFRWColDet.

        create bsFRWColDet.
        buffer-copy tFRWColDet to bsFRWColDet.   

    end. /* for each t_sFRWColDet where */
end. /* for each t_sFRWCol where */

for each tDeletedColDet:
    for each t_sFRWColDetComp where t_sFRWColDetComp.tc_parentrowid = tDeletedColDet.tcDelColDetRowID :
      
       if t_sFRWColDetComp.tc_status <> "D":U then
       do:
           t_sFRWColDetComp.tc_status = "":U.
           <M-58 run AddDetailLine
               (input  'FRWColDetComp':U (icTable), 
                input  tDeletedColDet.tcNewColDetRowID (icParentRowid), 
                output viFcReturnSuper (oiReturnStatus)) in BFRWColumnGroup>
        
        
           buffer-copy t_sFRWColDetComp 
                     except t_sFRWColDetComp.FRWColDetComp_ID
                            t_sFRWColDetComp.tc_ParentRowid
                            t_sFRWColDetComp.tc_Rowid
                            t_sFRWColDetComp.tc_Status
                            t_sFRWColDetComp.FromRangeFRWAnCode_ID
                            t_sFRWColDetComp.ToRangeFRWAnCode_ID
                            t_sFRWColDetComp.SourceFRWAnCode_ID
           to tFRWColDetComp.
       end.
       else
       do:
          delete t_sFRWColDetComp.
       end.
    end.
    
    for each tFRWColDetComp where tFRWColDetComp.tc_parentrowid = tDeletedColDet.tcDelColDetRowid:
        tFRWColDetComp.tc_status = "":U.
    end.
    
    for each tFRWColDetComp where tFRWColDetComp.tc_parentrowid = tDeletedColDet.tcNewColDetRowid:
       
        tFRWColDetComp.frwcoldet_id = tDeletedColDet.tiNewColDetID.

        <Q-61 run FRWAnCodePrim1 (first) (Read) (NoCache)
           (input ?, (FRWAnCode_ID)
            input tFRWColDetComp.tcFRWAnCodeCode, (FRWAnCodeCode)
            input tFRWColDetComp.tcFRWAnCodeFRWChartCode, (ChartCode)
            output dataset tqFRWAnCodePrim1) in BFRWAnalysisCode>

        find first tqFRWAnCodePrim1 no-error.
        if available tqFRWAnCodePrim1
        then assign tFRWColDetComp.FromRangeFRWAnCode_ID = tqFRWAnCodePrim1.tiFRWAnCode_ID.

        <Q-10 run FRWAnCodePrim1 (first) (Read) (NoCache)
           (input ?, (FRWAnCode_ID)
            input tFRWColDetComp.tcFRWAnCodeCode1, (FRWAnCodeCode)
            input tFRWColDetComp.tcFRWAnCodeFRWChartCode, (ChartCode)
            output dataset tqFRWAnCodePrim1) in BFRWAnalysisCode>

        find first tqFRWAnCodePrim1 no-error.
        if available tqFRWAnCodePrim1
        then assign tFRWColDetComp.ToRangeFRWAnCode_ID = tqFRWAnCodePrim1.tiFRWAnCode_ID.

        <Q-59 run FRWAnCodePrim1 (first) (Read) (NoCache)
           (input ?, (FRWAnCode_ID)
            input tFRWColDetComp.tcFRWAnCodeCode2, (FRWAnCodeCode)
            input tFRWColDetComp.tcFRWAnCodeFRWChartCode, (ChartCode)
            output dataset tqFRWAnCodePrim1) in BFRWAnalysisCode>

        find first tqFRWAnCodePrim1 no-error.
        if available tqFRWAnCodePrim1
        then assign tFRWColDetComp.SourceFRWAnCode_ID = tqFRWAnCOdePrim1.tiFRWAnCode_ID.

    end.
end.

/* Clear the composition record if the corresponding detial record is deleted or its column type is no longer "Composed" */
for each t_sFRWColDet where ((t_sFRWColDet.tc_Status = "C":U or t_sFRWColDet.tc_Status = "N":U) and 
                             t_sFRWColDet.FRWColDetColumnType <> {&FRWCOLDETCOLUMNTYPE-COMPOSED}) or 
                             t_sFRWColDet.tc_Status = "D":U:
    for each t_sFRWColDetComp where t_sFRWColDetComp.tc_parentrowid = t_sFRWColDet.tc_Rowid:
        delete t_sFRWColDetComp.
    end.
end.