Purpose
With file(), you can assign an alias to SAPWR (SAP Web Repository) files.
The file() command is used to assign short names - also called aliases - to scripts housed in an SAP Web Repository (SAPWR). This command is very useful since SAPWR sets a limit of thirty characters on a file name.
Syntax
file("long_filename",{“alias”:"short_filename"});
Note: The file() is placed in the esession.sjs file if such a file is present. If the scripts are housed in SAPWR, the rfcconnect command must include a 'Client=' statement in the guixt.sjs file.
Options
The file() command takes the following options:
aliasThis is used to specify the short filename that will be used instead of the original file name. The syntax is as follows:
{"alias":"shortFilename"}
Assigning an Alias
The file command can be used to assign aliases to files.
In the following example, we will assign an alias to a file in SAPWR with a very long file name.
- Create a file in SAPWR with the following filename:an_extremely_and_over_the_top_lengthy_script_filename.sjs
- Open the 'esession.sjs' file and enter the following code. Create the file if it does not already exist.
file("an_extremely_lengthy_script_filename.sjs",{“alias”:"longFile.sjs"});
- Save the file.
You should now be able to access the file using the alias instead of the actual file name.
Using Regular Expressions
The file() command can be used with regular expressions.
In the following example, we will use a regular expression.
- Create a file in SAPWR with the following filename, ZGUIXT.E0100.sjs
- Open the 'esession.sjs' file and enter the following code. Create the file if it does not already exist.
file("Z.GUIXT.SAPLSMTR_NAVIGATION.E0100",{"alias":"sessmgr"});
- Save the file.
You can now access the file using the alias 'sessmgr' instead of the actual file name.
Using a String
The file() command can be used with either strings or with regular expressions. In the following examples, we will demonstrate the various usages.
In the following example, we will use a string.
- Create a file in SAPWR with the following filename, ZGUIXT.E0100.sjs
- Open the 'esession.sjs' file and enter the following code. Create the file if it does not already exist.
file("Z.GUIXT.SAPLSMTR_NAVIGATION.E0100.sjs",{"alias":"sessmgr"});
- Save the file.
You can now access the file using the alias 'sessmgr' instead of the actual file name.
Tips and Tricks
- This file command should be placed in one of the session scripts, such as ESession.sjs, DSession.sjs, etc, that will change the file name for the specific session.