I’m excited to share a plugin I’ve developed for CAP framework: cds-numberrange-plugin. It’s now available on both GitHub and the NPM Registry.
Why I Developed This Plugin?
Over the last year I’ve been exploring and using CAP plugins in various projects. I’ve really liked the concept how plugins can easily extend CAP functionality while keeping the original application clean and maintainable.
During one of my recent CAP projects, I encountered a common requirement: implementing a number range mechanism for generating sequentially increasing field values, mainly object IDs. I first tried to use SAP HANA’s native DB Sequence objects. However, it has some limitations and requires additional development if you need to implement additional logic on top of the generated numbers. You also need to implement your custom logic to be able to test your app locally.
These challenges led me to build a database-agnostic number range management plugin for CAP framework.
Thanks to the existing open source plugins developed by SAP and Community that helped me to build my own. Especially Create your first CAP plugin by @WouterLemaire helped me to understand the basics of the plugin concept on CAP.
What the Plugin Does?
The cds-numberrange-plugin provides a customizable and database-agnostic number range management feature for your CAP projects. It integrates seamlessly as a CAP plugin and supports:
– Easily add auto-incrementation logic on your database fields.
– Optional formatting features like prefixes, suffixes, padding, etc.
– Determine when the number should be generated – either during draft creation or on draft activation.
The generated numbers can be configured in following different formats:
– Integer: 1,2,3,4,5…
– Integer: 1,3,5,7,9…
– String: 0001, 0002, …., 0010, 0011…
– String: A000000001Z, A000000002Z, A000000003Z…
I’ve tested the plugin with SQLite In-Memory, SQLite Persistent and SAP HANA databases and all works fine. I haven’t tested on PostgreSQL yet, but I’m sure it will work, since the DB part is implemented within the standard CAP framework.
Get Started
You can install the plugin via NPM:
npm install cds-numberrange-plugin
Sample package.json configuration should be like:
“cds-numberrange-plugin”: {
“ranges”: [
{
“name”: “<RANGE NAME>”,
“start”: 1,
“increment”: 1,
“createOnDraf”: true,
“additionalProperties”: {
“prefix”: “P”,
“suffix”: “S”,
“padCount”: 10,
“padValue”: “0”
}
}
]
}
And explore the full documentation, usage examples, and source code on GitHub:
https://github.com/abdulbasitg/cds-numberrange-plugin
Contribute or Share Feedback
As this is an open-source project, I’m always open to improvements and contributions. If you try it out and have feedback, suggestions, or bug reports – please open an issue or contribute via pull request on GitHub.
I hope this plugin helps the community with number range use cases more efficiently. Looking forward to feedback and improvement ideas!
I’m excited to share a plugin I’ve developed for CAP framework: cds-numberrange-plugin. It’s now available on both GitHub and the NPM Registry.Why I Developed This Plugin?Over the last year I’ve been exploring and using CAP plugins in various projects. I’ve really liked the concept how plugins can easily extend CAP functionality while keeping the original application clean and maintainable.During one of my recent CAP projects, I encountered a common requirement: implementing a number range mechanism for generating sequentially increasing field values, mainly object IDs. I first tried to use SAP HANA’s native DB Sequence objects. However, it has some limitations and requires additional development if you need to implement additional logic on top of the generated numbers. You also need to implement your custom logic to be able to test your app locally.These challenges led me to build a database-agnostic number range management plugin for CAP framework.Thanks to the existing open source plugins developed by SAP and Community that helped me to build my own. Especially Create your first CAP plugin by @WouterLemaire helped me to understand the basics of the plugin concept on CAP. What the Plugin Does?The cds-numberrange-plugin provides a customizable and database-agnostic number range management feature for your CAP projects. It integrates seamlessly as a CAP plugin and supports:- Easily add auto-incrementation logic on your database fields.- Optional formatting features like prefixes, suffixes, padding, etc.- Determine when the number should be generated – either during draft creation or on draft activation.The generated numbers can be configured in following different formats:- Integer: 1,2,3,4,5…- Integer: 1,3,5,7,9…- String: 0001, 0002, …., 0010, 0011…- String: A000000001Z, A000000002Z, A000000003Z…I’ve tested the plugin with SQLite In-Memory, SQLite Persistent and SAP HANA databases and all works fine. I haven’t tested on PostgreSQL yet, but I’m sure it will work, since the DB part is implemented within the standard CAP framework.Get StartedYou can install the plugin via NPM:npm install cds-numberrange-pluginSample package.json configuration should be like: “cds-numberrange-plugin”: {
“ranges”: [
{
“name”: “<RANGE NAME>”,
“start”: 1,
“increment”: 1,
“createOnDraf”: true,
“additionalProperties”: {
“prefix”: “P”,
“suffix”: “S”,
“padCount”: 10,
“padValue”: “0”
}
}
]
}And explore the full documentation, usage examples, and source code on GitHub:https://github.com/abdulbasitg/cds-numberrange-pluginContribute or Share FeedbackAs this is an open-source project, I’m always open to improvements and contributions. If you try it out and have feedback, suggestions, or bug reports – please open an issue or contribute via pull request on GitHub.I hope this plugin helps the community with number range use cases more efficiently. Looking forward to feedback and improvement ideas! Read More Technology Blog Posts by Members articles
#SAP
#SAPTechnologyblog