project QadFinancials > class BBusinessRelation > method ApiLoadSingleBusinessRelation

Description

This method is used on the UI to load a single business relation set of data by BusinessRelationId.


Parameters


iiBusinessRelationIdinputintegerBusiness relation id field.
tApiBusinessRelationoutputtemp-table
tApiAddressoutputtemp-table
tApiContactoutputtemp-table
tApiVatNumberoutputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program4/bbusinessrelation.p)

if iiBusinessRelationId = 0  or 
   iiBusinessRelationId = ?
then return.   

assign oiReturnStatus = -98.
            
empty temp-table tApiBusinessRelation.
empty temp-table tApiAddress.
empty temp-table tApiContact.
empty temp-table tApiVatNumber.
empty temp-table tApiBusRelationSafDefault.

<M-27 run DataLoad
          (input  '' (icRowids), 
           input  string(iibusinessRelationId) (icPkeys), 
           input  '' (icObjectIds), 
           input  '' (icFreeform), 
           input  false (ilKeepPrevious), 
           output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
find first tBusinessRelation no-error.
if available tBusinessRelation
then do:
    create tApiBusinessRelation.
    buffer-copy tBusinessRelation to tApiBusinessRelation.
    
    for each tAddress:
        create tApiAddress.
        buffer-copy tAddress to tApiAddress.
    end.

    for each tContact:
        create tApiContact.
        buffer-copy tContact to tApiContact.
    end.

    for each tVatNumber:
        create tApiVatNumber.
        buffer-copy tVatNumber to tApiVatNumber.
    end.
    
    for each tBusRelationSafDefault:
        create tApiBusRelationSafDefault.
        buffer-copy tBusRelationSafDefault to tApiBusRelationSafDefault.
    end.

    <M-31 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    
    assign oiReturnStatus = 0.
end.
else do :
    <M-30 run SetMessage
          (input  trim(#T-32'Business relation ($1) is not defined in the system.':120(844)t-32#) (icMessage), 
           input  string(iibusinessRelationId) (icArguments), 
           input  'BusinessRelation.BusinessRelation_ID':U (icFieldName), 
           input  '' (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '' (icRowid), 
           input  'QADFIN-1330':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
    assign oiReturnStatus = -4.
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 = "BBusinessRelation".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiLoadSingleBusinessRelation".
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/bbusinessrelation.apiloadsinglebusinessrelation.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiBusinessRelationId = <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.