CA TPX Session Management for z/OS

Tuesday Tip: Add ons to variable substitution in ACL (TPX script language)

  • 1.  Tuesday Tip: Add ons to variable substitution in ACL (TPX script language)

    Posted 08-20-2014 11:18 AM

    In ACL the concatenation character (a period) is used to produce one value that is the combination of two variables or text strings. The following example shows how this variable substitution works:


           SET       B,'X'

           SET       AX,'TPX'

           SET       C,&A.&B


    The period ‘.’ in the last line lets ACL replace &B with its value and concatenates that value to the variable name left of the period. This leads to the statement SET C,&AX as ‘X’ is the value stored in &B. This statement is executed and stores the value of &AX in &C. So finally &C contains the string ‘TPX’.


    Please take care when using variable substitution because it may make ACL-programs hard to read.


    If using variable substitution consider the following:


    1. The concept of variable substitution work only for a pair of variables, it does not work for a chain of variables like

           SET     CHAIN,&A.&B.&C


    2. Take care that the name of the resulting variable is not longer than eight characters; otherwise you will get unwanted output. Look at this example:

           SET       BBBB,CDEF     

           SET       AAAACDEF,RESULT

           SET       D,&AAAA.&BBBB


    &D contains the value of &AAAACDEF. This variable name is created from the concatenation of &AAAA with the value in &BBBB which is ‘CDEF’. The length of this variable is eight which is fine.


    Now let’s look at this example:

           SET       BBBB,CDEFGH     

           SET       AAAACDEF,RESULT

           SET       D,&AAAA.&BBBB


    Here variable &D contains ‘RESULTGH’. After variable substitution the third line reads

           SET       D,&AAAACDEFGH


    As variable names cannot exceed eight characters, the first eight characters are interpreted as variable name and therefore the content of &AAAACDEF is assigned to &D. The remaining string ‘GH’ is suffixed to the content of &AAAACDEF. So &D contains the string ‘RESULT’, followed by the string ‘GH’.


    Conclusion: Use short variables if you need to make use of variable substitution. Use commentary test to document what you are doing to make the code readable for you and your colleagues.