iiBusComponentID | input | integer | BusComponentID; not that if this parameter if filled the value of parameter BusComponentLabel will be discarded. Either this parameter ,either parameter BusComponentLabel needs to be filled. |
icBusComponentLabel | input | character | BusComponentLabel; note that the content of this parameter will only be used if parameter BusComponentID is empty. Either this parameter ,either parameter BusComponentID needs to be filled. |
icBusComponentConcept | input | character | BusComponentConcept |
tPossibleRoleScopeValues | output | temp-table | Temp-table containing the possible RoleScopeValues |
ocErrorMessageString | output | character | In case something goes wrong (oiReturnStatus <> 0), this parameter will contain information about the problem |
oiReturnStatus | output | integer | Return status of the method. |
/* ==================================================================== */ /* Note; no SetMessage is used as this method does not need to interact */ /* with the instance and it only returns a set of possible values */ /* ==================================================================== */ /* ============================================= */ /* Validate parameters; */ /* - ID or Label should be filled */ /* Get the code(=physical-name) of the Component */ /* Empty output paramaters */ /* ============================================= */ if iiBusComponentID = ? then assign iiBusComponentID = 0. if icBusComponentLabel = ? then assign icBusComponentLabel = "":U. if icBusComponentConcept = ? then assign icBusComponentConcept = "":U. if iiBusComponentID = 0 and icBusComponentLabel = "":U then do : assign ocErrorMessageString = trim(#T-2'Unable to return role scope values. Component ID or component label should be passed.':255(541)T-2#) oiReturnStatus = -1. return. end. /* if iiBusComponentID = 0 and */ <Q-1 run BusComponentByLabelCodeID (all) (Read) (NoCache) (input iiBusComponentID, (BusComponentID) input ?, (BusComponentCode) input (if iibuscomponentID = 0 then icbusComponentLabel else ?), (BusComponentLabel) output dataset tqBusComponentByLabelCodeID) in BBusinessComponent > find tqBusComponentByLabelCodeID no-lock no-error. if not available tqBusComponentByLabelCodeID then do : assign ocErrorMessageString = trim(substitute(#T-3'Unable to return role scope values. Component could not be found based on the component ID (&1) and the component label (&2).':255(542)T-3#,string(iiBusComponentID),icBusComponentLabel)) oiReturnStatus = -1. return. end. /* if not available tqBusComponentByLabelCodeID */ empty temp-table tPossibleRoleScopeValues. /* =============================================================== */ /* Define, based on the OS, what is a good and what is a bad slash */ /* =============================================================== */ if index(opsys,'UNIX':U) = 0 then assign vcSlash = "~\":U. else assign vcSlash = "/":U. /* =============================================================== */ /* Check if we can find the component its api-interface and run it */ /* =============================================================== */ assign vcComponentFullName = "api":U + trim(vcSlash) + trim(lc(tqBusComponentByLabelCodeID.tcBusComponentCode)) + ".":U. if search(vcComponentFullName + "r":U) = ? and search(vcComponentFullName + "p":U) = ? then do : assign ocErrorMessageString = trim(substitute(#T-4'Unable to return role scope values. The API interface of component '&1' could not be found.':255(543)T-4#,(if tqBusComponentByLabelCodeID.tcBusComponentCode = ? then "?":U else tqBusComponentByLabelCodeID.tcBusComponentCode))) oiReturnStatus = -1. return. end. /* search = ? */ assign vcComponentFullName = vcComponentFullName + "p":U. run value(vcComponentFullName) persistent set vhComponentApiInterface no-error. if error-status:error or not valid-handle(vhComponentApiInterface) then do : assign ocErrorMessageString = trim(substitute(#T-5'Unable to return role scope values. An error has occurred while starting the API interface of component '&1'.':255(544)T-5#,(if tqBusComponentByLabelCodeID.tcBusComponentCode = ? then "?":U else tqBusComponentByLabelCodeID.tcBusComponentCode))) oiReturnStatus = -1. if error-status:num-messages > 0 then assign ocErrorMessageString = ocErrorMessageString + chr(10) + (if error-status:get-message(1) = ? then "?":U else error-status:get-message(1)). return. end. /* if error-status:error */ /* ===================================== */ /* Check if the method is in the program */ /* ===================================== */ if not can-do(vhComponentApiInterface:INTERNAL-ENTRIES,"ApiGetRoleScopeValues":U) then do : assign ocErrorMessageString = trim(substitute(#T-6'Unable to return role scope values. Method (&2) could not be found in the API interface of component '&1'.':255(545)T-6#,(if tqBusComponentByLabelCodeID.tcBusComponentCode = ? then "?":U else tqBusComponentByLabelCodeID.tcBusComponentCode),"ApiGetRoleScopeValues":U)) oiReturnStatus = -1. delete procedure vhComponentApiInterface no-error. return. end. /* if not can-do */ /* ========================================= */ /* Run the fixed-named method in the program */ /* ========================================= */ run ApiGetRoleScopeValues in vhComponentApiInterface (input "":U /* icApiLogin: fixed parameter for api-methods, not passed here as the SessionId is passed */, input "":U /* icApiPassword: fixed parameter for api-methods, not passed here as the SessionId is passed */, input "":U /* icApiExtra: fixed parameter for api-methods, not passed here as the SessionId is passed */, input viSessionID /* iiApiSessionId: fixed parameter for api-methods */, input 0 /* CompanyID */, input 0 /* SharedSetID */, input icBusComponentConcept, output vcRoleScopeValues, output dataset tFcMessages /* Messages: fixed parameter for api-methods */, output viFcReturnSuper /* Returnstatus: fixed parameter for api-methods */) no-error. if error-status:error or viFcReturnSuper <> 0 or not valid-handle(vhComponentApiInterface) then do : assign ocErrorMessageString = trim(substitute(#T-7'Unable to return role scope values. An error has occurred while running the method (&2) in the API interface of component '&1'.':255(546)T-7#,(if tqBusComponentByLabelCodeID.tcBusComponentCode = ? then "?":U else tqBusComponentByLabelCodeID.tcBusComponentCode),"ApiGetRoleScopeValues":U)) oiReturnStatus = -1. if viFcReturnSuper <> 0 then assign ocErrorMessageString = ocErrorMessageString + chr(10) + trim(#T-8'Return Status':20(9000)T-8#) + " = ":U + string(viFcReturnSuper). if error-status:num-messages > 0 then assign ocErrorMessageString = ocErrorMessageString + chr(10) + trim(#T-9'Technical Error Information':100(548)T-9#) + " ":U + (if error-status:get-message(1) = ? then "?":U else error-status:get-message(1)). delete procedure vhComponentApiInterface no-error. return. end. /* if error-status:error */ /* =========================================== */ /* Convert the string into temp-tables records */ /* =========================================== */ do viCounter = num-entries(vcRoleScopeValues,chr(2)) to 1 by -1 : if not can-find (tPossibleRoleScopeValues where tPossibleRoleScopeValues.tcRoleScopeValueExtended = entry(viCounter,vcRoleScopeValues,chr(2))) then do : create tPossibleRoleScopeValues. assign tPossibleRoleScopeValues.tcRoleScopeValueExtended = entry(viCounter,vcRoleScopeValues,chr(2)). end. /* entry(viCounter,vcRoleScopeValues,chr(2)) */ end. /* do viCounter */ /* ===================================== */ /* Free the handle */ /* ===================================== */ delete procedure vhComponentApiInterface no-error.
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 = "BRole". create ttContext. assign ttContext.propertyName = "methodName" ttContext.propertyValue = "ApiGetPossibleRoleScopeValues". 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/brole.apigetpossiblerolescopevalues.i.xsd", ?). vhParameter = vhInputDS:get-buffer-handle("tParameterI"). vhParameter:buffer-create(). assign vhParameter::iiBusComponentID = <parameter value> vhParameter::icBusComponentLabel = <parameter value> vhParameter::icBusComponentConcept = <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.