Structure Aliasing


Structure aliasing is a mechanism which allows you to apply an alternate name (or alias) to a repository structure. Aliasing provides a mechanism to be able to generate code with more meaningful names, regardless of legacy names which may be present in your repository or data definitions. For example, your customer master file record layout might be defined by a repository structure named CUSMAS, but you may wish to refer to the structure by an alias of CUSTOMER when generating code.

When you specify an alias for a structure that alias will be used whenever the name of the repository structure would normally be used. For example the <STRUCTURE_NAME> token will be replaced by the name of the alias that you have provided instead of the name of the actual structure being used.

Specifying Structure Aliases

Structure aliases are specified via the -a command-line option. You can specify up to ten aliases after the -a option, based on the number of structures that you have specified after the -s command line option.

For example, if you are processing a single repository structure your command line might look something like this:

codegen -s CUSMAS -a CUSTOMER -t DataClass -r

If you were processing multiple structures, and wanted to apply an alias to each, you might use a command like this:


Accessing the Underlying Structure

Swapping out the structure name for a specified alias is exactly what you want in most cases, but there is one important exception. If you are trying to access the actual underlying repository structure, then using the alias name isn't going to work. For example if you have aliased your CUSMAS structure as CUSTOMER then the following template code:

.include "<STRUCTURE_NAME>" repository, structure="str<StructureName>"

Would produce the following output file code:

.include "CUSTOMER" repository, structure="strCustomer"

Clearly the problem is that there is no CUSTOMER structure in the repository, it's just an alias for CUSMAS, so the resulting code won't compile.

The solution to this problem is provided by the <STRUCTURE_NOALIAS> token which is always replaced by the name of the underlying repository structure, even if a structure alias has been specified. When writing templates you should ALWAYS use this token when you are trying to access an actual repository structure. For example:

.include "<STRUCTURE_NOALIAS>" repository, structure="str<StructureName>"

Would produce something output file code like this:

.include "CUSMAS" repository, structure="strCustomer"




Copyright © 2018  Synergex International, Inc.