What is the scope of a variable

Hi All,

Can you please help answer the below questions w.r.t WebMethods

a) Like in any programming language what is the the scope of a variable i.e, Local vs Global, package level etc

b) Apart from Input and Output variables can we define have generic Variables ( neither input not output) defined used for temp storage of data? If yes, then can you please let know how to define them? eg., if we want to swap data amongst two input variables we might need a third variable which could be a generic one

Regards
Kiran

Hello Kiran

w.r.t Question A - The scope of the variables in webMethods flow work bit differently. The entire flow works on a concept called “pipeline”. pipeline is a data structure that get carry forwarded or moved across all flow services. It can flow across services residing in different packages too. So the scope of the variables or fields depends on the pipeline in which they are residing. If you now ask me what is the scope of the pipeline, then it depends on many factors like below:

  • When a service ‘A’ calls/invokes service ‘B’ as a transformer, then pipeline from ‘A’ will not flow to ‘B’. Only the inputs explicitly mapped to ‘B’ will go as input
  • When service ‘A’ has “clearPipeline” step at the end of its service, then pipeline from ‘B’ will not flow into its calling service. Only the outputs specified to the service will flow out.
  • If you write any logic in a flow under a sequence or branch where you have set the “SCOPE” property of that sequence or branch on the right hand side designer properties to a specific document, then only the fields inside that document are available as scope of execution for logic written inside that flow.

Above are some example scenarios to give you some idea on how scope works.

w.r.t Question B - Yes. We can have variables defined which are neither input not output. Before 9.x version, we use to make use of “Extended Settings” or some call them as “watt settings” page on IS Admin to configure and store our custom properties of Key/ Value pairs. To access them, you can use “pub.utils:getServerProperty” util service. Pass a key and it will give you value in return. But from 9.x version onwards, we have a dedicated section provisioned by webMethods to configure/handle these and access them in a easy way. This section is called “Global Variables” and can be found on IS Admin page. We can configure key/value pairs there and access them simply by setting a variable substituion for a key to field in pipeline and check “substitute global variable” option in the setting.

1 Like

Perfect!!! :slight_smile:
Thanks a lot for the detailed explanation which is very informative for a newbie like me!!!