As a developer using IBM Host Access Transformation Services (HATS), you can add macros into the HATS application which helps performing repetitive tasks faster and more efficiently. Macros are also the basis for creating RESTful services in HATS. A macro is an XML script that defines a set of screens. Each screen includes a description of the screen, the actions to perform on that screen, and the screen or screens that can be presented after the actions are performed. Macros can be used to perform the following functions:
Advanced macros – Use variables and arithmetic expression in macro When a macro is recorded using the host terminal, it is stored in the basic macro format. If a macro is edited and support for variables and arithmetic expressions is added, HATS automatically switches the macro to the advanced macro format. The sections below demonstrate the following steps to showcase the use of Advanced Macro
Convert Basic Macro format to Advanced Macro format A. To use the basic HATS Macro Editor, right-click the macro name and select Open With > Macro Editor. B. On the Overview page of the basic HATS Macro Editor, click “Advanced Editor”. C. Select the “Use Variables and Arithmetic Expressions in Macro” check box on the Macro tab This enables all the advanced features for your macro. It automatically converts, all input fields where conversion is required, all the strings in your macro and all occurrences of the two special characters’ single quote (') and backslash (\) from their basic representations to their advanced representations. Creating variables A. For creating a new variable click on “Variables” tab and choose “<new variable>” option from the Variables list box B. Type a variable name in the Name input field. You must enclose the variable name in dollar signs ($). Variable Name Rules:
C. Click on ‘Save and Exit’ After creating variables, below code fragment gets added in the source automatically (Click on Source Tab of macro to view this) Setting up Arithmetic Expression Some characters that are ordinary characters in the basic macro format are used as operators in the advanced macro format. e.g. the plus sign (+) and the greater than sign (>). In basic macro value="'90' + '[enter]'" is considered as normal string whereas in Advanced macro it is considered to be 90 then enter, which implies that the plus sign (+) works as String concatenation operator. When using the basic macro format, the following character or character sequences are not treated as operators: +, -, *, /, %, ==, !=, >, =, <=, &&, ||, !. Whereas in the advanced macro format, the following character or character sequences are treated as operators:
Conditional Expressions (<if> element and <else> element) Conditional expressions are useful for developers when they need to add a condition in a recorded macro. In the example below, we use the extract action to capture data from the host terminal and store the data into a macro variable. From the host terminal captured data is 90, which is then stored in a macro variable Mac_Var1 We use this Mac_Var1 for conditional expression as in the below code snippet. As you can see in the above example, the conditional expression uses logical operators and arithmetic expression
You can find more information about HATS Advanced Macros in the online documentation for HATS. Ashish Rajpoot
Member Technical Staff rajpoota@hcl.com
0 Comments
Leave a Reply. |