Document Title: Notes on BML Functions in Oracle CPQ
1. Introduction to BML
BML (BigMachines Markup Language) is a proprietary scripting language
used in Oracle CPQ to implement custom business logic. BML is used across
Configuration, Commerce, Document Engine, and Integration modules.
2. BML Function Categories
BML functions are organized into various categories based on their use
cases:
2.1 String Functions
strConcat(str1, str2) – Concatenates two strings.
strToLower(str) – Converts a string to lowercase.
strToUpper(str) – Converts a string to uppercase.
strReplace(str, find, replace) – Replaces all occurrences of a
substring.
strTrim(str) – Removes leading/trailing whitespace.
2.2 Date Functions
getDate() – Returns the current date.
getTime() – Returns the current timestamp.
dateDiff(date1, date2) – Difference between two dates in days.
addDaysToDate(date, days) – Adds specified days to a date.
formatDate(date, format) – Formats a date string.
2.3 Math Functions
abs(number) – Absolute value.
round(number, decimalPlaces) – Rounds a number to given decimal
places.
min(num1, num2) – Returns the smaller of two numbers.
max(num1, num2) – Returns the larger of two numbers.
2.4 Conditional Functions
if(condition, trueValue, falseValue) – Returns one of two values
based on condition.
switch(condition, case1, value1, ..., defaultValue) – Returns
value based on multiple case matches.
2.5 List Functions
createList() – Creates an empty list.
listAdd(list, value) – Adds value to a list.
listSize(list) – Returns number of items in the list.
listContains(list, value) – Checks if value exists in list.
2.6 Map Functions
createMap() – Creates an empty key-value map.
mapPut(map, key, value) – Adds a key-value pair.
mapGet(map, key) – Retrieves value for a key.
mapContainsKey(map, key) – Checks if map contains the key.
2.7 BMQL Functions
bmql(query) – Executes a BMQL query and returns a result set.
get(attribute) – Retrieves attribute value.
set(attribute, value) – Assigns value to an attribute.
2.8 Miscellaneous Functions
logDebug(message) – Writes debug info to logs.
isNull(value) – Checks if value is null.
toString(value) – Converts a value to string.
toNumber(value) – Converts string to numeric type.
3. Common Use Cases
Dynamic pricing calculations
Input validations and formatting
Conditional logic for visibility and workflow
Custom document generation
Integrations with external systems using REST/SOAP
4. Best Practices
Modularize complex logic using util functions.
Use meaningful variable names.
Handle null values gracefully.
Optimize BMQL queries to prevent performance issues.
Log key checkpoints for easier debugging.
5. Sample Snippet
if (isNull(partNumber)) {
return "Part number is missing.";
} else {
return "Part: " + partNumber;
}
6. Conclusion
Understanding and utilizing BML functions effectively can greatly enhance
the flexibility and power of Oracle CPQ implementations. Mastery of these
functions enables developers to build smart, efficient, and scalable solutions.
End of Document