project QadFinancials > class BDeductionCat > method ApiGetExpenseSubCCAndSAF


Parameters


iiDeductionCatLineIDinputintegerDeductionCatLine ID.
tDeductionSafoutputtemp-table
ocCostCentreCodeoutputcharacter
ocDivisionCodeoutputcharacter
ocGLCodeoutputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.CreateDInvoicesDeduction


program code (program9/bdeductioncat.p)

assign oiReturnStatus = -98
       ocGLCode = "":U
       ocDivisionCode = "":U
       ocCostCentreCode = "":U.

empty temp-table tDeductionSaf.
/*No Deduction Cat Line */
if iiDeductionCatLineID = ? 
   or iiDeductionCatLineID = 0 then return.

/*get deduction expense account information */

<Q-42 run DeductionCatLineExpenseAccount (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input iiDeductionCatLineID, (DeductionCatLine_ID)
    output dataset tqDeductionCatLineExpenseAccount) in BDeductionCat>

for each tqDeductionCatLineExpenseAccount no-lock:
    if ocGLCode = '':U then
    do: 
       assign ocGLCode = tqDeductionCatLineExpenseAccount.tcGLCode
              ocCostCentreCode = tqDeductionCatLineExpenseAccount.tcCostCentreCode
              ocDivisionCode = tqDeductionCatLineExpenseAccount.tcDivisionCode.
       /*check expense account is valid */
       if tqDeductionCatLineExpenseAccount.tlGLIsActive <> true then 
       do:
                <M-93 run SetMessage
                   (input  #T-52'The expense GL account $1 is not valid':40(339911997)T-52# (icMessage), 
                    input  ocGLCode (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'qadfin-132633':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDeductionCat>
                return.
       end.
    end.

    /*build the output parameter DefaultSaf */
    if tqDeductionCatLineExpenseAccount.tcSafCode <> '':U 
       and tqDeductionCatLineExpenseAccount.tcSafCode <> ? then 
    do:
        create tDeductionSaf.
        assign tDeductionSaf.tcSafCode = tqDeductionCatLineExpenseAccount.tcSafCode
           tDeductionSaf.tcSafConceptCode = tqDeductionCatLineExpenseAccount.tcSafConceptCode.
    end.

end.

if ocGLCode = "":U then 
do:
    return.
end.

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 = "BDeductionCat".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiGetExpenseSubCCAndSAF".
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/bdeductioncat.apigetexpensesubccandsaf.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiDeductionCatLineID = <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.