icAPMatchingTcRowid | input | character | icAPMatchingTcRowid: TcRowid of the APMatching record. If this param has a value then param iiAPMatchingID will be ignored |
iiAPMatchingID | input | integer | iiAPMatching: ID of the Matching: In case icAPMatchingTcRowid is filled then this parameter will not be used |
oiReturnStatus | output | integer | Return status of the method. |
/* ================== */ /* Exception handling */ /* ================== */ assign oiReturnStatus = -98 viLocalReturnStatus = 0. /* ================== */ /* Start Block */ /* ================== */ UPDATECINVOICEBLOCK : DO : /* ================================================================================= */ /* Validate input / Find tAPMatching baed upon the input params */ /* Not all possible validations are done here because method "UpdateCInvoiceFromAPM" */ /* that is called at the end of this method has quite some validations itself */ /* ================================================================================= */ if icAPMatchingTcRowid <> "":U and icAPMatchingTcRowid <> ? then find tAPMatching where tAPMatching.tc_Rowid = icAPMatchingTcRowid no-lock no-error. else find tAPMatching where tAPMatching.APMatching_ID = iiAPMatchingID no-lock no-error. if not available tAPMatching then do : assign vcMsgAPMatching = trim(substitute(#T-58'The system cannot update the invoice from the matching because the matching cannot be found based upon the TC row ID (&1) and the ID (&2) that was passed.':255(70335)T-58#,icAPMatchingTcRowid,string(iiAPMatchingID))) viLocalReturnStatus = -3. <M-43 run SetMessage (input vcMsgAPMatching (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'QadFin-8359':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BAPMatching> Leave UPDATECINVOICEBLOCK. end. /* if not available tAPMatching */ if tAPMatching.CInvoice_ID = 0 or tAPMatching.CInvoice_ID = ? then do : assign vcMsgAPMatching = trim(substitute(#T-66'The system cannot update the invoice from the matching because the matching is not linked to the invoice.':255(70333)T-66#)) viLocalReturnStatus = -3. <M-51 run SetMessage (input vcMsgAPMatching (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input '':U (icRowid), input 'QadFin-8362':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BAPMatching> Leave UPDATECINVOICEBLOCK. end. /* if tAPMatching.CInvoice_ID = 0 or */ /* ================================================================================= */ /* Call the method in this class that performs the call to BCInvoice to update it */ /* Check if the current tAPMatching record is the only one in the business-instance: */ /* If so, then we can simply pass the class-table tAPMatchingLn and tAPMatchingLnTax */ /* if not, the we have to fill temp-tables tSPTAPMatchingLn and tSPTAPMatchingLnTax */ /* with the records of tAPMatchingLn and tAPMatchingLnTax of the current tAPMatching */ /* The disadvantage of this is that we have 2 calls to the same method but I could */ /* not find another way without creating the performance-loss bofcopying temp-tables */ /* ================================================================================= */ if can-find (first btAPMatching where btAPMatching.tc_Rowid <> tAPMatching.tc_Rowid) then do : empty temp-table tSPTAPMatchingLn. empty temp-table tSPTAPMatchingLnTax. empty temp-table tSPTAPMatchingLnWHT. for each tAPMatchingLn where tAPMatchingLn.tc_ParentRowid = tAPMatching.tc_Rowid and tAPMatchingLn.tc_Status <> "D":U : create tSPTAPMatchingLn. buffer-copy tAPMatchingLn to tSPTAPMatchingLn. for each tAPMatchingLnTax where tAPMatchingLnTax.tc_ParentRowid = tAPMatchingLn.tc_Rowid and tAPMatchingLnTax.tc_Status <> "D":U : create tSPTAPMatchingLnTax. buffer-copy tAPMatchingLnTax to tSPTAPMatchingLnTax. end. /* for each tAPMatchingLnTax where */ for each tAPMatchingLnWHT where tAPMatchingLnWHT.tc_ParentRowid = tAPMatchingLn.tc_Rowid and tAPMatchingLnWHT.tc_Status <> "D":U : create tSPTAPMatchingLnWHT. buffer-copy tAPMatchingLnWHT to tSPTAPMatchingLnWHT. end. /* for each tAPMatchingLnWHT where */ end. /* for each tAPMatchingLn where */ <M-68 run UpdateCInvoiceFromUIAPM (input tAPMatching.tc_Rowid (iiAPMatchingID), input tAPMatching.CInvoice_ID (iiCInvoiceID), input ? (iiPostingID), input tSPTAPMatchingLn (tSPTAPMatchingLn), input tSPTAPMatchingLnTax (tSPTAPMatchingLnTax), input tSPTAPMatchingLnWHT (tSPTAPMatchingLnWHT), output viFcReturnSuper (oiReturnStatus)) in BAPMatching> empty temp-table tSPTAPMatchingLn. empty temp-table tSPTAPMatchingLnTax. empty temp-table tSPTAPMatchingLnWHT. end. /* if can-find (first btAPMatching where */ else do : <M-67 run UpdateCInvoiceFromUIAPM (input tAPMatching.tc_Rowid (iiAPMatchingID), input tAPMatching.CInvoice_ID (iiCInvoiceID), input ? (iiPostingID), input tAPMatchingLn (tSPTAPMatchingLn), input tAPMatchingLnTax (tSPTAPMatchingLnTax), input tAPMatchingLnWHT (tSPTAPMatchingLnWHT), output viFcReturnSuper (oiReturnStatus)) in BAPMatching> end. /* Not if can-find (first btAPMatching where */ if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Leave UPDATECINVOICEBLOCK. END. /* UPDATECINVOICEBLOCK */ /* ================== */ /* Exception handling */ /* ================== */ assign oiReturnStatus = viLocalReturnStatus.