A subroutine is a workflow that you can call from multiple orchestration
workflows. Subroutines can contain any orchestration elements, such as the
Calculate step, and are useful when your orchestrations contain common actions.
Once you have created a subroutine, you can use it by dragging it from the
Step Palette into an orchestration workflow.
You can define inputs for a subroutine workflow, similar to defining
Working Data, and you can define outputs for a subroutine in the
Data Mapping tab of the
End step.
Like Web services, you can then map these inputs within the calling
orchestration to the appropriate source elements. You can use outputs in
mapping and expressions of other steps.
Note the following points about subroutines:
- Subroutines can be used in both asynchronous and synchronous
orchestrations.
- You can define as many subroutines as you want and nest them as
needed.
- A subroutine cannot call itself either directly or indirectly via
another subroutine.
Example
This simple example demonstrates how to create a subroutine that
appends the text "-subroutine" to a field.
- Create an application process app and add a new text field called
Text1.
- In the application workflow, create a quick transition called
Test Subroutine that starts and ends at the
New state.
- Add an action to the
Test Subroutine transition that does the
following:
- Calls a new synchronous orchestration before the transition
occurs
- Includes
Text1 as a field that is used and returned
by the event
- In app explorer, right-click
Orchestration Workflows and select
Add New Subroutine.
- Change the default name to
AppendTextSubroutine.
- From the
Step Palette, drag a
Calculate step to the subroutine.
- Select the subroutine workflow. For the data mapping inputs, add
the string
InText1.
- Select the
End step. For the data mapping outputs, add
the string
OutText1.
-
Select the
Calculate step, and create a new assignment
with the following values:
- Target:
OutText1
- Expression:
CONCAT(InText1, "-subroutine")
- Select the orchestration you created in step 2.
- Drag the new subroutine step
AppendTextSubroutine to the orchestration.
-
Select the subroutine step and map the
InText1 input to the following source:
- Select the
End step and map the
Text1 output to the following source:
- Save and deploy the process app.
To test in
SBM Work Center,
submit a new item and then click the
Test Subroutine button. The
Text1 field should display the following:
Copyright © 2007–2018 Serena Software, Inc., a Micro Focus company. All rights reserved.