Using macro variables

A macro variable is a string enclosed in a set of percent signs (e.g., %inbox%), used to indicate substitution of other data. You can use macros for many reasons, including, for example, defining a unique file destination, indirectly referencing directory locations (for inboxes, outboxes, etc.), or passing information to an Execute On Successful Send command. 

Types of macro variables

Macro variables are classified in one of three ways:

The following table outlines the macro variables (both reserved and custom) and the various contexts in which they can be used.

Table 1. Macro Variables and their Contexts
Macro Variable Context
Source File Destination Files SYSTEM Command Default Host Directory Default Local User Active Directory Default Root Directory Windows/Unix Folders Custom Variable Execute-On Pre/Post Command LCOPY Archive Accessible through API Directories Only Banner/Welcome Message
%system%       X X                  
%none%       X X                  
%inbox% X X X         X X   X X X  
%outbox% X X X         X X   X X X  
%file%                 X     X    
%sourcefile%   X             X X   X    
%srcfile%   X             X X   X    
%sourcefilebase%   X             X X   X    
%srcfilebase%   X             X X   X    
%sourcefileext%   X             X X   X    
%srcfileext%   X             X X   X    
%destfile%                 X X   X    
%destfilebase%                 X X   X    
%destfileext%                 X X   X    
%date% X X X X X       X X   X   X
%time% X X X           X X   X   X
%index% X X X           X X   X    
%host% X X X X X       X X X X    
%mailbox% X X X X X       X X X X    
%status%                 X     X    
%crc%                 X     X    
%filesize%                 X     X    
%transferid%   X             X     X    
%filesin%     X                 X    
%filesout%     X                 X    
%ebms.timestamp.date%   X                        
%ebms.timestamp.time%   X                        
%ebms.action%   X                        
%ebms.service%   X                        
%ebms.cpaid%   X                        
%as2.to%   X                        
%as2.from%   X                        
%as2.subject%   X                        
%oftp.sfiddsn%   X                        
%oftp.sfidorig%   X                        
%oftp.sfiddest%   X                        
%oftp.sfiddesc%   X                        
%as3.to%     X                      
%as3.from%     X                      
%ebics.ordertype%   X                        
%command%                 X     X    
custom directory variable X X X X X X X   X   X X X  
system.properties variable X X X X X X X   X   X X X  
Note: Cells with a bolded, italicized, underscored X indicate the value might not be known. If the value is not known, the macro name (for example, %sourcefile%) is simply passed through.  Further, if a macro is used that is not supported within a particular context (for example, referencing %crc% within a Destination File context), it will simply be passed through as well.

Using system.properties Variables

It is possible to add general variables to the conf/system.properties file and use them within the contexts outlined in the table. To add a general variable to conf/system.properties, the syntax is: varName=replacementText. For example, if conf/system.properties has the following: myvar=hello, the usage would be %myvar% in the desired location.

Note:
  1. Unlike other macro variables that are case-insensitive, system.properties macros are case-sensitive.
  2. After adding a macro to conf/system.properties, the service must be cycled before the macro can be processed.

Context Definitions

Macro variables are valid in certain contexts. The following describes the various contexts in which macro variables are valid. Not all macro variables are valid in all contexts.

