project QadFinancials > class BDPaymentSelection > method SetDPaySelPayCode


Parameters


t_sDPaySelPayCodeRefinput-outputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDPaymentSelection.UpdateDPaySelAndPayCode


program code (program1/bdpaymentselection.p)

for each t_sDPaySelPayCodeRef where 
         t_sDPaySelPayCodeRef.tc_Status <> "":U:

    find first tDPaySelPayCode where 
               tDPaySelPayCode.DPaySelPayCode_ID = t_sDPaySelPayCodeRef.DPaySelPayCode_ID no-error.

    if not available tDPaySelPayCode
    then do:
        if not can-find(first tDPaySel where 
                               tDPaySel.DPaySel_ID = t_sDPaySelPayCodeRef.DPaySel_ID) 
        then do:

            /*load all DPaySel and associated PayCodes */
            <M-1 run DataLoad
               (input  '':U (icRowids), 
                input  t_sDPaySelPayCodeRef.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. /* if  not can-find(first tDPaySel ... */
        
        find first tDPaySel where 
                   tDPaySel.DPaySel_ID = t_sDPaySelPayCodeRef.DPaySel_ID no-error.
        if not available tDPaySel
        then do:
            assign vcMessage = trim(substitute(#T-2'&1 not available.':100(56050)T-2#, "tDPaySel":U)) + chr(10) + 
                                    program-name(1)
                   oiReturnStatus = -1.

            <M-3 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-5623':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
            return.
        end.

        if t_sDPaySelPayCodeRef.tc_Status = "N":U
        then do:
            <M-4 run AddDetailLine
               (input  'DPaySelPayCode':U (icTable), 
                input  tDPaySel.tc_Rowid (icParentRowid), 
                output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>

            if viFcReturnSuper <> 0
            then do:
                assign oiReturnStatus = viFcReturnSuper.
                return.
            end.            
        end. /* create */
        
        if not available tDPaySelPayCode 
        then find first tDPaySelPayCode where 
                        tDPaySelPayCode.DPaySelPayCode_ID = t_sDPaySelPayCodeRef.DPaySelPayCode_ID no-error.
        
        if not available tDPaySelPayCode
        then do:
            assign vcMessage = trim(substitute(#T-5'&1 not available.':100(56050)T-5#, "tDPaySelPayCode":U)) + chr(10) + 
                                    program-name(1)
                   oiReturnStatus = -1.

            <M-6 run SetMessage
               (input  '':U (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QadFin-5624':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
            return.
        end.
    end.
    
    if t_sDPaySelPayCodeRef.tc_Status = "D":U
    then assign tDPaySelPayCode.tc_Status = "D":U.
    else buffer-copy t_sDPaySelPayCodeRef 
            except DPaySelPayCode_ID tc_Rowid tc_ParentRowid to tDPaySelPayCode.
end.  /* for each t_sDPaySelPayCodeRef */