| icXmlHandle | input | character | String that represents the Handle that refers to the XML file that represents the BusinessRelation, Addresses, Contacts and Vatnumber data that you want to insert into Scba. This handle should be valid and created like this; Create X-document <handle> <handle>:load("File":U,<file-name>) |
| icXmlFileName | input | character | XmlFileName; You can specify a relative pathname, an absolute pathname, or an HTTP URL.. Make sure the file is available to the server where this API is running on. This parameter will only be used if parameters ihXmlFileHandle and tApiXml are invalid, unknown or empty. |
| icAction | input | character | Action Possible values; "SAVE": data will be saved (if errors then no further actions will be taken) "SAVESTORE": data will be saved (it errors then the data will be stored (=DraftInstance) if possible but you will find tFcMessages that contain the reason why the save failed) "STORE": data will be stored (=DraftInstance) if possible "VALIDATE": dat will only be validated. |
| ocLstPrimKey | output | character | LstPrimKey Char4 separated list with the primary keys of the newly created main-table records. The fields of a primkey are separated with Char2. E.g. 1<Char2>2002<Char2>100<Char4>1<Char2>2002<Char2>101 |
| ocLstReturn | output | character | LstReturn Char4 separated list with the return-status of the newly created main-table records. Zero means no errors occured. E.g. 0<Char4>-1<Char4>-504<Char4>1<Char4>0 |
| ocLstRowid | output | character | LstRowid Char4 separated list with the temporarely rowids (negative for new ones) of the newly created main-table records. . E.g. -1<Char2>aox00098001<Char2>-26 |
| oiReturnStatus | output | integer | Return status of the method. |
/* ================= */
/* Empty Temp-tables */
/* ================= */
empty temp-table tApiBusinessRelation.
empty temp-table tApiAddress.
empty temp-table tApiContact.
empty temp-table tApiVatNumber.
empty temp-table tApiBusRelationSafDefault.
/* ============================================= */
/* Start XML Component and hold the handle to it */
/* ============================================= */
<M-1 run MainBlock () in XML>
assign vhXMLConvertionProgram = vhFcComponent.
/* ======================================================= */
/* Call method that will return a handle to the x-document */
/* ======================================================= */
/*V8
<M-? run GetXDocHandle (input icXmlHandle (icXmlHandle),
input tBusinessRelationApiXml (tApiXml),
input icXmlFileName (icXmlFileName),
output vcMessage (ocErrorMessage),
output vhXDocHandle (ohXDocHandle),
output viFcReturnSuper (oiReturnStatus)) in XML>
*/
if viFcReturnSuper <> 0
then do:
run gipr_DeleteProcedure in vhXMLConvertionProgram no-error.
delete procedure vhXMLConvertionProgram no-error.
assign oiReturnStatus = viFcReturnSuper.
<M-3 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-841':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
return.
end. /* if viFcReturnSuper <> 0 */
/* ===================================================================== */
/* Call method that will transfer the X-doc handle to temp-table records */
/* ===================================================================== */
assign vcTablesAndHandles = String(buffer tApiBusinessRelation:Handle) + ',BusinessRelation,':U + string(buffer tApiAddress:handle) + ',Address,':U + string(buffer tApiContact:handle) + ',Contact,':U + string(buffer tApiVatNumber:handle) + ',VatNumber,':U + String(buffer tApiBusRelationSafDefault:Handle) + ',BusRelationSafDefault':U.
<M-4 run ConvertXmlToTable (input {&TARGETPROCEDURE} (ihComponent),
input vhXDocHandle (ihParentNode),
input vcTablesAndHandles (icTables),
output tBusinessRelationTableRefXml (tTableRef),
output viFcReturnSuper (oiReturnStatus)) in XML>
run gipr_DeleteProcedure in vhXMLConvertionProgram no-error.
delete procedure vhXMLConvertionProgram no-error.
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = viFcReturnSuper
vcMessage = trim(#T-8'The XML file could not be converted to a corresponding temp table format. Contact your system administrator.':200(852)T-8#) + trim(#T-9'Details':25(853)t-9#) + ';':U + string(viFcReturnSuper).
<M-5 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-842':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
return.
end. /* if viFcReturnSuper <> 0 */
/* ============================= */
/* Set the parent-child relation */
/* ============================= */
for each tApiBusinessRelation:
for each tBusinessRelationTableRefXml where
tBusinessRelationTableRefXml.trParentRowid = rowid(tApiBusinessRelation):
find tApiAddress where
rowid(tApiAddress) = tBusinessRelationTableRefXml.trChildRowid
no-lock no-error.
if not available tApiAddress
then do:
find tApiContact where
rowid(tApiContact) = tBusinessRelationTableRefXml.trChildRowid
no-lock no-error.
if not available tApiContact
then do:
find tApiVatNumber where
rowid(tApiVatNumber) = tBusinessRelationTableRefXml.trChildRowid
no-lock no-error.
if not available tApiVatNumber
then do:
find tApiBusRelationSafDefault where
rowid(tApiBusRelationSafDefault) = tBusinessRelationTableRefXml.trChildRowid
no-lock no-error.
if not available tApiBusRelationSafDefault
then do:
assign oiReturnStatus = -3
vcMessage = trim(#T-10'The XML file could not be converted to a valid temp table format. Contact your system administrator.':200(854)T-10#).
<M-6 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-843':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
return.
end. /* if not available tApiBusRelationSafDefault */
else assign tApiBusinessRelation.tc_Rowid = string(tBusinessRelationTableRefXml.trParentRowid)
tApiBusRelationSafDefault.tc_Rowid = string(tBusinessRelationTableRefXml.trChildRowid)
tApiBusRelationSafDefault.tc_ParentRowid = tApiBusinessRelation.tc_Rowid.
end. /* if not available tApiVatNumber */
else assign tApiBusinessRelation.tc_Rowid = string(tBusinessRelationTableRefXml.trParentRowid)
tApiVatNumber.tc_Rowid = string(tBusinessRelationTableRefXml.trChildRowid)
tApiVatNumber.tc_ParentRowid = tApiBusinessRelation.tc_Rowid.
end. /* if not available tApiContact */
else assign tApiBusinessRelation.tc_Rowid = string(tBusinessRelationTableRefXml.trParentRowid)
tApiContact.tc_Rowid = string(tBusinessRelationTableRefXml.trChildRowid)
tApiContact.tc_ParentRowid = tApiBusinessRelation.tc_Rowid.
end. /* if not available tApiAddress */
else assign tApiBusinessRelation.tc_Rowid = string(tBusinessRelationTableRefXml.trParentRowid)
tApiAddress.tc_Rowid = string(tBusinessRelationTableRefXml.trChildRowid)
tApiAddress.tc_ParentRowid = tApiBusinessRelation.tc_Rowid.
end. /* for each tBusinessRelationTableRefXml */
end. /* for each tApiBusinessRelation */
/* ====================================== */
/* Call method that executes the creation */
/* ====================================== */
<M-7 run ApiStdMaintainTT (input tApiBusinessRelation (tApiBusinessRelation),
input tApiAddress (tApiAddress),
input tApiContact (tApiContact),
input tApiVatNumber (tApiVatNumber),
input tApiBusRelationSafDefault (tApiBusRelationSafDefault),
input icAction (icAction),
output ocLstPrimKey (ocLstPrimKey),
output ocLstReturn (ocLstReturn),
output ocLstRowid (ocLstRowid),
output oiReturnStatus (oiReturnStatus)) in BBusinessRelation>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 = "ApiStdMaintainXml".
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.apistdmaintainxml.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icXmlHandle = <parameter value>
vhParameter::icXmlFileName = <parameter value>
vhParameter::icAction = <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.