Source File
Applies to the “source” values of LCOPY, LDELETE, LREPLACE, PUT, and CHECK commands (Cleo Harmony and Cleo VLTrader applications only).  Macros are supported for the “source” values of the GET commands for FTP, SFTP and HTTP(s) protocols only.  Macros are not supported for the “source” values of GET commands for other protocols or the DIR command.
Destination File
Applies to the “destination” values of LCOPY, PUT, GET, and CHECK commands (Cleo Harmony and Cleo VLTrader applications only).  It also applies to default file names, as specified under the host AS2 tab (see AS2 Host: AS2 Tab), the host AS4 tab (see AS4 Host: AS4 Tab), the host ebXML tab (see ebXML Host: ebXML Tab), the host EBICS tab (see EBICS Host: EBICS Tab), and the Local HTTP Users HTTP tab (see Configuring access for HTTP host users). It also applies to the file destination, as specified under the host OFTP tab (see OFTP Host: OFTP Tab).  The Destination File context also applies to macros that can be included within HTTP parameter/header values, as defined under the HTTP tabs for HTTP-based protocols (for example, AS2, ebXML). Also, this context applies to the FileFormat parameter on EBICS GET command. See EBICS Command Reference. The Destination File context macro variables may also be used within the Subject header of the SMTP tab.
SYSTEM Command
Applies to the SYSTEM command that can be run within the host actions (see Using operating system commands in actions).
Default Directories
Applies to the default inbox/outbox/sentbox/receivedbox, as specified under the host General tabs (for an example, see FTP Configuration).  The %host% macro variable is supported, but not %mailbox%.
In addition, the %date% macro is supported, but the %time% macro is not. Be careful using the %date% macro in the default outbox because files in the date-stamped outbox subdirectory will not be sent if the send action occurs after midnight. Likewise, archiving entries in sentbox and receivedbox date-stamped directories will only occur for the current date.
Default Local User Archive Directories
Applies to the sentbox and receivedbox archive directories as specified under the local user host General tabs (for an example, refer to Configuring local FTP users).  Both the %host% and %mailbox% macro variables are supported in this context.
In addition, the %date% macro is supported, but the %time% macro is not. Be advised that archiving entries in sentbox archive and receivedbox archive date-stamped directories will only occur for the current date.
Default Root Directory
Applies to the default root directory, as specified under the local user FTP tab, HTTP tab, and SSH FTP tab (for an example, refer to Configuring local FTP users). It also applies to the user home directory, as specified under the local user mailbox FTP tab, HTTP tab, and SSH FTP tab (for an example, see FTP Mailbox: FTP Tab).
Windows/Unix Folders
Applies to the UNC paths specified when you set up Windows/Unix folder access. See CIFS directories. Macros used in this context should always be UNC paths starting with two backslashes (\\). No other macros are supported within macros used in this context.
Custom Variables
Applies to the values that can be specified under custom directory variables on the General tab under Configure System Options. See Other system options for more information.
Execute-On
Applies to the system commands that can be specified within the Execute On Successful Send/Receive/Copy/Check properties and the Execute On Fail property (system, host, or action level). See Advanced system options for information about the Advanced tab under Configure System Options for definitions of these properties. With regard to Execute On Fail command, when a command is executed as a result of a failed transfer (either on the client or the server), then all applicable macros are supported. When a command is executed as a result of a general system failure, then only %date%, %time% and %status% are supported. 
Post/Pre Command
Applies to the FTP properties Post Get Command, Post Put Command, Pre Get Command, and Pre Put Command, as specified under the FTP Host: Advanced Tab.  This context also applies to the Post Put Command and Pre Put Command properties as defined in the SSH FTP Host: Advanced Tab.
LCOPY Archive
Applies to the archive directory that can be specified with the LCOPY Archive property (system, host, or action level). See Advanced system options for more information.
Accessible through API
Applies to macros that are available through IactionController interface of the API (if the API is licensed).  Refer to the API javadocs for a description of this interface and the method that can be used to obtain a given macro value.
Directories Only
Applies in several places where only the custom directories macros or %inbox%/%outbox% are appropriate.
Banner/Welcome Message
Applies to the banner and/or welcome messages for the HTTP, FTP, SMTP, and SSH FTP servers. See Configuring Local Listener Responses.

Rules Regarding Macro Variable Use

