You are on page 1of 17

In SAP BODS These functions are basically classified into 14 different categories as listed

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.

Syntax: is_group_changed( [in] ExpressionList ) As int


Example: is_group_changed (state,city)
Result: 1,0,1,0,0,1,1
ISEMPTY: Determines if the nested table is empty or not.
Syntax: isempty( [in] NestedTableName As int ) As int
Example: isempty(HEADER_TABLE.LINE_ITEM_TABLE)
Result: 1 if empty else 0.
JOB_NAME: Returns the name of the job in which the call to this function exists.
Syntax: job_name( ) As varchar
Example: job_name( )
Result: JOB_DS_FUNCTIONS
JOB_RUN_ID: Returns the run identifier of the job in which the call to this function
exists.
Syntax: job_run_id( ) As varchar
Example: job_run_id( )
Result: 51
LEAST: Returns the lowest value in a list of at least one or more expressions.
Syntax: least( [in] ExpressionList )
Example: least(p,s,t)
Result: p
NVL: Replaces the input with Replacement if Input is NULL.
Syntax: nvl( [in] InputExpression, [in] ReplacementExpression )
Example: nvl(DS_MISC_FUNC.DELIVERY_DATE, sysdate())
Result: 09.29 20:21:11
PREVIOUS_ROW_VALUE: Returns column value for previous row.
Syntax: previous_row_value( [in] Expression )
Example: previous_row_value( DS_AGGR_FUNC.LINE)
Result: previous line value for subsequent row
PUSHDOWN_SQL: During execution, pushes the SQL string in the second argument to
the database represented by the datastore in the first argument for execution.
Syntax: pushdown_sql( [in] DatastoreName As varchar, [in] SQLString As varchar ) As
int
Example: pushdown_sql(DS_SAPHANA_TGT,substr_after(ab-cd,-))
Result: cd
RAISE_EXCEPTION: Calling this function causes an exception to be generated.
Syntax: raise_exception( [in] ErrorMessage As varchar ) As int
Example: ifthenelse(DS_AGGR_FUNC.AMOUNT < 200 , 0, ( apply 20% discount))
RAISE_EXCEPTION_EXT: Calling this function causes an exception to be generated.
Syntax: raise_exception_ext( [in] ErrorMessage As varchar, [in] ExitCode As int ) As
int
Example: ifthenelse(DS_AGGR_FUNC.AMOUNT < 200 , 0, raise_exception_ext( apply
20% discount, DS_AGGR_FUNC.AMOUNT*0.8 ))
REPOSITORY_NAME: Returns the repository name which is the database connection
string and owner name.
Syntax: repository_name( ) As varchar
Example: repository_name()
Result: SERVER.DS_SAP_STUD
SET_REPSERVER_CDC_READER_START_TIMESTAMP: This function marks the start
timestamp for a Sybase Replication server CDC table reader.
Syntax: set_repserver_cdc_reader_start_timestamp( [in] TableName, [in]
DataflowName As varchar, [in] JobName As varchar, [in] Type As int, [in]
UserSpecifiedTimestamp As datetime ) As int
SLEEP: Suspends the execution of a data flow or work flow for the specified milliseconds.
Syntax: sleep( [in] Milliseconds As int ) As int
Example: sleep(3000)
Result: data flow or work flow starts after 3 secs
SYSTEM_USER_NAME: Returns the user name used to log into the job server operating
system.
Syntax: system_user_name( ) As varchar
Example: system_user_name( )
Result: Administrator
TABLE_ATTRIBUTE: Retrieves the values of the specified table attribute.
Syntax: table_attribute( [in] TableName As varchar, [in] AttributeName As varchar )
As varchar
Example:table_attribute(DS_SAP_HANA_TGT.SAP_STUDENT.DS_MISC_FUNC,Date_c
reated)
Result: Fri Sep 25 12:19:25 2015
TRUNCATE_TABLE: Deletes all rows in a memory table.
Syntax: truncate_table( [in] InputTable ) As int
Example: truncate_table( MISC_FUNC )
Result: 0 Rows in MISC_FUNC
WAIT_FOR_FILE: Notify the existence of files that match the input file name pattern.
Syntax: wait_for_file( [in] FileName As varchar, [in] Timeout As int, [in] PollInterval As
int, [in] MaxMatch As int, [out] FileNameList As varchar, [out] ListSize As int, [in]
ListSeparator As varchar ) As int
WORKFLOW_NAME: Returns the innermost work flow name in which this call exists.
Syntax: workflow_name( ) As varchar
Example: workflow_name( )
Result: WF_MISC_FNS

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:

