icProgramName | input | character | Name 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. |
icMethodName | input | character | Name of the method that should be executed on the backend service. |
izInput | input | dataset-handle | |
bzInputOutput | input-output | dataset-handle | |
bzOutput | input-output | dataset-handle | |
icAsyncHandler | input | character | The name of a procedure that acts as the handler in an asynchronous call. |
oiReturnStatus | output | integer | Return status of the method. |
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.