project QadFinancials > class BDPaymentSelection > method SetDPaySel

Description

Loads or creates records of DPaySel table based on t_sDPaySelRef table


Parameters


t_sDPaySelRefinput-outputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDPaymentSelection.UpdateDPaySelAndPayCode


program code (program1/bdpaymentselection.p)

for each t_sDPaySelRef where 
         t_sDPaySelRef.tc_Status <> "":U:
    
    find first tDPaySel where 
               tDPaySel.DPaySel_ID = t_sDPaySelRef.DPaySel_ID no-error.

    if not available tDPaySel
    then do:

        if t_sDPaySelRef.tc_Status = "N":U
        then do:
            /* AddDetailLine */
            <M-1 run AddDetailLine
               (input  'DPaySel':U (icTable), 
                input  '':U (icParentRowid), 
                output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>

            if viFcReturnSuper <> 0
            then do:
                assign oiReturnStatus = viFcReturnSuper.
                return.
            end. 

            assign t_sDPaySelRef.DPaySel_ID = tDPaySel.DPaySel_ID.

            for each t_sDPaySelPayCodeRef where
                     t_sDPaySelPayCodeRef.tc_ParentRowid = t_sDPaySelRef.tc_rowid:
                assign t_sDPaySelPayCodeRef.DPaySel_Id = tDPaySel.DPaySel_ID.
            end.
        end. /* create */
        else do:
            /* load the existing record */
            <M-2 run DataLoad
               (input  '':U (icRowids), 
                input  string(t_sDPaySelRef.DPaySel_ID) (icPkeys), 
                input  '':U (icObjectIds), 
                input  '':U (icFreeform), 
                input  true (ilKeepPrevious), 
                output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
          
            if viFcReturnSuper <> 0
            then do:
                assign oiReturnStatus = viFcReturnSuper.
                return.
            end.            
        end. /* load the existing record */

        if not available tDPaySel 
        then find first tDPaySel where 
                        tDPaySel.DPaySel_ID = t_sDPaySelRef.DPaySel_ID no-error.
        
        if not available tDPaySel
        then do:
            assign vcMessage = trim(substitute(#T-3'&1 not available.':100(56050)T-3#, "tDPaySel":U)) + chr(10) + 
                                    program-name(1)
                   oiReturnStatus = -1.

            <M-4 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-5622':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>

            return.
        end.
    end.

    if t_sDPaySelRef.tc_Status = "D":U
    then assign tDPaySel.tc_Status = "D":U.
    else  buffer-copy t_sDPaySelRef except DPaySel_ID tc_Rowid tc_ParentRowid to tDPaySel.        

end. /* for each t_sDPaySel */