project QadFinancials > class BVAT > method ApiDeleteOfTaxRate
Description
delete the vat and vat rules tables for a certain vat code
Parameters
icVatCode | input | character | Vat Code |
icDomainCode | input | character | Domain |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program9/bvat.p)
/* ====================== */
/* replace unknown values */
/* ====================== */
if icVatCode = ? then assign icVatCode = "":U.
if icDomainCode = ? then assign icDomainCode = "":U.
/* ================== */
/* exception handling */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
/* ===================================================== */
/* if input parameters are not filled, don't do anything */
/* ===================================================== */
if icVatCode = "":U or icDomainCode = "":U
then return.
/* ======================================= */
/* create list of vat records to be loaded */
/* ======================================= */
<Q-8 run VATPrim (all) (Read) (NoCache)
(input ?, (VatId)
input icVatCode, (VatCode)
input ?, (DomainId)
input icDomainCode, (DomainCode)
input ?, (VatInOut)
output dataset tqVATPrim) in BVAT >
for each tqVatPrim where
tqVATPrim.tcVatCode = icVatCode and
tqVATPrim.tcDomainCode = icDomainCode
no-lock:
if not can-find (first tVat where
tVat.Vat_ID = tqVATPrim.tiVat_ID)
then assign vcListVatIds = if vcListVatIds = "":U
then string(tqVATPrim.tiVat_ID)
else if lookup(string(tqVATPrim.tiVat_ID), vcListVatIds,chr(4)) = 0
then vcListVatIds + chr(4) + string(tqVATPrim.tiVat_ID)
else vcListVatIds.
end.
VATBLOCK: DO:
/* ==================== */
/* load the vat records */
/* ==================== */
if vcListVatIds <> "":U
then do:
<M-30 run DataLoad
(input '':U (icRowids),
input vcListVatIds (icPkeys),
input '':U (icObjectIds),
input '':U (icFreeform),
input false (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BVAT>
if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
assign vcMessage = trim(substitute(#T-9'Data could not be loaded: unable to load the list of tax records (&1).':100(733741039)T-9#, replace(vcListVatIds, chr(4), ",":U))).
<M-10 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-9663':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVAT>
leave VATBLOCK.
end. /* end if viFcReturnSuper < 0 */
end. /* end if vcListVatIds <> "":U */
/* ============================================================================================= */
/* delete vat and vatrule tables */
/* we don't need to mark the subtables as deleted because maintable is already marked as deleted */
/* ============================================================================================= */
for each tVat:
assign tVat.tc_Status = "D":U.
end. /* end for each tVat */
/* ========================================== */
/* validation, additionalupdates and datasave */
/* ========================================== */
if vcListVatIds <> "":U
then do:
<M-11 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BVAT>
if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave VATBLOCK.
<M-12 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BVAT>
if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave VATBLOCK.
<M-13 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BVAT>
if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave VATBLOCK.
end.
END. /* end block */
/* ================== */
/* exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.
Sample code: how to call this method through RPCRequestService (QXtend Inbound)
define temp-table ttContext no-undo
field propertyQualifier as character
field propertyName as character
field propertyValue as character
index entityContext is primary unique
propertyQualifier
propertyName
index propertyQualifier
propertyQualifier.
define dataset dsContext for ttContext.
define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.
/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
ttContext.propertyValue = "BVAT".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiDeleteOfTaxRate".
create ttContext.
assign ttContext.propertyName = "applicationId"
ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
ttContext.propertyValue = "".
/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/bvat.apideleteoftaxrate.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icVatCode = <parameter value>
vhParameter::icDomainCode = <parameter value>.
/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").
if not vhServer:connected()
then do:
message "Could not connect AppServer" view-as alert-box error title "Error".
return.
end.
/* Run */
assign vhContextDS = dataset dsContext:handle.
run program/rpcrequestservice.p on vhServer
(input-output dataset-handle vhContextDS by-reference,
output dataset-handle vhExceptionDS,
input dataset-handle vhInputDS by-reference,
input-output dataset-handle vhInputOutputDS by-reference,
output dataset-handle vhOutputDS).
/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).
if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).
/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.
if valid-handle(vhInputDS)
then delete object vhInputDS.
if valid-handle(vhOutputDS)
then delete object vhOutputDS.
if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.