- Arithmetic
- Boolean
- Constants
- Conversions
- Node Functions
- Statistics
- Text
ARITHMETIC FUNCTIONS
These are standard functions used in graphical mapping whenever we use only numerical values. These include values with digits after the decimal point. If it is not a digit, then the system throws a Java exception. The default data type for all calculations is 'float'.
The output structure depends upon the result.
- If the result is a value with decimal places existing, then the output value remains unchanged.
- If the result is a value with zero after decimal point, then the integer value of the result is considered. For e.g. the result of 23.5 + 6.5 = 30 and not 30.0.
The details of the standard Arithmetic functions are as follows:
add: This function simply sums up the input values and produces the summation value as output.
Here we are considering the marks obtained by a student. In the source structure, all marks are specified individually. But in the target structure, Physics Chemistry and Biology are considered as a single subject Science. Also History and Geography are optional and considered as single.
subtract: This function simply subtracts the second input value from the first and produces the value as output.
abs: This function gives the absolute value of the input fed. For e.g. if the input value is a negative number (say -100), then the output will become a positive one (100).
Here we are calculating the difference in marks scored between History and Geography. If the first input is higher than the second, then it is a positive value else a negative one. In that case the abs function takes the absolute value of the difference and provides it to the output structure.
Case 1: When the first input is greater than the second input.
Case 2: When the first input is lower than the second input.
max: This function compares two input values and gives the larger one as the output.
Here we are comparing the marks obtained in Science group and displaying the maximum marks scored.
min: This function compares two input values and gives the smaller one as the output.
Here we are comparing the marks obtained in Science group and displaying the minimum marks scored.
multiply: This standard function multiplies the two input values and produces the multiplied output to the target structure.
Here we are simply taking the two marks, obtained in English and Mathematics, as input and multiplying them to produce the output.
divide: This function divides the first input value with the second input value and provides the result to the output structure element.
Here we are calculating the average marks obtained by the student in Science group.
equalsA: This function takes the two float inputs, compares them and returns 'true' if the values are equal else 'false'.
Here we are comparing the marks obtained in History and Geography. If both are equal, target structure element "Equality" holds 'true' else 'false'.
sign: This standard function returns '0' if the input value is zero, returns '1' if the input value is positive else '-1' if the input value is negative.
Here we are checking the difference in marks obtained in History and Geography and according to the result, the 'Sign' field in target structure is updated.
neg: This function simply multiplies the input value with -1 and produces the output, thus simply changes the sign of the input value.
Here we are just checking the difference between marks obtained in History and Geography. If the output from 'sub' is positive, the resultant output from 'neg' becomes negative and vice-versa.
inv(1/x): This function gives the reciprocal value of the given input value.
Here we are calculating the inverse of the marks obtained in English.
greater: This function takes two input values and compares them. If the first value is greater than the second one, the output is 'true' else 'false'.
less: This function takes two input values and compares them. If the first value is less than the second one, the output is 'true' else 'false'.
Here we are taking the marks obtained in History and Geography, comparing them and producing the corresponding outputs.
power: This function takes the two input values and returns the value of the first argument to the power of the second argument. If the result exceeds the range, then it is expressed in exponential terms.
Here we are just taking the marks obtained in English as the first argument to the power of marks obtained in Mathematics as the second argument.
sqr: This function simply returns the square of the input value.
sqrt: This function simply returns the square root of the input value.
Here we are taking the marks obtained in Biology and feeding it in 'sqr' and 'sqrt' functions.
round: This function rounds off the input value and returns the closest integer value to the argument.
Here we are considering the average marks scored in Physics, Chemistry and Biology. The 'round' function rounds off the average and returns the closest integer value to it.
ceil: This function produces the smallest possible integer value (up to minus 'infinite') that is not smaller than the input argument and is equal to a mathematical integer.
Here we are taking the difference in marks obtained in History and Geography and the ceiling value as the result.
floor: This function produces the largest possible integer value that is not larger than the input argument and is equal to a mathematical integer.
Here we are taking the difference in marks obtained in History and Geography and the floor value as the result.
counter: This standard function counts the number of invocations. The result is the number of calls for this target-field mapping where we specify the initial value and the increment of the counter in the function properties.
Here we are counting the number of students whose marks are being displayed.
FormatNum: This standard function helps in displaying the result in the required format. By default, there are three standard formats. The user can also define their own formats by typing the same in the "Number Format" area. It can be done by either typing '0's or '#'s. '0' signifies that the result will be displayed in given format but the vacant spaces will be substituted by zeros. But in case of '#', the result will be displayed in given format only, even if the length if the result is smaller. The 'Decimal Separator' displays the decimal point in the mentioned format.
Here we are formatting the result of the difference between the marks of History and Geography.
Constants:
The standard functions of the Constants function category do not have an input value. Therefore, they generate a value for a target field instead of taking it from a source field. . In addition to these functions, all functions (regardless of whether they are standard or user-defined functions) that do not have input values are referred to as Generating Functions.
CONSTANT: O gets any string constant that you can enter in the dialog for the function properties.
Example : i map the constant value"I am consatnt' to target field constant.
you can enter the value in preoperties of constant:
COPYVALUE:
For a frequently occurring element, copies the value at a defined position in the source structure to the assigned target field.
Ex.
i take the position = 1 ...
and here is the output:
like i have value Nitesh Sunil and Anil. So in queue Nitesh will on 0th position Sunil on 1 and Anil on 2ed.
so the value for each occurence in target will be 1st place holder sunil.
3)SENDER
O gets the name of the sender business system. Test_Sender_System is output when you test the message mapping in the Integration Builder. and the ouptput :
4)RECEIVER
O returns the name of the receiver business system. Test_Receiver_System is output when you test the message mapping in the Integration Builder. and the output:
Node Function:
Real Example for formatByExample by Sundararamaprasad Subbaraman
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3194
For removeContexts,SplitByValue,collapseContexts ,createIf,exists,useOneAsMany
Message Mapping Simplified - Part II by Sravya Talanki
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2792
Statistics :
Designed for source fields that occur more than once in the source structure (maxOccurs = i > 1).
1) SUM:
R = Sum of values X1 to Xi of a context.
For example I want to take the sum of payment:
Make the context mt_source.
And here is the output:
2)AVERAGE :
R = Average of values X1 to Xi of a context
With the same example of last one used in SUM, I will replace the sum function with Average and map it to total payment.
And the output:
3) COUNT:
R = Number of fields in a context .
With the same example I will count the credit card (source) occurrences in total card (target).context will be mt_source only.
And output is:
4) INDEX:R = Index i of Xi.
In the function properties, you specify the following: the initial value of i, the increment, and whether the index value is to be reinitialized at the beginning of every new context, or whether it is to have the same value for the entire source structure.
We can generate sequence number or indexing with split by value function.
And output :
4
Text:
1. substring:
Input
1) string = "Firstname" (for example)
Parameters
o starting position = 0 (for example)
o number of characters = 4 (for example)
Description
This function accepts a string, asks for the initial position (index) and the number of characters to be extracted from the input string.
Output
o only selected part of the input string = "Firs" (i.e. four characters from index '0') (for this example)
2. concat:
Input
1) string1 = "Lastname" (for example)
2) string2 = "Firstname" (for example)
Parameters
o delimiter = ", " (for example)
Description
This function accepts two strings and concatenates them with the delimiter specified by the user.
Output
o string1<delimiter>string2 = "Lastname, Firstname" (for this example)
3. equalsS:
Input
1) string1 = "Lastname" (for example)
2) string2 = "Firstname" (for example)
Parameters
o (none)
Description
This function simply accepts two strings. If both are same then return "true" else returns "false".
Output
o "true" (if the input strings are same) = "false" (for this example)
o "false" (otherwise)
4. indexOf (2 input parameters):
Input
1) string1 = "Firstname" (for example)
2) string2 = "name" (for example)
Parameters
(none)
Description
This function accepts two strings and finds the second string in the first one.
If the second string is found in first string, then it returns the index (index starts from zero) otherwise it returns "-1". The comparison is case-sensitive.
Output
o Index from where string2 starts = "5" (for this example)
5. indexOf (3 input parameters):
Input
1) string1 = "Firstname" (for example)
2) string2 = "name" (for example)
3) number (also a string) = "3" (for example)
Parameters
(none)
Description
This function accepts two strings & a number (say n) and finds the second string in the first one from the nth index in the first string.
If the second string is found in first string, then it returns the index (index starts from zero) otherwise it returns "-1". The comparison is case-sensitive.
Output
o Index from where string2 starts. = "5" (for this example)
o "-1" if string2 not found in string1.
6. lastIndexOf (2 input parameters):
Input
1) string1 = "Firstname" (for example)
2) string2 = "name" (for example)
Parameters
(none)
Description
This function accepts two strings and finds the last position at which second string is found in the first one.
If the second string is found in first string, then it returns the index (index starts from zero) otherwise it returns "-1". The comparison is case-sensitive.
Output
o Index from where string2 starts = "5" (for this example)
o "-1" if string2 not found in string1
7. lastIndexOf (3 input parameters):
Input
1) string1 = "Firstname" (for example)
2) string2 = "name" (for example)
3) number (also a string) = "3" (for example)
Parameters
(none)
Description
This function accepts two strings & a number (say n) and finds the last position at which second string is found in the first one, starting from the nth index in the first string.
If the second string is found in first string, then it returns the index (index starts from zero) otherwise it returns "-1". The comparison is case-sensitive.
Output
o Index from where string2 starts. = "5" (for this example)
o "-1" if string2 not found in string1.
8. compare:
Input
1) string1 = "First00" (for example)
2) string2 = "First01" (for example)
Parameters
(none)
Description
This function accepts two strings and compares them lexicographically.
In simple word, the lexicographic or lexicographical order is also known as dictionary order. That is if the words were put (in order) in a dictionary, then after how many words will string1 come after string2. [Note: output is "0" if strings are equal.]
Output
o Returns an integer number as the lexicographic difference of string1 with respect to string2. = "-1" (for this example)
9. replaceString:
Input
1) string1 = "rumming with gums" (for example)
2) string2 = "m" (for example)
3) string3 = "n" (for example)
Parameters
(none)
Description
This function accepts three strings and replaces all occurrences of string2 with string3 in string1.
The comparison is case-sensitive.
Output
o string1 with its parts replaced as string3 in place of string2. = "running with guns" (for this example)
10. length:
Input
1) string1 = "Firstname" (for example)
Parameters
(none)
Description
This function accepts one string & calculates its length.
Output
o Returns the length of string1 = "9" (for this example)
11. endsWith:
Input
1) string1 = "Firstname" (for example)
2) string2 = "name" (for example)
Parameters
(none)
Description
This function accepts two strings and checks if string2 is the last part of string1.
The comparison is case-sensitive.
Output
o "true" if string2 is the last part of string1 = "true" (for this example)
o "false" otherwise.
12. startsWith (2 input parameters):
Input
1) string1 = "Firstname" (for example)
2) string2 = "Fir" (for example)
Parameters
(none)
Description
This function accepts two strings and checks if string2 starts with string1.
The comparison is case-sensitive.
Output
o "true" if string2 starts with string1 = "true" (for this example)
o "false" otherwise.
13. startWith (3 input parameters):
Input
1) string1 = "Firstname" (for example)
2) string2 = "irst" (for example)
3) number (also a string) = "1" (for example)
Parameters
(none)
Description
This function accepts two strings & a number (say n) and checks if string2 when it starts from index n with string1.
The comparison is case-sensitive.
Output
o "true" if string2 is the last part of string1 = "true" (for this example)
o "false" otherwise.
14. toUpperCase:
Input
1) string1 = "Firstname" (for example)
Parameters
(none)
Description
Converts all characters of the string to uppercase.
Output
o string1 with all characters in uppercase = "FIRSTNAME" (for this example)
15. trim:
Input
1) string1 = " Firstname " (for example)
Parameters
(none)
Description
This function accepts a string and removes all the white space characters (spaces, tabs, returns, etc.) from the start and end of the input string.
Output
o string1 with all white spaces removed from start and end = "Firstname" (for this example)
16. toLowerCase:
Input
1) string1 = "Firstname" (for example)
Parameters
(none)
Description
Converts all characters of the string to lowercase.
Output
o string1 with all characters in lowercase = "firstname" (for this example)
1 Comment
Former Member
Congratulations, It's very interesting.