project QadFinancials > class BMfgMessage > method ApiGetComplexMessage

Description

Retrieves the requested message detail from MFG/PRO and replaces the substitution markers with the values passed in in the message argument parameters.


Parameters


iiMessageNumberinputintegerMessage Number to retrieve from MFG/PRO.
icSubstitutionText1inputcharacterText to be substiuted in the message in place of the first substitution marker in the message text.
icSubstitutionText2inputcharacterText to be substiuted in the message in place of the second substitution marker in the message text.
icSubstitutionText3inputcharacterText to be substiuted in the message in place of the third substitution marker in the message text.
icSubstitutionText4inputcharacterText to be substiuted in the message in place of the fourth substitution marker in the message text.
icSubstitutionText5inputcharacterText to be substiuted in the message in place of the fifth substitution marker in the message text.
ocMessageTextoutputcharacterMessage Text with the substitution markers replaced with the substitution text.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method MfgDatabaseComponent.SetComplexMessage


program code (program3/bmfgmessage.p)

assign
    ocMessageText  = ""
    oiReturnStatus = -98.

/*
* Get the message text using the GetSimpleMessage method and then
* apply the Substitution values to the returned message text.
*/
<M-2 run ApiGetSimpleMessage (input  iiMessageNumber (iiMessageNumber), 
                              output ocMessageText (ocMessageText), 
                              output viFcReturnSuper (oiReturnStatus)) in BMfgMessage>

if ocMessageText <> "" and
   ocMessageText <> ?
then do:

    <M-3 run SubstituteArguments (input  icSubstitutionText1 (icSubstitutionText1), 
                                  input  icSubstitutionText2 (icSubstitutionText2), 
                                  input  icSubstitutionText3 (icSubstitutionText3), 
                                  input  icSubstitutionText4 (icSubstitutionText4), 
                                  input  icSubstitutionText5 (icSubstitutionText5), 
                                  input-output ocMessageText (bcMessageText), 
                                  output viFcReturnSuper (oiReturnStatus)) in BMfgMessage>

end. /* ocMessageText <> "" or ? */

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 = "BMfgMessage".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiGetComplexMessage".
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/bmfgmessage.apigetcomplexmessage.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiMessageNumber = <parameter value>
       vhParameter::icSubstitutionText1 = <parameter value>
       vhParameter::icSubstitutionText2 = <parameter value>
       vhParameter::icSubstitutionText3 = <parameter value>
       vhParameter::icSubstitutionText4 = <parameter value>
       vhParameter::icSubstitutionText5 = <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.