Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | DSPs and building output templates | Using Output Templates to Format Service Output | %scope%
 
%scope%
You use the %scope% tag to restrict a specified block of code to a particular document in the pipeline. You can also use the %scope% tag to define a completely new document and switch the scope to that document.
Syntax
%scope [DocumentName] [option
option option...]
%
Block of Code
%end%
Arguments
DocumentName specifies the name of a document within the current scope. If you do not specify DocumentName, the param and rparam options will extend the current scope. If you specify a new DocumentName, the scope switches to that document.
Options
You can use any of the following options to add elements to the scope specified by DocumentName. When you specify multiple options, separate them with spaces.
Important:
If you set the value of an existing variable with these options, the value you specify will replace the variable’s current value.
Note:
For space reasons, the %scope% tag is shown on multiple lines in some of the examples below. Be aware that when you use the %scope% tag in a template or DSP, the entire tag must appear on one line.
Option
Description
param(Name=’Value’)
Defines a new String or String array with the name you specify in Name and assigns to it the string you specify in Value.
If Name is a String, specify one Value and enclose it in single quotes. For example:
  %scope param(buyerClass=’Gold’)%
If Name is a String array:
*Include a set of empty brackets at the end of the name to indicate that you are defining an array.
*Enclose each element Value in single quotes.
*Separate elements with commas.
For example:
  %scope param(shipPoints[]=’BWI’,’LAX’, ’ORD’,’MSP’,’DFW’)%
rparam(Name={Key=’Value’; Key=’Value;Key=’Value’})
Defines a new document or document list with the name you specify in Name, and assigns to it, values that you provide in a list of Key=Value pairs.
If Name is a document:
*Enclose its list of elements in braces { }.
*Separate the elements with semicolons.
*Enclose Value strings in single quotes.
For example:
  %scope rparam(custServiceInfo=   {csClass=’Gold’;csPhone=’800-444-2300’;   csRep=’Lauren Cheung’})%
If Name is a document list:
*Enclose each document in the list with braces { }.
*Separate documents with vertical bars |.
*Separate elements within each document with semicolons.
*Enclose Value strings in single quotes.
For example:
  %scope rparam(custServiceCtrs[]=   {csName='Memphis';csPhone='800-444-2300';}|   {csName='Troy';csPhone='800-444-3300';}|   {csName='Austin';csPhone='800-444-4300';})%
Effect on Scope
Switches scope to the specified document.
Notes
The specified scope remains in effect until the next %scope% tag is encountered (which declares a new scope) or the next, non-nested %end% tag is encountered (which reverts to the prior scope).
For readability, you may use %endscope% instead of %end% to denote the end of the %scope% structure.
Examples
The following example sets the scope to the document named buyerInfo.
.
.
.
%scope buyerInfo%
<p>Shipped To:<br>
%value companyName%<br>
%value streetAddr1%<br>
%value streetAddr2%<br>
%value city%, %value state% %value postalCode%
%end%
.
.
.
The following example sets the scope to document buyerInfo and then uses the param option to add variables called buyerClass and shipPoint to that document.
.
.
.
%scope buyerInfo param(buyerClass=’Gold’) param(shipPoint=’BWI Hub’)%
<p>Shipped To:<br>
%value companyName%<br>
%value streetAddr1%<br>
%value streetAddr2%<br>
%value city%, %value state% %value postalCode%</p>
<hr>
<p>Point of Departure: %value shipPoint%<br>
Customer Class: %value buyerClass%</p>
%end%
.
.
.
The following example sets the scope to document buyerInfo and then uses the rparam option to add a String variable named req to that scope before invoking a service.
.
.
.
<p>Open Orders:</p>
%scope buyerInfo rparam(req=openorders)%
%invoke orders:getOrderInfo%<br>
%loop orders%
Date: %value oDate%
Number: <A HREF="showOrder.dsp&oNum=%value oNum%">%value oNum%</A>
<br>
%endloop%
<p>Click Order Number to View Details:</p>
%endscope%
.
.
.