project BLF > class PMfgPro > method CallService

Description

Call a service on the remote service via the predefined service interface layer.

!!! the dataset handles should be passed by reference.

If you don't want to use the generic dispatcher procedure (com/qad/qra/si/RPCRequestService.p), you need to specify the data item vcDispatcherName.


Parameters


icProgramNameinputcharacterName of the MfgPro procedure that holds the service implementation on the server side.
This is optional. It is defaulted to the global class data item "vcDefaultMfgProgram", which is set in the InitInstance method.
icMethodNameinputcharacterName of the method that should be executed on the backend service.
izInputinputdataset-handle
bzInputOutputinput-outputdataset-handle
bzOutputinput-outputdataset-handle
icAsyncHandlerinputcharacterThe name of a procedure that acts as the handler in an asynchronous call.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method PMfgPro.CallStandAloneService
method PAuthentication.Authenticate
method PAuthentication.GetTimeOutRemote
method PAuthentication.GetUserRemote
method PAuthentication.IsAlive
method PAuthentication.Logout
method PTimeZone.getCurrentTimeZoneOffset

QadFinancials
method PAvatax.GetAvataxConfig
method PBankAccountValidation.ValidateBankAccount
method PEDI.ExecuteEDI
method PGTM.CalculateTax
method PGTM.CancelTax
method PGTM.GetTaxEnvironment
method PGTM.GetTaxZone
method PGTM.PostTaxCommit
method PGTM.RecalculateTaxAvataxCommit
method PGTM.ValidateAddress
method PLicense.ValidateProgramLicense
method PMfgAnalysisCode.AutoGenCustAC
method PMFGLCDetailByOrderLine.QueryLacodDet
method PMFGLegalDocument.UpdateLDPostStatus
method PMFGLegalDocument.UpdateLegalDocument
method PMFGPendingVoucher.CheckOpenGLPeriod
method PMFGPendingVoucher.UpdatePvoMstr
method PMFGPeriodicCosting.TransferPCCostAdjustment
method PMfgProAccount.GLAccountUsageCheck
method PMfgProFACtrl.SetFAFlagInControl
method PMfgProGetMfgProVersion.GetMfgProVersion
method PMfgProGetPricePriceList.GetPriceFromPriceList
method PMfgProGTApi.UpdateGTTable
method PMfgProNrmApi.ValidateShippingNumbers
method PMfgProSOApi.GetSalesOrderBalance
method PMfgProUpdateOperFromAPM.UpdateOperationalsFromAPM
method PMultiDB.createConnectionRecords
method PMultiDB.UpdateActiveFlag
method PMultiDB.validateDomainCodeAcrossDBs
method PMultiDB.validateEntityCodeAcrossDBs
method PMFGProfile.DeleteCreditorProfile
method PMFGProfile.DeleteDebtorProfile

QadFitnesse
method PMfgProFixedAsset.TestFAApiData


program code (program1/pmfgpro.p)

assign oiReturnStatus = -98.