Below are some general rules for macro variable use.  

  1. Macros are identified by %c%, where c is one-to-many characters.
  2. Macro variables are case insensitive. You can enter them in lowercase or uppercase.
  3. You cannot place a % within a macro variable.
  4. When a string contains macros to be resolved and a % that is not tied to a macro, you must escape the non-macro % with %%. After all macro substitution takes place, the software strips the extra %, yielding the intended character sequence. For example, LCOPY test.edi %%%date%_%index% is resolved to %20090714_01.
  5. The * and ? characters are not allowed within a macro name. Use other special characters with caution.
  6. When using the %date% and %time% macros, it is your responsibility to ensure the formats for the date and time do not violate any file system naming conventions, for example, if the macros are being used to build a filename or directory.
  7. Macros are not allowed within a source filename that contains a *, ?, or regular expression. For example, in LCOPY inbox/%mailbox%*, %mailbox% is not resolved. However, in LCOPY inbox/%mailbox%/*, %mailbox% is resolved because it is referenced in the source directory path and not the source filename.
  8. You can use macros multiple times within the same command. For %date%, %time% and %index%, the same substitution value is used in all references within the same command. However, when you use either of these macros within the destination path of an LCOPY, and multiple files are being copied in one command, the following special rules are enforced:
    1. If these macros are used anywhere within the directory path, they are only resolved once within command.
    2. If these macors are used within the file token, they are resolved for each filename.
  9. Macros you use within a system command, either within the SYSTEM Command context or within the Execute-On context, can be used as part of the actual command or as parameters to a batch file.
  10. If the absolute path of the any of the files referenced in the macros contain embedded spaces (for example., %file% resolves to Program Files\LexiCom\inbox\testHost\test.edi) it might be necessary to add double quotes to the macro specification(s) in the command in order for the command to be properly processed by the operating system. For example, copy “%file%” “%file%.bad”.
  11. Special rules apply to using directory macro variables for example, %inbox%, %outbox%, and custom directory variables.
    • If you use these macros in a source file, destination file, custom directory variable definition, or an LCOPY Archive context, and the path is a non-URI path, they are replaced only at the beginning of the string. For all other contexts (for example, URI source/destination paths, SYSTEM commands), they are replaced anywhere in the string.
    • Although allowed, you should not use directory macros should within a remote destination file context, as they reference local directory paths and are therefore nonsensical in this context.
    • When preceding a path with a directory macro, you should place a file separator character (for example, ‘/’or ‘\’ between the macro and the subsequent path (for example, %inbox%/test.edi).
    • When using directory macros, care should be used so as not to create circular references (for example, host outbox references %CustomVar% and %CustomVar% references %outbox%).
  12. All directory macro variables reference their absolute paths.

Reserved Macro Variables

Below is the table of all reserved macro variables.  

Macro Description
Framework Macros
%system% References the system-level inbox/outbox/sentbox/receivedbox.
%none% For sentbox/receivedbox fields where this option is available to select, this indicates that there should be no associated sent/receivedbox (rather than defaulting to the system values in the absence of a selection)
%inbox% References the absolute path of the configured host or local user inbox.
%outbox% References the absolute path of the configured host or local user outbox.
%file% References the local file (including the absolute path) involved in the current operation.  For PUT and certain CHECK commands, %file% is the source file.  For GET, LCOPY, and certain CHECK commands %file% is the destination file. See CHECK command.
Note: The CHECK command is only available in Cleo Harmony and Cleo VLTrader applications.
%sourcefile%

%srcfile%

References the source file name involved in the current operation.  If the source file is local, and it is referenced in the Execute-On context, then the absolute path is included.
%sourcefilebase%

%srcfilebase%

References the source file name base (everything up to, but not including, the last '.'.
%sourcefileext%

%srcfileext%

References the source file name extension (everything from, and including, the last '.'.  If no extension is contained in the source file, blank is returned.
%destfile% References the destination file name involved in the current operation.  If the destination file is local, and it is referenced in the Execute-On context, then the absolute path is included.
%destfilebase% References the destination file name base (everything up to, but not including, the last '.'.
%destfileext% References the destination file name extension (everything from, and including, the last '.'.  If no extension is contained in the destination file, blank is returned.
%date% Specifies the current date in the format defined in the Macro Date Format setting (system, host, or action level).  See Advanced system options for more information about this property.
%date[+/-#y][+/-#m][+/-#d][,MacroDateFormat=...]% Specifies a variant of the date as a value in either the past or the future.  The '#' character specifies one or more digit values and the order of the +/- fields (y=year, m=month, d=day) dictates the order of the operation, however calendar rules still apply (for example, if the operation causes the day to wrap to the next month then the month value is automatically incremented).  The MacroDateFormat parameter variable is case-insensitive. If it is specified with the +/- field(s), it must be specified as the last parameter.  If it is not specified, the format defined in the Macro Date Format setting (system, host, or action level) is used.  See Advanced system options for more information about this property.
%time% Specifies the current time in the format defined in the Macro Time Format setting (system, host, or action level).  See Advanced system options for more information about this property.
%time[+/-#h][+/-#m][+/-#s][,MacroTimeFormat=...]% Specifies a variant of the time as a value in either the past or the future.  The # character specifies one or more digit values and the order of the +/- fields (h=hour, m=minute, s=second) dictates the order of the operation, however calendar rules still apply (for example, if the operation causes the minute to wrap to the next hour then the hour value is automatically incremented).  The MacroTimeFormat parameter variable is case-insensitive. If it is specified with the +/- field(s), it must be specified as the last parameter.  If it is not specified, the format defined in the Macro Time Format setting (system, host, or action level) is used.  See Advanced system options for more information about this property.
%index% Specifies the usage of a daily host index value; often used to help guarantee file uniqueness.  Each host's index is reset to 1 at the beginning of each day.  It is incremented by one every time %index% is referenced.

The minimum number of digits in the index string is determined by the Minimum Number Of Macro Index Digits system option. See Advanced system options for more information.

%host% The alias of the host involved in the current operation.
%mailbox% The alias of the mailbox involved in the current operation.
%status% The status of the current operation.  Returned status values are either "Success" or "Warning" (both denote a successful transaction) and "Error" or "Exception" (both denote a failed transaction). 
%crc% The value of the computed CRC-32 associated with a transferred file.  The CRC is computed only when Compute CRC on transfers is active. See Logs for information. This feature is available only for Cleo Harmony and Cleo VLTrader applications.
%filesize% The size of a transferred file in measured in bytes.
%transferid% The value of the unique ID assigned to a transferred file.  This feature is available only for Cleo Harmony and Cleo VLTrader applications.
%filesin% The number of files received through within an action.
%filesout% The number of files sent through within an action.
%command% The full command syntax (only available for the Execute-On context of CHECK commands).
ebMS Macros
%ebms.timestamp.date% The date portion of the SOAP header's <eb:Timestamp> value.  The format of the date is determined by the Macro Date Format setting (system-, host-, or action-level).  See Advanced system options for information about Advanced tab under Configure System Options for a definition of this property.  This macro will only be resolved when used in the default file name.
%ebms.timestamp.time% The time portion of the SOAP header's <eb:Timestamp> value.  The format of the time is determined by the 'Macro Time Format' setting (system, host, or action level).  See Advanced system options for information about Advanced tab under Configure System Options for a definition of this property.  This macro will only be resolved when used in the default file name.
%ebms.action%

%ebms.service%

%ebms.cpaid%

%ebms.action% = the SOAP header's <eb:Action> value. 

%ebms.service% = the SOAP header's <eb:Service> value. 

%ebms.cpaid% = the SOAP header's <eb:CPAId> value. 

These macros will only be resolved when used in the default file name.

AS2 Macros
%as2.to% The current AS2-To value provided in the received message header. This macro will only be resolved when used in the default file name.
%as2.from% The current AS2-From value provided in the received message header. This macro will only be resolved when used in the default file name.
%as2.subject% The current Subject value provided in the received message header. This macro will only be resolved when used in the default file name.
AS3 Macros
%as3.to% The AS3-To name of a client. This macro will only be resolved when used in the SITE command within an action to verify that the AS3 names are properly configured on the VersaLex AS3 server.
%as3.from% The AS3-From name of a client. This macro will only be resolved when used in the SITE command within an action to verify that the AS3 names are properly configured on the VersaLex server.
EBICS Macros
%ebics.ordertype% For EBICS, this macro will resolve to the order type of the EBICS transaction.

Formatting %date% and %time% Macros

The default %date% setting is yyyyMMdd and the default %time% setting is HHmmssSSS.

To specify a different %date% or %time% format, use a pattern string in the 'Macro Date Format' and 'Macro Time Format' setting (system, host, or action level).  See Advanced system options for information about the Advanced tab under Configure System Options for definitions of these properties.  Formats may also be specified as part of the macro definition, e.g., %date,MacroDateFormat=yyyyMMdd% and %time,MacroTimeFormat=HHmmssSSS%

 In the pattern, all ASCII letters are reserved as pattern letters, which are defined as the following:

Symbol Meaning Example
G era designator AD
y year 2004
M month in year September & 09
d day in month 15
h hour in am/pm (1~12) 12
H hour in day (0~23) 0
m minute in hour 30
s second in minute 24
S millisecond 352
E day in week Wednesday
D day in year 259
F day of week in month 2 (2nd Wed in September)
w week in year 35
W week in month 2
a am/pm marker PM
k hour in day (1~24) 24
K hour in am/pm (0~11) 0
z time zone Central Standard Time
' escape for text delimiter
" single quote '

Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text.  For instance, characters like '.', '#' and '@' will appear in the resulting date or time text even if they are not embraced within single quotes.

Note: A pattern containing any invalid pattern letter will result in a thrown exception during formatting or parsing.

Examples Using Pattern Strings:

%date% Format Pattern Result
MM-dd-yyyy 09-15-2004
EEE_MMM_d_yy Wed_September_15_04

%time% Format Pattern Result
h_mm_a 12_08_PM
K_mma-z 0_00PM-CST

Macro Variable Usage Examples

Destination File Examples:

Action Command Destination File Result
PUT test.edi %date%_%time%.edi 20090714_131524352.edi
PUT test.edi %date-1d,MacroDateFormat=MMdd%.edi 0713.edi
GET test.edi %srcfile%%date%-%time%-%index% test.edi20090714-131524352-1
LCOPY test.edi %date%_%time%.%srcfileext% 20090714_131524352.edi
LCOPY test.edi %%%date%_%time% %20090714_131524352

Source File Examples:

Action Command Source File Result
PUT %inbox%\%date%\test.edi inbox\20090714\test.edi
PUT %inbox%\%date,MacroDateFormat=yyyy% inbox\2009\test.edi
PUT %outbox%\%mailbox%\* outbox\myMailbox\*

Execute-On Examples:

After successful execution of 'LCOPY test.edi test2.edi':

Execute On Successful Copy System Command System Command Result
cmd.exe /c copy "%destfile%" "c:\temp\%destfilebase%.copy" cmd.exe /c copy "c:\LexiCom\inbox\test2.edi" "c:\temp\test2.copy"
cmd.exe /c ExecuteOnCopy.bat "%destfile%" "c:\temp\%destfilebase%.copy" cmd.exe /c ExecuteOnCopy.bat "c:\LexiCom\inbox\test2.edi" "c:\temp\test2.copy"

Default Host Directory Examples:

Assume the system-level inbox is 'myInbox\' and the custom directory variable, '%custom1%', is set to '\\filsvr01\serverInbox\'.

Host Default Directory (Inbox) Setting Resolved Location
%custom1% \\filsvr01\serverInbox\
%custom1%\inbox1 \\filsvr01\serverInbox\inbox1
%system% myInbox\
%system%\inbox1 myInbox\inbox1