icAction | input | character | This parameter defines what should happen with the input data : -SAVE: Save the data if there were no errors, -SAVESTORE : Save the data if there were no errors. If there were errors, save as draft. -STORE : Save the data as draft -VALIDATE : Validate the input data, but do no save the data. |
bcLstReturn | input-output | character | Char 4 separated list with the return status of the newly created main-table records. Zero means not errors occurred. |
bcLstPrimKey | input-output | character | Character 4 separated list with the primary keys of the newly created main-table records. The fields of the primary key are separated with Character 2. |
bcLstRowid | input-output | character | Char 4 separated list with the temporarely rowids (negative for new ones) of the newly created main-table records. |
blSaveAsDraft | input-output | logical | Save As Draft |
oiReturnStatus | output | integer | Return status of the method. |
/*==========================================================*/ /* create/modify VatRule records */ /*==========================================================*/ for each tApiVatRule where tApiVatRule.tc_ParentRowid = tApiVat.tc_Rowid by tApiVatRule.tc_Rowid: /* Next if the record already exists using logical key*/ find tVatRule where tVatRule.tc_ParentRowid = tVat.tc_Rowid and tVatRule.VatRuleSequence = tApiVatRule.VatRuleSequence and tVatRule.VatRuleBaseFull = tApiVatRule.VatRuleBaseFull no-error. if not avail tVatRule then find tVatRule where tVatRule.tc_ParentRowid = tVat.tc_Rowid and tVatRule.VatRule_ID = tApiVatRule.VatRule_ID no-error. if available tVatRule then do: assign tVatRule.tc_Status = '':U. buffer-compare tApiVatRule except VatRule_ID Vat_ID tc_Rowid tc_ParentRowid tc_Status to tVatRule save vlBufferCompareResult. if vlBufferCompareResult = true then next. assign tVatRule.tc_Status = 'C':U. end. else do: <M-1 run AddDetailLine (input 'VatRule':U (icTable), input tVat.tc_Rowid (icParentRowid), output viFcReturnSuper (oiReturnStatus)) in BVAT> if viFcReturnSuper <> 0 then do: assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then do: assign blSaveAsDraft = (icAction <> {&DAEMONACTION-SAVE} and icAction <> {&DAEMONACTION-VALIDATE}) bcLstReturn = bcLstReturn + chr(4) + string(viFcReturnSuper) bcLstPrimKey = bcLstPrimKey + chr(4) + "*":U bcLstRowid = bcLstRowid + chr(4) + "*":U oiReturnStatus = viFcReturnSuper. return. end. end. end. buffer-copy tApiVatRule except VatRule_ID Vat_ID tc_Rowid tc_ParentRowid tc_Status to tVatRule. end. /* Remove the longer used VatRule of the Vat */ for each tVatRule where tVatRule.tc_ParentRowid = tVat.tc_Rowid : /* Check if the record still exists */ find first tApiVatRule where tApiVatRule.tc_ParentRowid = tApiVat.tc_Rowid AND tApiVatRule.VatRule_ID = tVatRule.VatRule_ID no-error. if not available tApiVatRule then find tApiVatRule where tApiVatRule.tc_ParentRowid = tApiVat.tc_Rowid AND tApiVatRule.VatRuleSequence = tVatRule.VatRuleSequence AND tApiVatRule.VatRuleBaseFull = tVatRule.VatRuleBaseFull no-error. if not available tApiVatRule then if tVatRule.tc_Status = "N":U then delete tVatRule. else assign tVatRule.tc_Status = "D":U. end. /* for each tApiVatRule where ... */