project QadFinancials > class BDPaymentSelection > method RemoveEmptyPaySel


Parameters


icPaySelIDsinputcharacterList of Pay Sel IDs to delete
oiReturnStatusoutputintegerReturn status of the method


Internal usage


QadFinancials
method BDDocument.AdditionalUpdatesDPaymentSelection


program code (program1/bdpaymentselection.p)

/*************************************************/
/* Remove the pay sel id's from input parameter  */
/*************************************************/
if icPaySelIDs <> ? and icPaySelIDs <> "":U and icPaySelIDs <> "0":U
then do:            
    /* If we do a DataLoad here then vlFcDataValidated will be set to false again. */
    /* To avoid we get error 'BLF-308: Data to save () has not been validated", we will manually assign vlFcDataValidated to true after the DataLoad if it was already true before the DataLoad */
    assign vlPreviousFcDataValidated = vlFcDataValidated.

    /* load the existing record */
    <M-52 run DataLoad
       (input  '':U (icRowids), 
        input  icPaySelIDs (icPkeys), 
        input  '':U (icObjectIds), 
        input  '':U (icFreeform), 
        input  true (ilKeepPrevious), 
        output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
        
    if viFcReturnSuper <> 0
    then do:
        assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0
        then do:        
            assign vcMessage      = trim(substitute(#T-98'&1 not available.':100(56050)T-98#, "icPaySelIDs":U)) + chr(10) + 
                                      program-name(1).                   
            <M-63 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':u (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'qadfin-468897':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
          end.
        return.
    end.        

    if vlPreviousFcDataValidated = true
    then assign vlFcDataValidated = true.
    
    /* set the status to D to delete */   
    do viIDIndex = num-entries(icPaySelIDs, chr(4)) to 1 by -1 :    
        assign viCurrentEntry = Integer(entry(viIDIndex, icPaySelIDs, chr(4))) no-error.
        if error-status:error
        then do:
            assign oiReturnStatus = -3
                   vcMessage      = trim(substitute(#T-23'Internal error: unable to get Payment Selection from ID &1.':255(611655269)T-23#,icPaySelIDs)).
            <M-35 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'S':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'qadfin-719471':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>            
        end. 

        /* CHECK IF THE PAYSEL_ID HAS ANY MORE DOCUMENTS ATTACHED */
        /* DO NOT DELETE IN SUCH CASE                             */
        <Q-65 assign vlFcQueryRecordsAvailable = DocumentByDpaySelID (NoCache)
           (input viCompanyID, (CompanyId)
            input viCurrentEntry, (DPaySelID)) in BDDocument>
        
        if vlFcQueryRecordsAvailable = false 
        then do:
            find first tDPaySel where tDPaySel.DPaySel_ID = viCurrentEntry.
            if available tDPaySel 
            then do:
                assign tDPaySel.tc_Status = 'D':U.
            end. /* if available tDPaySel */ 
        end.   /* vlFcQueryRecordsAvailable = false */
    end. /* do */        
end.