Examples for Pattern Strings:


MATCH_REGEX: Searches input strings for the specified regular expression pattern
Syntax: match_regex( [in] InputString As varchar, [in] RegularExpressionPattern As
varchar, [in] Flags As varchar ) As int
Example: This function itself is huge and has lot of options, please go through the
article MATCH_REGEX function in SAP Data Services for more details.
MATCH_SIMPLE: Searches input strings for the specified simple pattern. The result is
either 1 or 0.
Syntax: match_simple( [in] InputString As varchar, [in] PatternString As varchar ) As
int
Example: match_simple(ACCT14,ACCT[1..5000])
Result: 1 (The input value ACCT14 match with the search string).
PRINT: Prints the input string to the trace log file.
Syntax: print( [in] InputString As varchar ) As varchar
Example: print(the current time stamp is : || cast(sysdate(),varchar(20));
Result: 09.28 10:44:12 (displays the current system date and time)
REPLACE_SUBSTR: Returns a string where every occurrence of a given search string in
the input string is replaced by the given replacement string.
Syntax: replace_substr( [in] InputString As varchar, [in] SearchString As varchar, [in]
ReplaceString As varchar ) As varchar
Example: replace_substr(a penny saved is a penny earned,penny, million)
Result: a million saved is a million earned
REPLACE_SUBSTR_EXT: Returns a string where occurrence(s) of a given search string
in the input string is replaced by the given replacement string.
Syntax: replace_substr_ext( [in] InputString As varchar, [in] SearchString As varchar,
[in] ReplaceString As varchar, [in] StartAtOccurrence As int, [in] NumberOfOccurrence
As int ) As varchar
Example: replace_substr_ext(ayyyayyyayyyayyy, a, B, 2, 2)
Result: ayyyByyyByyyayyy (Replaced a with B starting from second occurrence and
replaces two occurrences )
RPAD: Right pads or truncates 1 to display length n with char2, replicated as many times
as necessary.
Syntax: rpad( [in] StringToBeRight-padded As varchar, [in] Size As int, [in]
RightPaddingString As varchar ) As varchar
Example: rpad(abcd,6,e)
Result: abcdee (total string length 6 and adds e to match the string length)
RPAD_EXT: Right pads or truncates 1 to character length n with char2, replicated as
many times as necessary. Supports logical characters.
Syntax: rpad_ext( [in] StringToBeRight-padded As varchar, [in] Size As int, [in]
RightPaddingString As varchar ) As varchar
Example: rpad(abcd,6, )
Result: abcd (added 2 spaces on the right side to make string length 6)
RTRIM: Returns the input string with characters specified in the trim string removed. The
input string is scanned from the right. When the first character not in the trim is
encountered, the result is returned.
Syntax: rtrim( [in] InputString As varchar, [in] TrimString As varchar ) As varchar
Example: rtrim(abcd , ); rtrim(abcd,cd)
Result: abcd (removes the specified from right side); ab (removes cd from right
side)
RTRIM_BLANKS: Returns the input string with the blanks (spaces characters) on the
right removed.
Syntax: rtrim_blanks( [in] InputString As varchar ) As varchar
Example: rtrim_blanks(abcd )
Result: abcd (removes blank spaces from right side)
RTRIM_BLANKS_EXT: Returns the input string with the blanks (spaces, tabs, new lines,
and other non-visible characters) on the right removed.
Syntax: rtrim_blanks_ext( [in] InputString As varchar ) As varchar
Example: rtrim_blanks_ext(abcd )
Result: abcd (removes all the blank spaces from right side)
SEARCH_REPLACE: Performs a search and replace on input parameters by matching
specific criteria and values given in the search table specification.
Syntax: search_replace( [in] [ExternalTable,SearchColumn,ReplaceColumn], [in]
[SearchType], [in] [CaseSensitivity], [in] [DefaultReplacementValue], [in]
[InputColumnList], [in] [OutputColumnList] )
Note: This function has so many options which cannot be covered here, please go through
the article SEARCH_REPLACE function in SAP Data Services for more details.
SOUNDEX: returns the soundex encoding of the input string. The source string of English
and should not contain special characters or numbers. If the source is either special
characters or number, it will be ignored or prints 0000 as result.
Syntax: soundex( [in] InputString As varchar ) As varchar
Example: soundex(sapstudent)
Result: S 123 (soundex encoded value for sapstudent)
SUBSTR: returns the portion of the input string specified by the offset and length.
Syntax: substr( [in] InputString As varchar, [in] SubstringStart As int, [in]
SubstringLength As int ) As varchar
Example: substr (its a small world,5,20)
Result: a small world
UPPER: Converts the input string to Upper case
Syntax: upper( [in] InputString As varchar, [in] InputLocale As varchar ) As varchar
Example: upper(test)
Result: TEST
WORD: This function returns one word from an input string. Words are delimited by
white space. The word number indicates which word to return.
Syntax: word( [in] InputString As varchar, [in] WordNumber As int ) As varchar
Example: word(its a small world,3)
Result: small
WORD_EXT: This function returns one word from an input string. Words are delimited by
user-specified special character. The word number indicates which word to return.
Syntax: word_ext( [in] InputString As varchar, [in] WordNumber As int, [in]
WordSeparator As varchar ) As varchar
Example: word_ext(its.a.small.world,3,.)
Result: small

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:

IS_VALID_DATETIME: Returns 1 if the input string is valid datetime, 0 otherwise.


Syntax: is_valid_datetime( [in] InputExpression As varchar, [in] DateTimeFormat As
varchar ) As int
Example: is_valid_datetime (01/14/2002 26:56:09, mm/dd/yyyy hh24:mi:ss)
Result: This expression returns 0 because there is no such hour as 26, even on the
24 hour clock.
Formats for Date Time:

IS_VALID_DECIMAL: Returns 1 if the input string is valid decimal, 0 otherwise.


Syntax: is_valid_decimal( [in] InputExpression As varchar, [in] DecimalFormat As
varchar ) As int
Example: is_valid_decimal(123.45,###.##)
Result: The function returns 1 because the input value is a valid decimal.
IS_VALID_DOUBLE: Returns 1 if the input string is valid double, 0 otherwise.
Syntax: is_valid_double( [in] InputExpression As varchar, [in] DoubleFormat As
varchar ) As in
Example: is_valid_decimal(789.45,###.##)
Result: The function returns 1 because the input value is a valid double.
IS_VALID_INT: Returns 1 if the input string is valid integer, 0 otherwise.
Syntax: is_valid_int( [in] InputExpression As varchar, [in] IntegerFormat As varchar )
As int
Example: is_valid_int(123,###)
Result: The function returns 1 because the input value is a valid integer.
IS_VALID_REAL: Returns 1 if the input string is valid real, 0 otherwise.
Syntax: is_valid_real( [in] InputExpression As varchar, [in] RealFormat As varchar ) As
int
Example: is_valid_real(12345.6789,#####.####)
Result: The function returns 1 because the input value is a valid real number.
IS_VALID_TIME: Returns 1 if the input string is valid time, 0 otherwise.
Syntax: is_valid_time( [in] InputExpression As varchar, [in] TimeFormat As varchar )
As int
Example: is_valid_time(23:21:12,HH24:MM:SS)
Result: The function returns 1 because the input value is a valid time.

You might also like