project QadFinancials > class BAccountingInterface > method ApiSynchronise

Description

This method is used to synchronize the China Accounting Interface's report filter information.


Parameters


olUpdatesDoneoutputlogicalIndicates whether the update action had been done.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BSystem.ApiSynchroniseCustom2


program code (program9/baccountinginterface.p)

/* Set default Returnstatus , clear the instance */
assign oiReturnStatus = -98.
<M-1 run ClearData
   (output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.

/* Read all existing report record */
<Q-6 assign vlFcQueryRecordsAvailable = AcctIFPrim (NoCache)
   (input ?, (AcctIFCode)
    input ?, (AcctIF_ID)) in BAccountingInterface >

/* if there is data available we can stop this action*/ 
if not vlFcQueryRecordsAvailable = false
then do:
    assign oiReturnStatus = 0.
    return.
end.

/* create report records */
<M-7 run AddDetailLine
   (input  'AcctIF':U (icTable), 
    input  '':U (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
assign tAcctIF.AcctIFCode           = 'DZZB':U
       tAcctIF.AcctIFName           = '????????':U
       tAcctIF.AcctIFExportFileName = 'dzzb.txt':U.

<M-8 run AddDetailLine
   (input  'AcctIF':U (icTable), 
    input  '':U (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
assign tAcctIF.AcctIFCode           = 'KJKM':U
       tAcctIF.AcctIFName           = '????????':U 
       tAcctIF.AcctIFExportFileName = 'kjkm.txt':U.

<M-9 run AddDetailLine
   (input  'AcctIF':U (icTable), 
    input  '':U (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
assign tAcctIF.AcctIFCode           = 'BMXX':U
       tAcctIF.AcctIFName           = '?????????':U 
       tAcctIF.AcctIFExportFileName = 'bmxx.txt':U.

<M-10 run AddDetailLine
   (input  'AcctIF':U (icTable), 
    input  '':U (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
assign tAcctIF.AcctIFCode           = 'WLDW':U
       tAcctIF.AcctIFName           = '?????????':U 
       tAcctIF.AcctIFExportFileName = 'wldw.txt':U.

<M-11 run AddDetailLine
   (input  'AcctIF':U (icTable), 
    input  '':U (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
assign tAcctIF.AcctIFCode           = 'XMXX':U
       tAcctIF.AcctIFName           = '?????????':U 
       tAcctIF.AcctIFExportFileName = 'xmxx.txt':U.

<M-12 run AddDetailLine
   (input  'AcctIF':U (icTable), 
    input  '':U (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
assign tAcctIF.AcctIFCode           = 'KMYE':U
       tAcctIF.AcctIFName           = '?????????????':U 
       tAcctIF.AcctIFExportFileName = 'kmye.txt':U.

<M-13 run AddDetailLine
   (input  'AcctIF':U (icTable), 
    input  '':U (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
assign tAcctIF.AcctIFCode           = 'JZPZ':U
       tAcctIF.AcctIFName           = '????????':U 
       tAcctIF.AcctIFExportFileName = 'jzpz.txt':U.

<M-14 run AddDetailLine
   (input  'AcctIF':U (icTable), 
    input  '':U (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
assign tAcctIF.AcctIFCode           = 'Q_ZCFZ':U
       tAcctIF.AcctIFName           = '???????????':U 
       tAcctIF.AcctIFExportFileName = 'q_zcfz.txt':U.

<M-15 run AddDetailLine
   (input  'AcctIF':U (icTable), 
    input  '':U (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
assign tAcctIF.AcctIFCode           = 'Q_LR':U
       tAcctIF.AcctIFName           = '?????????':U 
       tAcctIF.AcctIFExportFileName = 'q_lr.txt':U.

<M-16 run AddDetailLine
   (input  'AcctIF':U (icTable), 
    input  '':U (icParentRowid), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
assign tAcctIF.AcctIFCode           = 'GSSM':U
       tAcctIF.AcctIFName           = '??????':U 
       tAcctIF.AcctIFExportFileName = 'gssm.txt':U       
       tAcctIF.AcctIFIsExport = true.
                                                   
<M-3 run ValidateBC
   (output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
<M-4 run AdditionalUpdates
   (output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.
<M-5 run DataSave
   (output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper <> 0
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.

/* ==================================== */
/* Indicate that changes have been done */
/* ==================================== */
assign olUpdatesDone = true.
        
/* indicate that changes are done */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.


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 = "BAccountingInterface".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiSynchronise".
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 = "".

/* 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.