/* First, make sure the session context is updated correctly */
if vcGlobalSessionId = ""
then do:
        /* retrieve global session if not yet available */
        <M-6 run StartCacher
           (output vhFcComponent (ohCacher), 
            output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
        <M-43 run GetCharacterValueFromSession
           (input  viSessionID (iiSessionId), 
            input  'GlobalSessionId' (icDataItemName), 
            output vcGlobalSessionId (ocValue), 
            output viFcReturnSuper (oiReturnStatus)) in Cacher>     
end.

<M-91 run SetQadContextProperty
   (input  'sessionId' (icPropertyName), 
    input  vcGlobalSessionId (icPropertyValue), 
    output viFcReturnSuper (oiReturnStatus)) in PMfgPro>


if (icProgramName <> vcDefaultMfgProgram and icProgramName <> "")
then do :
    <M-1 run SetQadContextProperty (input  'programName':U (icPropertyName), 
                                input  icProgramName (icPropertyValue), 
                                output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
    if viFcReturnSuper <> 0
    then do :
        assign oiReturnStatus = viFcReturnSuper.
        <M-2 run SetMessage (input  #T-1'The -$1- property could not be set in the internal service context.':100(8066)T-1# (icMessage), 
                     input  'ProgramName':U (icArguments), 
                     input  '' (icFieldName), 
                     input  '' (icFieldValue), 
                     input  'S':U (icType), 
                     input  1 (iiSeverity), 
                     input  '' (icRowid), 
                     input  'BLF-369':U (icFcMsgNumber), 
                     input  'The internal context property could not be set.  This is an internal error.':U (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
        return.
    end.
end.
else if vcDefaultMfgProgram <> <M-23 GetQADContextProperty
                                  (input  'programName':U (icPropertyName)) in PMfgPro>
then do /* reset to the default program */:
    <M-19 run SetQadContextProperty
       (input  'programName':U (icPropertyName), 
        input  vcDefaultMfgProgram (icPropertyValue), 
        output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
    if viFcReturnSuper <> 0
    then do :
        assign oiReturnStatus = viFcReturnSuper.
        <M-20 run SetMessage (input  #T-21'The -$1- property could not be set in the internal service context.':100(8066)T-21# (icMessage), 
                     input  'ProgramName':U (icArguments), 
                     input  '' (icFieldName), 
                     input  '' (icFieldValue), 
                     input  'S':U (icType), 
                     input  1 (iiSeverity), 
                     input  '' (icRowid), 
                     input  'BLF-374':U (icFcMsgNumber), 
                     input  'The internal context property could not be set.  This is an internal error.':U (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
        return.
    end.
end.

if icMethodName = "" or icMethodName = ?
then do :
        assign oiReturnStatus = -1.
        <M-24 run SetMessage
           (input  'The method name was not specified for this service call':U (icMessage), 
            input  '' (icArguments), 
            input  '' (icFieldName), 
            input  '' (icFieldValue), 
            input  'S':U (icType), 
            input  1 (iiSeverity), 
            input  '' (icRowid), 
            input  'BLF-375':U (icFcMsgNumber), 
            input  'This is an internal error.':U (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
        return.
end.
else do:
    <M-3 run SetQadContextProperty
       (input  'methodName':U (icPropertyName), 
        input  if icMethodName = 'Fake':U then ? else icMethodName (icPropertyValue), 
        output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
    if viFcReturnSuper <> 0
    then do :
        assign oiReturnStatus = viFcReturnSuper.
        <M-4 run SetMessage (input  #T-5'The -$1- property could not be set in the internal service context.':100(8066)T-5# (icMessage), 
                         input  'MethodName':U (icArguments), 
                         input  '' (icFieldName), 
                         input  '' (icFieldValue), 
                         input  'S':U (icType), 
                         input  1 (iiSeverity), 
                         input  '' (icRowid), 
                         input  'BLF-370':U (icFcMsgNumber), 
                         input  'The internal context property could not be set.  This is an internal error.':U (icFcExplanation), 
                         input  '' (icFcIdentification), 
                         input  '' (icFcContext), 
                         output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
        return.
    end.
end.


/* Call the backend service method, using the corresponding right parameters */
assign vhNullDataSet          = ?
       vlInputAvailable       = (valid-handle (izInput) And izInput:Name <> '':U)
       vlInputOutputAvailable = (valid-handle (bzInputOutput) And bzInputOutput:Name <> '':U)
       vlOutputAvailable      = (valid-handle (bzOutput) And bzOutput:Name <> '':U)
       vcControl              = (if vlInputAvailable then "1":U else "0":U) +
                                (if vlInputOutputAvailable then "1":U else "0":U) +
                                (if vlOutputAvailable then "1":U else "0":U)
       vhAsyncHandlerProc     = (if icAsyncHandler <> "" and icAsyncHandler <> ? then {&TARGETPROCEDURE} else ?)
       vcAsyncHandlerMethod   = (if icAsyncHandler <> "" and icAsyncHandler <> ? then icAsyncHandler else ?)
       vhContextDS            = dataset tContext:handle
       vhParamDsIn            = (if vlInputAvailable then izInput else 
                                 (if vcDispatcherName = "" or vcDispatcherName = ?
                                  then vhNullDataSet
                                  else dataset dNullDispatchIn:handle))
       vhParamDsInOut         = (if vlInputOutputAvailable then bzInputOutput else 
                                 (if vcDispatcherName = "" or vcDispatcherName = ?
                                  then vhNullDataSet
                                  else dataset dNullDispatchInOut:handle))
       vhParamDsOut           = (if vlOutputAvailable then bzOutput else 
                                 (if vcDispatcherName = "" or vcDispatcherName = ?
                                  then vhNullDataSet
                                  else dataset dNullDispatchOut:handle))
       vhSessionContextSI     = dataset dsSessionContext:handle.
       
<M-9 run SetQadContextProperty
   (input  'datasetInName':U (icPropertyName), 
    input  (if valid-handle(izInput) then izInput:name else '') (icPropertyValue), 
    output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
if viFcReturnSuper <> 0
then do :
    assign oiReturnStatus = viFcReturnSuper.
    <M-10 run SetMessage
       (input  #T-11'The -$1- property could not be set in the internal service context.':100(8066)T-11# (icMessage), 
        input  'datasetInName':U (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'S':U (icType), 
        input  1 (iiSeverity), 
        input  '' (icRowid), 
        input  'BLF-371':U (icFcMsgNumber), 
        input  'The internal context property could not be set.  This is an internal error.':U (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
    return.
end.

<M-12 run SetQadContextProperty
   (input  'datasetInOutName':U (icPropertyName), 
    input  (if valid-handle(bzInputOutput) then bzInputOutput:name else '') (icPropertyValue), 
    output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
if viFcReturnSuper <> 0
then do :
    assign oiReturnStatus = viFcReturnSuper.
    <M-13 run SetMessage
       (input  #T-14'The -$1- property could not be set in the internal service context.':100(8066)T-14# (icMessage), 
        input  'datasetInOutName':U (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'S':U (icType), 
        input  1 (iiSeverity), 
        input  '' (icRowid), 
        input  'BLF-372':U (icFcMsgNumber), 
        input  'The internal context property could not be set.  This is an internal error.':U (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
    return.
end.

<M-15 run SetQadContextProperty
   (input  'datasetOutName':U (icPropertyName), 
    input  (if valid-handle(bzOutput) then bzOutput:name else '') (icPropertyValue), 
    output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
if viFcReturnSuper <> 0
then do :
    assign oiReturnStatus = viFcReturnSuper.
    <M-16 run SetMessage
       (input  #T-17'The -$1- property could not be set in the internal service context.':100(8066)T-17# (icMessage), 
        input  'datasetOutName':U (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'S':U (icType), 
        input  1 (iiSeverity), 
        input  '' (icRowid), 

        input  'BLF-373':U (icFcMsgNumber), 
        input  'The internal context property could not be set.  This is an internal error.':U (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
    return.
end.

/* Make sure the context dataset is put in the right format to pass it */
empty temp-table ttContext.
for each tContext:
    create ttContext.
    assign ttContext.PropertyName = tContext.tcPropertyName
           ttContext.PropertyValue = tContext.tcPropertyValue
           ttContext.PropertyQualifier = tContext.tcPropertyQualifier.              
end.

<M-29 run SetFullMarshall
   (input-output vhSessionContextSI by-reference (bzDataSet), 
    output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
    
<M-30 run SetFullMarshall
   (input-output vhExceptionDS by-reference (bzDataSet), 
    output viFcReturnSuper (oiReturnStatus)) in PMfgPro>

<M-31 run SetFullMarshall
   (input-output vhParamDsIn by-reference (bzDataSet), 
    output viFcReturnSuper (oiReturnStatus)) in PMfgPro>

<M-32 run SetFullMarshall
   (input-output vhParamDsOut by-reference (bzDataSet), 
    output viFcReturnSuper (oiReturnStatus)) in PMfgPro>

<M-33 run SetFullMarshall
   (input-output vhParamDsInOut by-reference (bzDataSet), 
    output viFcReturnSuper (oiReturnStatus)) in PMfgPro>

do transaction on error undo, leave
               on stop  undo, leave:    
    run CallService in vhServiceCaller
        (input-output    dataset-handle vhSessionContextSI,
         output          dataset-handle vhExceptionDS,
         input           dataset-handle vhParamDsIn by-reference,
         input-output    dataset-handle vhParamDsInOut by-reference,
         input-output    dataset-handle vhParamDsOut by-reference,
         input           vhAsyncHandlerProc,
         input           vcAsyncHandlerMethod,
         input           vcDispatcherName /*pcDisparcherName as character*/ ).      
end.

/* First, trap any 4GL exceptions */
if error-status:error
then do :
    do viCnt = 1 to 5:
        assign vcError = error-status:get-message(viCnt).
        <M-35 run SetMessage
          (input  '4GL error: ':U + vcError (icMessage), 
           input  '' (icArguments), 
           input  '' (icFieldName), 
           input  '' (icFieldValue), 
           input  'S':U (icType), 
           input  1 (iiSeverity), 
           input  '' (icRowid), 
           input  'BLF-376':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
    end.
    assign oiReturnStatus = -5.
    return.
end.


/* Check for MfgPro error messages */
<M-8 run StoreSIExceptions
   (input  vhExceptionDS by-reference (izExceptionDS), 
    output viReturnFromService (oiReturnFromService), 
    output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
assign oiReturnStatus = viReturnFromService.

/*delete dataset vhExceptionDS to avoid that temp_err_msg keeps living in memory*/
delete object vhExceptionDS no-error.