project QadFinancials > class BPeriod > method UpdatePeriodMark

Description

This method is used to update the PriodMarkID field when the old id is not available any more.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPeriod.AdditionalUpdates


program code (program1/bperiod.p)

if can-find(first tPeriodMarkForPeriod)
then do:
    /* ======================= */
    /* Update Item Price Group */
    /* ======================= */
    if viBPeriodMark5ID = 0 or
       viBPeriodMark5ID = ?
    then do:
        <I-8 {bFcStartAndOpenInstance
            &ADD-TO-TRANSACTION = "true"
            &CLASS              = "BPeriodMark"}>
        assign vlBPeriodMarkIsStartedFromPer = true.
    end.
    else do:
        <I-6 {bFcOpenInstance
            &CLASS           = "BPeriodMark"}>
    end.
    
    <M-7 run CreatePeriodMarkRecords
       (input  tPeriodMarkForPeriod (tAPIPeriodMark), 
        input-output tPeriodMarkConv (tPeriodMarkForPeriodConv), 
        input  true (ilClearData), 
        output viFcReturnSuper (oiReturnStatus)) in BPeriodMark>

    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0
    then do:
        <I-12 {bFcCloseInstance
            &CLASS           = "BPeriodMark"}>

        /* error handling */
        <M-14 run StopExternalInstances
           (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
        assign oiReturnStatus = -1.
        return.
    end.
    
    if vlBPeriodMarkIsStartedFromPer
    then do:
        <M-10 run ValidateBCAndAdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BPeriodMark>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0
        then do:
            <I-13 {bFcCloseInstance
            &CLASS           = "BPeriodMark"}>

            <M-15 run StopExternalInstances
               (output viFcReturnSuper (oiReturnStatus)) in BPeriod>
            assign oiReturnStatus = -1.
            return.
        end.
    end.
    
    <I-9 {bFcCloseInstance
            &CLASS           = "BPeriodMark"}>

    /* Lets put the correct Period Mark Id to the Period */
    for each tPeriodMarkConv,
        each tPeriod where
             tPeriod.Period_ID = tPeriodMarkConv.tiPeriod_ID:
        assign tPeriod.PeriodMark_ID = tPeriodMarkConv.tiPeriodMarkNew_ID.
    end.        
end.