project QadFinancials > class BVATPeriod > method APIUpdateVATPeriodStatus
Description
Method that updates one vat period based on primary or logical key.
Following fields will be updated : VatPeriodstatus, VatPeriodIsReportChecked,
PostCondition
The Vat Period record will be updated based on the input data
Parameters
| iiVATPeriod_ID | input | integer | Vat Period ID (Primary Key) |
| icStatus | input | character | Status |
| ilIsReportChecked | input | logical | is report checked ? |
| iiVATPeriodYear | input | integer | Vat Year (part of logical key) |
| iiVATPeriodPeriod | input | integer | Vat Period (part of logical key) |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bvatperiod.p)
<M-1 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
if iiVATPeriod_ID = 0 or
iiVATPeriod_ID = ?
then do:
<Q-9 run VATPeriodPrim (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (VATPeriodID)
input iiVATPeriodYear, (Year)
input iiVATPeriodPeriod, (Period)
output dataset tqVATPeriodPrim) in BVATPeriod >
find first tqVATPeriodPrim no-error.
if not available tqVATPeriodPrim
then do:
assign oiReturnStatus = -1.
return.
end.
assign iiVATPeriod_ID = tqVATPeriodPrim.tiVatPeriod_ID.
end.
<M-2 run DataLoad
(input '':U (icRowids),
input string(iiVATPeriod_ID) (icPkeys),
input '':U (icObjectIds),
input '' (icFreeform),
input no (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
if viFcReturnSuper <> 0
then do:
<M-3 run SetMessage
(input #T-10'Data could not be loaded: unable to load the tax period ($1).':200(3868)T-10# (icMessage),
input string(iiVATPeriod_ID) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 2 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-786':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
assign oiReturnStatus = -1.
return.
end.
find first tVATPeriod where tVATPeriod.VATPeriod_ID = iiVATPeriod_ID no-error.
if not available tVATPeriod
then do:
<M-4 run SetMessage
(input #T-11'The data have been successfully loaded, but the tax period record ($1) is not available.':200(3869)T-11# (icMessage),
input string(iiVATPeriod_ID) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 2 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-787':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
assign oiReturnStatus = -1.
return.
end.
if tVatPeriod.VatPeriodStatus = {&VATPERIODSTATUS-REPORTED} and
icStatus = {&VATPERIODSTATUS-REPORTED}
then do:
<M-5 run SetMessage
(input #T-12'Tax period $1 has already been reported.':150(3870)T-12# (icMessage),
input string(iiVATPeriod_ID) (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 2 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-788':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
assign oiReturnStatus = -1.
return.
end.
if ilIsReportChecked <> ?
then assign tVatPeriod.VatPeriodIsReportChecked = ilIsReportChecked.
if icStatus <> ? and
icStatus <> "":U
then do:
assign tVatPeriod.VatPeriodStatus = icStatus.
if icStatus <> {&VATPERIODSTATUS-REPORTED}
then assign tVatPeriod.VatPeriodIsReportChecked = false.
end.
assign tVatPeriod.tc_Status = "C":U.
<M-6 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = -1.
return.
end.
<M-7 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = -1.
return.
end.
<M-8 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BVATPeriod>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = -1.
return.
end.
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 = "BVATPeriod".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "APIUpdateVATPeriodStatus".
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/bvatperiod.apiupdatevatperiodstatus.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiVATPeriod_ID = <parameter value>
vhParameter::icStatus = <parameter value>
vhParameter::ilIsReportChecked = <parameter value>
vhParameter::iiVATPeriodYear = <parameter value>
vhParameter::iiVATPeriodPeriod = <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.