Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | DSPs and building output templates | Using Dynamic Server Pages (DSPs) | Using the DSP Tags | Why Does Scope Matter? | Ending the Scope of the Invoke Action
 
Ending the Scope of the Invoke Action
The %end% element in the %invoke%…%end% construct ends the scope for that invoke. It marks the point in the DSP where the variables associated with that construct are dropped and scope reverts to the previous level.
The following example shows a DSP that invokes two services in sequence. In this DSP, both services receive the variables from the initial scope as input. The two %invoke% blocks are highlighted in bold in the sample.
<HTML>
<HEAD>
<title>Order Tracking System</title>
</HEAD>
<!--User passes in order number in param named oNum> -->
<!--The initial scope contains only <oNum> -->

%invoke orders:getShipInfo%
<!--Scope switches to results
of getShipInfo -->

<!--You can reference variables
in the initial scope -->

<!--with a relative addressing
qualifier -->

<p>
Order: %value /oNum%<br>
Date Shipped: %value shipDate%<br>
Carrier: %value carrier% %value
serviceLevel%

</p>
%endinvoke%

<!--Scope reverts to the initial scope -->
<!--Results from getShipInfo have been discarded -->
<!--and cannot be accessed beyond this point -->

%invoke orders:getCustInfo%
<!--Scope switches to results
of getCustInfo -->

<!--You can reference variables
in the initial scope-->

<!--with a relative addressing
qualifier -->

<table>
<tr><td>Company:</td>
<td>%value companyName%</td></tr>

<tr><td>Phone:</td>
<td>%value phoneNum%</td></tr>

<tr><td>Address:</td>
<td>%value StreetAddr1%<br>

%value StreetAddr2%</td></tr>
<tr><td></td> <td>%value
city%, %value state%</td></tr>

<tr><td></td> <td>%value
postalCode%</td></tr>

</table>
%endinvoke%

<!--Scope reverts to the initial scope -->
<!--Results from getCustInfo have been discarded -->
<!--and cannot be accessed beyond this point -->
</BODY>
</HTML>
<HTML>
<HEAD>
<title>Order Tracking System</title>
</HEAD>
<!--User passes in order number in param named <oNum> -->
<!--The initial scope contains only <oNum> -->

%invoke orders:getShipInfo%
<!--Scope switches to results
of getShipInfo -->

<!--You can reference variables
in the initial scope -->

<!--with a relative addressing
qualifier -->

<p>
Order: %value /oNum%<br>
Date Shipped: %value shipDate%<br>
Carrier: %value carrier% %value
serviceLevel%

</p>
%invoke orders:getCustInfo%
<!--Scope switches to results
of getCustInfo -->

<!--You can reference variables
in the initial scope -->

<!--and prior scope with relative
addressing qualifiers -->

<table>
<tr><td>Company:</td>
<td>%value companyName%</td></tr>

<tr><td>Phone:</td>
<td>%value phoneNum%</td></tr>
<tr><td>Address:</td> <td>%valueStreetAddr1%<br>
%value StreetAddr2%</td></tr>
<tr><td></td> <td>%value
city%, %value

state%</td></tr>
<tr><td></td> <td>%value
postalCode%</td></tr>

</table>
%endinvoke%
<!--Scope reverts back to results
of getShipInfo -->

<!--Results from getCustInfo
have been discarded -->

<!--and cannot be accessed beyond
this point -->

%endinvoke%

<!--Scope reverts to the initial scope -->
<!--Results from getShipInfo have been discarded -->
<!--and cannot be accessed beyond this point -->
</BODY>
</HTML>