How to Use the Reuse Library NumberRange
In nearly every solution there is the need to have a unique numbering of the Custom Business Object instances.
Until now in most cases a special Custom Business Object is “misused” for this functionally.
With the release 1405 we finally provide a reuse library which does the job.
Here I want to describe how this reuse library can be used and explain it with some examples.
Use Case “Quote, Order, Invoice Numbering”
You are using quotes, orders, and invoices and need to number them in separate intervals.
Step 1: Create a own Code Data Type
As we are working with quotes, orders, and invoices, I created a own code data
type and named it “OrderType”.
Step 2: Custom Reuse Library
The reason to create a Custom Reuse Library is that you can centralize the creation
of the numbers and reuse this.
This Custom Reuse Library should contain a function to derive the numbers
which has as an input parameter the order type.
Step 3: Code the Function in the Custom Reuse Library
In the resp. ABSL code the Reuse Library NumberRange is called to draw a new number for the order type from the input. We use the order type as so called Number Range Object to separate between different number ranges.
As we want to separate the number between the order types a switch statement follows in which the formatting takes place.
The result is convert to string and assigned to the return parameter
Step 4: Call of the Function in the Custom Business Object Script
In the ABSL coding of the Custom Business Object Quote the drawing of the invoice number looks like this.
Similar are the Order and Invoice:
Use Case “Special Format for Records”
You need to format the identification of a record in a distinct manner; especially you want to include the current year.
Step 1: Call the Reuse Library
Call the Reuse Library to draw a new number for the record. Use the string “RECORD” for the Number Range Object.
Step 2: Format the Number
We want to prefix each and every number with the letter “R”, have the current year, and the number with 4 digits. Each part is separated by a minus sign.
As the length of the return value of the DrawNumber function of the Reuse Library is char 60 we use Substring 56.
Step 3: Call of the Function in the Custom Business Object Script
The call in the ABLS code is very simple.
Step 4: Reset the Number Range Object
As we include the current year we want the numbers to restart each year. Therefore we need to reset the Number Range Object by calling this code.
That’s all, folks.