Beruflich Dokumente
Kultur Dokumente
below:
1. Aggregate Functions
2. Conversion Functions
3. Cryptographic Functions
4. Custom Functions
5. Database Functions
6. Date Functions
7. Environment Functions
8. Lookup Functions
9. Math Functions
10. Miscellaneous Functions
11. SAP Functions
12. String Functions
13. System Functions
14. Validation Functions
Now lets see in detail what each of the aggregate function does, with the table we created
in HANA as input.
AVG: Calculates the average of given set of values
Syntax: avg( [in] ColumnName )
Example: avg(AMOUNT)
Result: 30
COUNT: Counts the number of values in a table column.
Syntax: count( [in] ColumnName ) As int
Example: Count(ORDER_NUMBER)
Result: 4
COUNT_DISTINCT: Counts the number of distinct non-null values in a table column.
Syntax: count_distinct( [in] ColumnName ) As int
Example: Count_distinct(ORDER_NUMBER)
Result: 3
MAX: Returns the maximum value from a list.
Syntax: max( [in] ColumnName )
Example: MAX(AMOUNT)
Result: 78
MIN: Returns the minimum value from a list.
Syntax: min( [in] ColumnName )
Example: MIN(AMOUNT)
Result: 45
SUM: Calculates the sum of a given set of values.
Syntax: sum( [in] ColumnName )
Example: SUM(AMOUNT)
Result: 23
CONVERSION FUNCTIONS:
CAST: Converts an expression of one data type to another.
Syntax: cast( [in] Expression, [in] DataType As varchar )
Example: CAST(123.45, INT)
Result: 123
EXTRACT_FROM_JSON: Converts the JSON in the given field into NRDM
Syntax: extract_from_json( [in] JSONFieldName As varchar, [in] SchemaName As
varchar, [in] EnableValidation As int ) As int
EXTRACT_FROM_XML: Converts the XML in the given field into NRDM.
Syntax: extract_from_xml( [in] XMLFieldName As varchar, [in] DTDOrSchemaName As
varchar, [in] EnableValidation As int ) As int
INTERVAL_TO_CHAR: Takes an interval and returns a character representation of the
interval.
Syntax: interval_to_char( [in] InputInterval As interval, [in] FormatString As varchar )
As varchar
JULIAN_TO_DATE: Converts a Julian date to a calendar date.
Syntax: julian_to_date( [in] InputJulianDate As int ) As datetime
Example: julian_to_date(15266)
Result: 09.23 00:00:00
LOAD_TO_XML: Converts the data represented by the given nested table into XML.
Syntax: load_to_xml( [in] NestedTableName, [in] DTDOrSchemaName As varchar, [in]
EnableValidation As int, [in] XMLHeader As varchar, [in] ReplaceNullString As varchar,
[in] IsTopLevelElement As int, [in] MaxSize As int ) As varchar
LONG_TO_VARCHAR: Converts a column value of type LONG to a value of type
VARCHAR.
Syntax: long_to_varchar( [in] ColumnName, [in] MaxSize As int, [in] StartPosition As
int ) As varchar
NUM_TO_INTERVAL: Takes a number and returns an INTERVAL.
Syntax: num_to_interval( [in] InputNumber As int, [in] FormatString As varchar ) As
interval
TO_CHAR: Converts date or numeric type to string.
Syntax: to_char( [in] InputDateOrNumber, [in] FormatString As varchar ) As varchar
Example: TO_CHAR(SYSDATE(), MONTH)
Result: SEPTEMBER
TO_DATE: Converts a string to a date under control of a format string.
Syntax: to_date( [in] InputString As varchar, [in] FormatString As varchar ) As
datetime
Example: TO_DATE(MAR191988, MONDDYYYY)
Result: 03.19 00.00.00
TO_DECIMAL: Converts a varchar to decimal.
Syntax: to_decimal( [in] InputDecimalString As varchar, [in] DecimalSeparator As
varchar, [in] ThousandsSeparator As varchar, [in] Scale As int ) As decimal
Example: to_decimal(1,903.1988, ., ,, 3)
Result: 198
TO_DECIMAL_EXT: Converts a varchar to decimal.
Syntax: to_decimal_ext( [in] InputDecimalString As varchar, [in] DecimalSeparator As
varchar, [in] ThousandsSeparator As varchar, [in] Precision As int, [in] Scale As int ) As
decimal
Example: to_decimal_ext(1903.1988, ., ,, 3,4)
Result: 199
VARCHAR_TO_LONG: Converts a column value of type varchar to a value of type long.
Syntax: varchar_to_long( [in] ColumnName As varchar ) As long
Example: varchar_to_long(sap student is dedicated to provide learning materials)
CRYPTOGRAPHIC FUNCTIONS:
DECRYPT_AES: Returns decrypted text using AES generated key and specified
passphrase. The passphrase must be same as the one used to encrypt the data.
Syntax: decrypt_aes( [in] CipherText As varchar, [in] Passphrase As varchar, [in]
AESKeyLength As number ) As varchar
Example: encrypt_aes_ext(9oSufeXtTW2cWLI8pe0NPFMlJ7M ,sap_student,128)
Result: abcd
Things to Remember: AES Key Length should be 128, 192 or 256. We have to use the
same Passphrase and AES key used for encryption.
DECRYPT_AES_EXT: Returns decrypted text using specified passphrase and salt. The
passphrase and salt must be same as the one used to encrypt the data.
Syntax: decrypt_aes_ext( [in] CipherText As varchar, [in] Passphrase As varchar, [in]
Salt As varchar, [in] AESKeyLength As number ) As varchar
Example: encrypt_aes_ext( JnYOeQ ,sap_student,venkat_n,128)
Result: abcd
Things to Remember: AES Key Length should be 128, 192 or 256 and Salt value should
exactly be eight ASCII characters in length. We have to use the same Passphrase, AES key
and salt used for encryption.
ENCRYPT_AES: Returns encrypted text encoded in base64 using AES generated key and
specified passphrase.
Syntax: encrypt_aes( [in] PlainText As varchar, [in] Passphrase As varchar, [in]
AESKeyLength As number ) As varchar
Example: encrypt_aes(abcd,sap_student,128)
Result: 9oSufeXtTW2cWLI8pe0NPFMlJ7M
Things to Remember: AES Key Length should be 128, 192 or 256. This function generates
distinct encrypted values for every row even though the source being the same (we can see
the results in below image).
ENCRYPT_AES_EXT: Returns encrypted text encoded in base64 using AES generated
key and specified passphrase and salt.
Syntax: encrypt_aes_ext( [in] PlainText As varchar, [in] Passphrase As varchar, [in]
Salt As varchar, [in] AESKeyLength As number ) As varchar
Example: encrypt_aes_ext(abcd,sap_student,venkat_n,128)
Result: JnYOeQ
CUSTOM FUNCTIONS:
JDE_DATE: Given a Julian date stored in JD Edwards database, returns the equivalent
value as a Data services data type.
Syntax: JDE_Date( [in] julian As int ) As date
JDE_TIME: Given a number representing in JD Edwards database, a Data services
character value that represents the equivalent military time in HH24:MI:SS format.
Syntax: JDE_Time( [in] jde_time As int ) As varchar(8)
WL_GETKEYVALUE: Returns the value of the specified key in the given URL.
Syntax: WL_GetKeyValue( [in] URL As varchar(100), [in] searchKey As varchar(100) )
As varchar(100)
DATABASE FUNCTIONS:
KEY_GENERATION: Reads the max (generated key) column from the input table, uses
that as the starting value for generating new key values.
Syntax: key_generation( [in] InputTable, [in] KeyColumn As column, [in]
KeyIncrement As int ) As int
Example:key_generation(DS_SAP_HANA_TGT.SAP_STUDENT.DS_AGGR_FUNC,ORDER
_NUMBER,1)
Result: This function generates the new columns by taking maximum value from input
column and increasing it by 1.
SQL: Executes the specified SQl command against the specified datastore.
Syntax: sql( [in] Datastore As datastore, [in] SQLString As varchar ) As varchar
Example: sql(DS_SAP_HANA_TGT,SELECT substr_after(\ab_cd\,\_\) FROM
DUMMY)
Result: cd (entire SQL will be executed in source and result will be transferred to Data
Services).
TOTAL_ROWS: Returns the total number of rows in a database table or a memory table.
Syntax: total_rows( [in] InputTable ) As int
Example: total_rows(DS_SAP_HANA_TGT.SAP_STUDENT.DS_AGGR_FUNC)
Result: 4 (Record count of the table)
DATE FUNCTIONS:
ADD_MONTHS: Adds a given number of months to a date.
Syntax: add_months( [in] OriginalDate As datetime, [in] MonthsToAdd As int ) As
datetime
Example: add_months(2015.01.12,7)
Result: 08.12 00:00:00
CONCAT_DATE_TIME: Given a date value and a time value, concatenates the two
values and returns one datetime value.
Syntax: concat_date_time( [in] InputDate As datetime, [in] InputTime As datetime )
As datetime
Example: concat_date_time(2015-01-01, 01:30:45)
Result: 01.01 00:00:00
DATE_DIFF: Returns the difference between dates.
Syntax: date_diff( [in] FirstDate As datetime, [in] SecondDate As datetime, [in]
FormatString As varchar ) As int
Example: date_diff( 2015.01.20,2015.01.1,D)
Result: 19
DATE_PART: Extracts a portion of a given date as an integer.
Syntax: date_part( [in] InputDate As datetime, [in] FormatString As varchar ) As int
Example: date_part(2015.01.01,YYYY)
Result: 2015
DAY_IN_MONTH: Returns the day number relative of the month for the input date.
Syntax: day_in_month( [in] InputDate As datetime ) As int
Example: day_in_month(2015.02.10)
Result: 10
DAY_IN_WEEK: Returns the day number relative of the week for the input date.
Syntax: day_in_week( [in] InputDate As datetime ) As int
Example: day_in_week(2015.02.10)
Result: 3
DAY_IN_YEAR: Returns the day number relative of the year for the input date.
Syntax: day_in_year( [in] InputDate As datetime ) As int
Example: day_in_year(2015.02.10)
Result: 41
FISCAL_DAY: Returns an integer representing the number of fiscal days since the
reference date.
Syntax: fiscal_day( [in] ReferenceDate As varchar, [in] InputDate As datetime ) As int
Example: fiscal_day(2015.04.01, 2015.05.01)
Result: 30
ISWEEKEND: Returns 1 if the input date is a weekend, 0 otherwise.
Syntax: isweekend( [in] InputDate As datetime ) As int
Example: isweekend (2015-01-01)
Result: 0
JULIAN: Returns the integer Julian date for the input date.
Syntax: julian( [in] InputDate As datetime ) As int
Example: julian(09.23)
Result: 15266
LAST_DATE: Returns the last date of the month for a given date.
Syntax: last_date( [in] InputDate As datetime ) As datetime
Example: last_date (09.23)
Result: 09.30 00:00:00
MONTH: Returns the month number of the input date.
Syntax: month( [in] InputDate As datetime ) As int
Example: month (09.23)
Result: 9
QUARTER: Returns the number of the quarter for the input date.
Syntax: quarter( [in] InputDate As datetime ) As int
Example: quarter (09.23)
Result: 3
SYSDATE: Returns the current date in the system.
Syntax: sysdate( ) As datetime
Example: sysdate( )
Result: 09.23 06:24:30
SYSTIME: Returns the current time in the system.
Syntax: systime( ) As datetime
Example: systime( )
Result: 01.01 06:24:30
WEEK_IN_MONTH: Returns the week number relative to the month for the input date.
Syntax: week_in_month( [in] InputDate As datetime ) As int
Example: week_in_month (09.23)
Result: 4
WEEK_IN_YEAR: Returns the week number relative to the year for the input date.
Syntax: week_in_year( [in] InputDate As datetime, [in] WeekType As varchar ) As int
Example: week_in_year (09.23)
Result: 39
YEAR: Returns the year number for the input date.
Syntax: year( [in] InputDate As datetime ) As int
Example: year (09.23)
Result: 2015
ENVIRONMENT FUNCTIONS:
GET_ENV: Returns a varchar value for an environment variable set through the
set_env() call. If the environment variable is not set, returns NULL.
Syntax: get_env( [in] VariableName As varchar ) As varchar
Example: get_env (TEST)
Result: C:\TEST
GET_ERROR_FILENAME: Returns the full path and file name for the error log.
Syntax: get_error_filename( ) As varchar
Example: get_error_filename( )
Result: Returns the path where its stored
GET_MONITOR_FILENAME: Returns the full path and file name for the monitor log.
Syntax: get_monitor_filename( ) As varchar
Example: get_monitor_filename( )
Result: Returns the path where its stored
GET_TRACE_FILENAME: Returns the full path and file name for the trace log.
Syntax: get_trace_filename( ) As varchar
Example: get_trace_filename( )
Result: Returns the path where its stored
IS_SET_ENV: Returns 1 if the environment variable is set, otherwise returns 0.
Syntax: is_set_env( [in] VariableName As varchar ) As int
Example: is_set_env(TEST)
Result: 1
SET_ENV: Sets a value for an environmental variable.
Syntax: set_env( [in] VariableName As varchar, [in] VariableValue As varchar ) As int
Example: set_env(TEST,C:\TEST)
Result: N/A
LOOKUP FUNCTIONS:
LOOKUP: Translates column values using a lookup table.
Syntax: lookup( [in] LookupTable, [in] ResultColumn, [in] DefaultValue, [in]
CacheSpec As varchar, [in] CompareColumn, [in] Expression )
LOOKUP_EXT: Translates column values using a lookup table, file or memory table.
Syntax: lookup_ext( [in] [LookupTable,CacheSpec,ReturnPolicy], [in]
[ReturnColumnList], [in] [DefaultValueList], [in] [ConditionList], [in]
[OrderbyColumnList], [in] [OutputVariableList], [in] [SqlOverride] )
LOOKUP_SEQ: Translates column values using a lookup table, using a column (For
Example, effective date) that indicates the logical sequence of the rows.
Syntax: lookup_seq( [in] LookupTable, [in] ResultColumn, [in] DefaultValue, [in]
SequenceColumn, [in] SequenceExpression, [in] CompareColumn, [in] Expression )
MATH FUNCTIONS:
ABS: Returns the absolute value of the input number.
Syntax: abs( [in] InputNumber As number ) As number
Example: abs(-1)
Result: 1
CEIL: Returns the smallest integer value greater than or equal to the input number.
Syntax: ceil( [in] InputNumber As number ) As number
Example: ceil(2.5)
Result: 3
FLOOR: Returns the largest integer value less than or equal to the input number.
Syntax: floor( [in] InputNumber As number ) As number
Example: floor(2.5)
Result: 2
IN: Returns the natural logarithm of the given numeric expression
Syntax: ln( [in] InputNumber As number ) As double
Example: ln(10)
Result: 302585
LOG: Returns the base-10 logarithm of the given numeric expression
Syntax: log( [in] InputNumber As number ) As double
Example: log(10)
Result: 1
MOD: Returns the remainder when one number is divider by another.
Syntax: mod( [in] InputNumber1 As number, [in] InputNumber2 As number ) As real
Example: mod(13,8)
Result: 5
POWER: Returns the value of the given expression to the specified power.
Syntax: power( [in] BaseNumber As number, [in] ExponentNumber As number ) As
double
Example: power(5,6)
Result: 000000
RAND: Generates a random number between 0 and 1.
Syntax: rand( ) As real
Example: rand()
Result: 435089
RAND_EXT: Generates a random number between 0 and 1 using linear congruential
algorithm.
Syntax: rand_ext( [in] InitialSeed As int ) As real
Example: rand_ext(3)
Result: 000368
ROUND: Returns the input number rounded to the specified number of decimal places to
the right of the decimal point. The number of decimal places defaults to 0. If the number
of decimal places is negative, digits left of the decimal point are rounded.
Syntax: round( [in] InputNumber As number, [in] NumberOfDecimalPlaces As int ) As
number
Example: round(1.5555, 4)
Result: 5556
SQRT: Returns the square root of the input number.
Syntax: sqrt( [in] InputNumber As number ) As double
Example: sqrt(6)
Result: 449489
TRUNC: Returns the input number truncated to the specified number of decimal places to
the right of the decimal point. The number of decimal places defaults to 0. If the number
of decimal places is negative, digits left of the decimal point are truncated.
Syntax: trunc( [in] InputNumber As number, [in] NumberOfDecimalPlaces As int ) As
number
Example: trunc(1.23456, 2)
Result: 230
MISCELLANEOUS FUNCTIONS:
BASE64_DECODE: Returns the source data after decoding the base64- encoded input.
Syntax: base64_decode( [in] Base64encodedInput As varchar, [in] Codepage As
varchar ) As varchar
Example: base64_decode(YWJjZA==,utf-8)
Result: abcd
BASE64_ENCODE: Returns base64 encoded stream of input data.
Syntax: base64_encode( [in] InputData As varchar, [in] Codepage As varchar ) As
varchar
Example: base64_encode(abcd,utf-8)
Result: YWJjZA==
CURRENT_ CONFIGURATION: Retrieves the name of the current configuration of a
specified datastore.
Syntax: current_configuration( [in] DatastoreName As varchar ) As varchar
Example: current_configuration(DS_SAP_HANA_TGT)
Result: Configuration1
CURRENT_SYSTEM_CONFIGURATION: Returns the name of the current system
configuration.
Syntax: current_system_configuration( ) As varchar
Example: current_system_configuration( )
Result: SYSTEM_CONFIG_DEV
DATAFLOW_NAME: Returns the data flow name in which this call exists. If the call is not
in a data flow, returns NULL.
Syntax: dataflow_name( ) As varchar
Example: dataflow_name()
Result: DF_MISC_FUNCTIONS
DATASTORE_FIELD_VALUE: Retrieves the value of a specified datastore.
Syntax: datastore_field_value( [in] DatastoreName As varchar, [in] FieldName As
varchar ) As varchar
Example: datastore_field_value( DS_SAP_HANA_TGT,user)
Result: VENKATESH
DB_DATABASE_NAME: Retrieves the Database name of a specified datastore.
Note: This function returns an empty string for datastore configurations without MS SQL
Server or SAP ASE as the Database Type.
Syntax: db_database_name( [in] DatastoreName As varchar ) As varchar
Example: db_database_name(DS_SAP_HANA_TGT)
Result: TEST_DB
DB_OWNER: Retrieves the real owner name that corresponds to a specified design name
in a specified datastore.
Syntax: db_owner( [in] DatastoreName As varchar, [in] DesignName As varchar ) As
varchar
Example: db_owner(DS_SAP_HANA_TGT,VENKATESH)
Result: SAP_STUDENT
DB_TYPE: Retrieves the Database type of a specified datastore.
Syntax: db_type( [in] DatastoreName As varchar ) As varchar
Example: db_type(DS_SAP_HANA_TGT)
Result: HANA
DB_VERSION: Retrieves the Database version of a specified datastore.
Syntax: db_version( [in] DatastoreName As varchar ) As varchar
Example: db_version(DS_SAP_HANA_TGT)
Result:x
DECODE: Computes multiple conditions and returns the expression with TRUE condition.
Otherwise, returns the default expression.
Syntax: decode( [in] ConditionalExpression, [in] CaseExpression, [in]
DefaultExpression )
Example: decode(length(abcd)=4,abcd,xyz)
Result: abcd
FILE_EXISTS: Checks to see if a given file exists.
Syntax: file_exists( [in] FileName As varchar ) As int
Example: file_exists(c:/test.msg)
Result: Returns 1 if a file or directory is present on the disk (even if 0 bytes long), 0
otherwise.
GEN_ROW_NUM: Returns the generated row number for the current instance.
Syntax: gen_row_num( ) As int
Example: gen_row_num( )
Result:
GEN_ROW_NUM_BY_GROUP: Generates a number of each row in a group beginning
with 1 and incremented by 1.
Syntax: gen_row_num_by_group( [in] ExpressionList ) As int
Example: gen_row_num_by_group( DS_MISC_FUNC.ORDER_NUMBER)
Result:
GEN_UUID: Returns UUID.
Syntax: gen_uuid( ) As varchar
Example: gen_uuid( )
Result: 68bdc9bc66cf11e59968137c73544531 Unique ID for each row
GET_DOMAIN_DESCRIPTION: Returns the domain description for the input value. If no
description exists, returns NULL.
Syntax: get_domain_description( [in] DomainName As varchar, [in] DomainValue ) As
varchar
Example:get_domain_description(DS_SAP_HANA_TGT.SAP_STUDENT.TEST_DOMAIN,
TEXT)
Result: TEXT DESCRIPTION
GET_FILE_ATTRIBUTE: Returns a specified file attribute.
Syntax: get_file_attribute( [in] FileName As varchar, [in] FileAttribute As varchar ) As
varchar
Example: get_file_ attibute(c:\database \TEST, date_created)
Result: 2015: 09:25:10:27:43
GREATEST: Returns the greatest value in a list of at least one or more expressions.
Syntax: greatest( [in] ExpressionList )
Example: greatest (p,s,t)
Result: t
HOST_NAME: Returns the name of the computer on which the job is executing.
Syntax: host_name( ) As varchar
Example: host_name( )
Result: TEST_HOST
IFTHENELSE: Computes the expression A. If A evaluates to TRUE, returns B. Otherwise
returns C.
Syntax: ifthenelse( [in] ConditionalExpression, [in] ThenExpression, [in]
ElseExpression )
Example: ifthenelse( DS_MISC_FUNC.AMOUNT>200 , discount applied, discount
cannot be applied)
Result: result varies as per row value
IS_GROUP_CHANGED: Returns 1 if group is changed, 0 otherwise.
SAP FUNCTIONS:
BEGIN_TREX_TRANSACTION: Begins a transaction in BWA server and obtains
transaction id.
Syntax: begin_trex_transaction( [in] Datastore As datastore, [in] CubeName As
varchar ) As varchar
COMMIT_TREX_TRANSACTION: Commits the transaction with transaction id obtained
via begin_trex_transaction() function in BWA server.
Syntax: commit_trex_transaction( [in] Datastore As datastore, [in] CubeName As
varchar, [in] TransactionId As varchar ) As int
CREATE_TREX_CUBE: Creates the cube using the XML specified in BWA server.
Syntax: create_trex_cube( [in] Datastore As datastore, [in] CubeXML As varchar ) As
int
DELETE_TREX_CUBE: Deletes the cube in BWA server.
Syntax: delete_trex_cube( [in] Datastore As datastore, [in] CubeName As varchar ) As
int
ROLLBACK_TREX_TRANSACTION: Rolls back the transaction with transaction id
obtained via begin_trex_transaction() function in BWA server.
Syntax: rollback_trex_transaction( [in] Datastore As datastore, [in] CubeName As
varchar, [in] TransactionId As varchar ) As int
SAP_EXTRACTOR_DELTA_INITIALIZE: Initialize delta Extractor. When an error
occurs, the function outputs \E\ and returns the error message
Syntax: sap_extractor_delta_initialize( [in] Datastore As varchar, [in] ExtractorName
As varchar, [out] ReturnText As varchar ) As varchar
SAP_OPENHUB_PROCESSCHAIN EXECUTE: Executes the process chain in the
specified SAP datastore.
Syntax: sap_openhub_processchain_execute( [in] Datastore As varchar, [in]
OpenHubTable As varchar, [in] ProcessChain As varchar, [out] LogId As varchar, [out]
ReturnText As varchar ) As varchar
SAP_OPENHUB_SET_READ_STATUS: notifies SAP Netweaver BW whether Data
Services was able to read the open Hub table.
Syntax: sap_openhub_set_read_status( [in] Datastore As varchar, [in] OpenHubTable
As varchar, [in] Status As varchar, [out] ReturnText As varchar ) As varchar
STRING FUNCTIONS:
ASCII: Get the ASCII for the first character in the input string.
Syntax: ascii( [in] InputString As varchar ) As int
Example: asci(a)
Result: 97
CHR: Get character representation of the given ASCII value.
Syntax: chr( [in] ASCIIValue As int ) As varchar
Example: chr(97)
Result: a
DOUBLE_METAPHONE: Returns the Double Metaphone encoding of the input string.
Syntax: double_metaphone( [in] InputString As varchar, [in] Alternate As number, [in]
ReturnInputIfEmpty As number ) As varchar
Example: double_metaphone(sap_student,0,0)
Result: SPSTTNT (encoded value for sap_student)
INDEX: Returns the position within the input string where the search string is contained.
The input string is scanned from the left, starting at the starting position.
Syntax: index( [in] InputString As varchar, [in] SearchString As varchar, [in]
StartingPosition As int ) As int
Example: index(sap_student,_,1)
Result: 4 (position is calculated starting from 1)
INIT_CAP: Capitalizes the first letter of each word in a given string.
Syntax: init_cap( [in] InputString As varchar, [in] InputLocale As varchar ) As varchar
Example: init_cap(sap_student website)
Result: Sap_student Website
LENGTH: Returns the length of the input string.
Syntax: length( [in] InputString As varchar ) As int
Example: length(sap_student)
Result: 11 (Length of the string sap_student)
LITERAL: Macro that makes the input literal. If you have any special characters in the
search string, then data services by default removes special characters while performing
search. We can use literal function to make the search string including special characters.
Syntax: literal( [in] input )
Example: literal(www.sapstudent.com)
Result: sapstudent.com
LOWER: Converts the input string to Lower case
Syntax: lower( [in] InputString As varchar, [in] InputLocale As varchar ) As varchar
Example: lower(English) or lower(English,de)
Result: english, englisch (along with lower case system converts to german language
using ISO 639 language codes)
LPAD: Left pads or truncates 1 to display length n with char2, replicated as many times
as necessary.
Syntax: lpad( [in] StringToBeLeft-padded As varchar, [in] Size As int, [in]
LeftPaddingString As varchar ) As varchar
Example: lpad(abcd,6,a)
Result: aaabcd (added two a characters on the left the side to make the string length
to 6.
LPAD_EXT: Left pads or truncates 1 to character length n with char2, replicated as many
times as necessary. Supports logical characters.
Syntax: lpad_ext( [in] StringToBeLeft-padded As varchar, [in] Size As int, [in]
LeftPaddingString As varchar ) As varchar
Example: lpad_ext(abcd,6,a) or lpad(abcd,3,a)
Result: aaabcd, bcd (truncated a character to make string length to 3)
LTRIM: Returns the input string with characters specified in the trim string removed. The
input string is scanned from the left. When the first character not in the trim is
encountered, the result is returned.
Syntax: ltrim( [in] InputString As varchar, [in] TrimString As varchar ) As varchar
Example: ltrim(abcd, ) or ltrim(abcd,ab)
Result: abcd, cd
LTRIM_BLANKS: Returns the input string with the blanks (spaces characters) on the left
removed.
Syntax: ltrim_blanks( [in] InputString As varchar ) As varchar
Example: ltrim( abcd)
Result: abcd
LTRIM_BLANKS_EXT: Returns the input string with the blanks (spaces, tabs, new lines,
and other non-visible characters) on the left removed.
Syntax: ltrim_blanks_ext( [in] InputString As varchar ) As varchar
Example: ltrim( abcd)
Result: abcd
MATCH_PATTERN: Searches input strings for the specified pattern. Substring matches
are not supported in match pattern. The result will 1 if the string matches else 0.
Syntax: match_pattern( [in] InputString As varchar, [in] PatternString As varchar ) As
int
Characters need to be used to create for pattern:
SYSTEM FUNCTIONS:
EXEC: Executes an executable or a batch file with the specified parameters.
Syntax: exec( [in] FileName As varchar, [in] Arguments As varchar, [in] Flags As int )
As varchar
Example: exec(c:\Data Services\bin\clone_and_rename.bat, TBL.FNAME, 1);
Result: This executes the file TBL.FINAME in the specified directory.
MAIL_TO: Sends e-mail (subject and message) to the provided recipients list via Data
Services Job server email client.
Syntax: mail_to( [in] RecipientsList As varchar, [in] Subject As varchar, [in] Message
As varchar, [in] TraceLogLinesNumber As int, [in] ErrorLogLinesNumber As int ) As int
Example: mail_to(admin@company.com,Out of memory error in the SalesFact job.
Please fix the error before running recovery job., ,10, 10)
Result: This sends the email to admin@company.com about the error SalesFact Job.
SMTP_TO: Sends e-mail (subject and message) to the provided recipients list via SMTP.
Syntax: smtp_to( [in] RecipientsList As varchar, [in] Subject As varchar, [in] Message
As varchar, [in] TraceLogLinesNumber As int, [in] ErrorLogLinesNumber As int ) As int
Example: smtp_to(admin@company.com, Out of memory error in the SalesFact job.
Please fix the error before running recovery job., ,10, 10)
Result: Sends email to company admin about the error.
VALIDATION FUNCTIONS:
IS_VALID_DATE: Returns 1 if the input string is valid date, 0 otherwise.
Syntax: is_valid_date( [in] InputExpression As varchar, [in] DateFormat As varchar )
As int
Example: is_valid_date(1/34/2010,mm/dd/2010)
Result: This returns 0 because there is no date with number 34.
Formats for Date: