Description
This method is used on the UI for Excel Integration. It returns all BusinessRelation info so they can be shown in the Excel Integration grid.
Parameters
tApiBusinessRelation | output | temp-table | temp-table of businessrelation for ApiMaintainAddress. |
tApiAddress | output | temp-table | Temp-table of address used for maintain. |
tApiContact | output | temp-table | Cotact temp-table used for maintain. |
tApiVatNumber | output | temp-table | |
tApiBusRelationSafDefault | output | temp-table | temp-table containing the SafDefault informatioon for a BusinessRelation |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program9/bbusinessrelation.p)
empty temp-table tApiBusinessRelation.
empty temp-table tApiAddress.
empty temp-table tApiContact.
empty temp-table tApiVatNumber.
empty temp-table tApiBusRelationSafDefault.
/* ================= */
/* Business Relation */
/* ================= */
<Q-3 run CorporateGroupPrim (Start) in BCorporateGroup >
<Q-9 run LanguagePrim (Start) in BLanguage >
<Q-1 run BusinessRelationByCode (all) (Read) (NoCache)
(input ?, (BusinessRelationCode)
input viDomainID, (DomainID)
output dataset tqBusinessRelationByCode) in BBusinessRelation >
for each tqBusinessRelationByCode:
create tApiBusinessRelation.
<M-2 run BufferCopy
(input buffer tqBusinessRelationByCode:handle (ihFrom),
input buffer tApiBusinessRelation:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
assign tApiBusinessRelation.tcCorporateGroupCode = <M-4 ApiLoadBusinessRelationCalcCorporateGroupCode
(input tApiBusinessRelation.CorporateGroup_ID (iiCorporateGroupId)) in BBusinessRelation>
tApiBusinessRelation.tcLngCode = <M-10 ApiLoadBusinessRelationCalcLngCode
(input tApiBusinessRelation.Lng_ID (iiLngId)) in BBusinessRelation>
tApiBusinessRelation.tc_ParentRowid = "":U
tApiBusinessRelation.tc_Status = "":U.
create tBusRelIndex.
assign tBusRelIndex.tcRowID = tqBusinessRelationByCode.tc_rowid
tBusRelIndex.tiBusinessRelationID = tqBusinessRelationByCode.tiBusinessRelation_ID.
end.
<Q-5 run CorporateGroupPrim (Stop) in BCorporateGroup >
/* ======= */
/* Address */
/* ======= */
<Q-16 run AddressTypePrim (Start) in BAddressType >
<Q-19 run CountryPrim (Start) in BCountry >
<Q-22 run CountyPrim (Start) in BCounty >
<Q-27 run StatePrim (Start) in BState >
<Q-14 run AddressByBusinessRelation (all) (Read) (NoCache)
(input ?, (BusinessRelationId)
output dataset tqAddressByBusinessRelation) in BBusinessRelation >
for each tqAddressByBusinessRelation,
first tBusRelIndex where
tBusRelIndex.tiBusinessRelationID = tqAddressByBusinessRelation.tiBusinessRelation_ID:
create tApiAddress.
<M-15 run BufferCopy
(input buffer tqAddressByBusinessRelation:handle (ihFrom),
input buffer tApiAddress:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
assign tApiAddress.tcAddressTypeCode = <M-17 ApiLoadBusinessRelationCalcAddressTypeCode
(input tApiAddress.AddressType_ID (iiAddressTypeId)) in BBusinessRelation>
tApiAddress.tc_ParentRowid = tBusRelIndex.tcRowID
tApiAddress.tc_Rowid = tqAddressByBusinessRelation.tc_rowid
tApiAddress.tc_Status = "":U.
if tApiAddress.Country_ID = 0 or
tApiAddress.Country_ID = ?
then assign tApiAddress.tcCountryCode = "":U
tApiAddress.tcCountryDescription = "":U
tApiAddress.tiCountryFormat = 0.
else do:
<Q-20 run CountryPrim (all) (Read) (Cache)
(input tApiAddress.Country_ID, (CountryId)
input ?, (CountryCode)
output dataset tqCountryPrim) in BCountry >
find first tqCountryPrim where
tqCountryPrim.tiCountry_ID = tApiAddress.Country_ID
no-error.
assign tApiAddress.tcCountryCode = if available tqCountryPrim
then tqCountryPrim.tcCountryCode
else "":U
tApiAddress.tcCountryDescription = if available tqCountryPrim
then tqCountryPrim.tcCountryDescription
else "":U
tApiAddress.tiCountryFormat = if available tqCountryPrim
then tqCountryPrim.tiCountryFormat
else 0.
end.
if tApiAddress.County_ID = 0 or
tApiAddress.County_ID = ?
then assign tApiAddress.tcCountyCode = "":U
tApiAddress.tcCountyDescription = "":U.
else do:
<Q-23 run CountyPrim (all) (Read) (Cache)
(input tApiAddress.County_ID, (County_ID)
input ?, (CountyCode)
output dataset tqCountyPrim) in BCounty >
find first tqCountyPrim where
tqCountyPrim.tiCounty_ID = tApiAddress.County_ID
no-error.
assign tApiAddress.tcCountyCode = if available tqCountyPrim
then tqCountyPrim.tcCountyCode
else "":U
tApiAddress.tcCountyDescription = if available tqCountyPrim
then tqCountyPrim.tcCountyDescription
else "":U.
end.
if tApiAddress.Lng_ID = 0 or
tApiAddress.Lng_ID = ?
then assign tApiAddress.tcLngCode = "":U
tApiAddress.tcLngDescription = "":U.
else do:
<Q-26 run LanguagePrim (all) (Read) (Cache)
(input ?, (LngCode)
input tApiAddress.Lng_ID, (LngID)
output dataset tqLanguagePrim) in BLanguage >
find first tqLanguagePrim where
tqLanguagePrim.tiLng_ID = tApiAddress.Lng_ID
no-error.
assign tApiAddress.tcLngCode = if available tqLanguagePrim
then tqLanguagePrim.tcLngCode
else "":U
tApiAddress.tcLngDescription = if available tqLanguagePrim
then tqLanguagePrim.tcLngDescription
else "":U.
end.
if tApiAddress.State_ID = 0 or
tApiAddress.State_ID = ?
then assign tApiAddress.tcStateCode = "":U
tApiAddress.tcStateDescription = "":U.
else do:
<Q-28 run StatePrim (all) (Read) (Cache)
(input tApiAddress.State_ID, (StateID)
input ?, (StateCode)
output dataset tqStatePrim) in BState >
find first tqStatePrim where
tqStatePrim.tiState_ID = tApiAddress.State_ID
no-error.
assign tApiAddress.tcStateCode = if available tqStatePrim
then tqStatePrim.tcStateCode
else "":U
tApiAddress.tcStateDescription = if available tqStatePrim
then tqStatePrim.tcStateDescription
else "":U.
end.
create tAddressIndex.
assign tAddressIndex.tcRowID = tqAddressByBusinessRelation.tc_rowid
tAddressIndex.tiAddressId = tqAddressByBusinessRelation.tiAddress_ID.
end.
<Q-29 run StatePrim (Stop) in BState >
<Q-24 run CountyPrim (Stop) in BCounty >
<Q-18 run AddressTypePrim (Stop) in BAddressType >
<Q-25 run LanguagePrim (Stop) in BLanguage >
/* ======= */
/* Contact */
/* ======= */
<Q-30 run ContactByAddress (all) (Read) (NoCache)
(input ?, (AddressId)
output dataset tqContactByAddress) in BBusinessRelation >
for each tqContactByAddress,
first tAddressIndex where
tAddressIndex.tiAddressId = tqContactByAddress.tiAddress_ID:
create tApiContact.
<M-31 run BufferCopy
(input buffer tqContactByAddress:handle (ihFrom),
input buffer tApiContact:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
assign tApiContact.tc_ParentRowid = tAddressIndex.tcRowID
tApiContact.tc_Rowid = entry(1, tqContactByAddress.tc_rowid)
tApiContact.tc_Status = "":U.
end.
/* ========== */
/* VAT Number */
/* ========== */
<Q-32 run VatNumberByBusinessRelation (all) (Read) (NoCache)
(input ?, (BusinessRelationId)
input ?, (VatNumberIDToSkip)
input ?, (IdentityCountryID)
input ?, (VatNumberIdentity)
input ?, (BusinessRelationIDToSkip)
output dataset tqVatNumberByBusinessRelation) in BBusinessRelation >
for each tqVatNumberByBusinessRelation,
each tBusRelIndex where
tBusRelIndex.tiBusinessRelationID = tqVatNumberByBusinessRelation.tiBusinessRelation_ID:
create tApiVatNumber.
<M-33 run BufferCopy
(input buffer tqVatNumberByBusinessRelation:handle (ihFrom),
input buffer tApiVatNumber:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
assign tApiVatNumber.tcDeclarationCountryCode = <M-35 ApiLoadBusinessRelationCalcCountryCode
(input tApiVatNumber.DeclarationCountry_ID (iiCountryId)) in BBusinessRelation>
tApiVatNumber.tcIdentityCountryCode = <M-36 ApiLoadBusinessRelationCalcCountryCode
(input tApiVatNumber.IdentityCountry_ID (iiCountryId)) in BBusinessRelation>
tApiVatNumber.tc_ParentRowid = tBusRelIndex.tcRowID
tApiVatNumber.tc_Rowid = entry(1, tqVatNumberByBusinessRelation.tc_rowid)
tApiVatNumber.tc_Status = "":U.
end.
<Q-34 run CountryPrim (Stop) in BCountry >
/* =========== */
/* SAF Default */
/* =========== */
<Q-37 run BusRelationSafDefaultByBRID (all) (Read) (NoCache)
(input ?, (BusinessRelationID)
output dataset tqBusRelationSafDefaultByBRID) in BBusinessRelation >
for each tqBusRelationSafDefaultByBRID,
each tBusRelIndex where
tBusRelIndex.tiBusinessRelationID = tqBusRelationSafDefaultByBRID.tiBusinessRelation_ID:
create tApiBusRelationSafDefault.
<M-38 run BufferCopy
(input buffer tqBusRelationSafDefaultByBRID:handle (ihFrom),
input buffer tApiBusRelationSafDefault:handle (ihTo),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
assign tApiBusRelationSafDefault.tc_ParentRowid = tBusRelIndex.tcRowID
tApiBusRelationSafDefault.tc_Rowid = entry(1, tqBusRelationSafDefaultByBRID.tc_rowid)
tApiBusRelationSafDefault.tc_Status = "":U.
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 = "ApiLoadBusinessRelation".
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.