Skip to Content
Author's profile photo Horst Schaude

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”.

CodeDataType.png

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

CustomReuseLib.png

which has as an input parameter the order type.

GetOrderNumber.png

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.

code!.png

As we want to separate the number between the order types a switch statement follows in which the formatting takes place.

Code2.png

The result is convert to string and assigned to the return parameter

Code3.png

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.

Code4.png

Similar are the Order and Invoice:

/wp-content/uploads/2014/06/code5_489267.png

/wp-content/uploads/2014/06/code6_489268.png

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.

/wp-content/uploads/2014/06/code7_489269.png

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.

/wp-content/uploads/2014/06/code8_489272.png

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.

/wp-content/uploads/2014/06/code9_489273.png

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.

/wp-content/uploads/2014/06/code10_489274.png

That’s all, folks.

Horst

Assigned Tags

      18 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Horst,

      thanks for your blogpost.

      I have a question, as the above mentioned way doesn't work and we are getting dumps in ByD.

      We have created a Codelist with an entry of our own created bo (ABCNumber). We are handling this Codelist value in the parameter of the created custom reuse library.

      In the reuse library we draw the number from the NumberRange as you mentioned above. Unfortunately we are getting a dump when we are exectuing this.

      The call is: var number = NumberRange.drawNumber("ABCNumber")

      Could you maybe help us here?

      Best Regards,

      Daniel

      Author's profile photo Horst Schaude
      Horst Schaude
      Blog Post Author

      Hello Daniel,

      Can you provide some details about the dump?

      Bye,

          Horst

      Author's profile photo Former Member
      Former Member

      Hi Horst,

      thanks for your respond.

      We have tried to get a solution for this issue and we now found one. If we are using the following code, there will be a number drawn from the number range:

      //  

      var numberRange : ID = "Record";

      var number = NumberRange.DrawNumber(numberRange);

      var aktID = (100000 + number).ToString();

      //

      We don't know, why we got a dump, but finally it works.

      Best Regards,

      Daniel

      Author's profile photo Horst Schaude
      Horst Schaude
      Blog Post Author

      Hello Daniel,

      If there any issues, please contact me.

      Bye,

           Horst

      Author's profile photo Fred K
      Fred K

      Hi Horst,

      I am getting "0" when I use NumberRange.GetNumber function in another instance.

      BeforeSave for instance 1

          var rec : ID="ORDER";

          var num=NumberRange.DrawNumber(rec);             // is 3.

          var currentNum=NumberRange.DrawNubmer(rec);  // is 3

      BeforeSave for instance 2

         var rec : ID="ORDER";

          var current=NumberRange.GetNumber(rec);     // always gives "0".

      with a warning "Invalid Importing Parameter Namespace".

      Best Regards

      Fred.

      Author's profile photo Horst Schaude
      Horst Schaude
      Blog Post Author

      Hello Fred,

      Because of this message you will get the "0" back.

      The message is raised because the namespace of your solution was not handed over.

      Any special for the second instance?

      Otherwise you need to raise a incident.

      You can ask the processor to put it direct on my name.  😀

      Bye,

         Horst

      Author's profile photo Fred K
      Fred K

      Hi Horst,

             Thanks .

             "Not handed over"? I dont understand what you mean. 🙂

              How can I make it handed over? 🙂

              I think there is nothing special in the second instance.

      Best Regards

      Fred

      Author's profile photo Horst Schaude
      Horst Schaude
      Blog Post Author

      Hello Fred,

      That's nothing you are doing direct. 😀

      It the system, stupid. 😉

      So, create the incident.

      Sorry,

         Horst

      Author's profile photo Former Member
      Former Member

      Thank you Horst for the great blog.

      Regards,

      Gincy Anto.

      Author's profile photo Puneet Mittal
      Puneet Mittal

      Hi Horst,

      Thanks for sharing such type of blog!!!!

      I go through this blog , Firstly i have created code list data type with order only then create reuse library.

      When i have written code in GetOrderNumber.absl then it gives dump.  I am not accessing Code list name directly .

      Can you help me on this.

      Regards,

      Puneet Mittal

      Author's profile photo Horst Schaude
      Horst Schaude
      Blog Post Author

      Hello Puneet,

      May you post the code?

      Bye,

         Horst

      Author's profile photo C4C Admin
      C4C Admin

      Hi Horst,

      I am new to SDK and have below question on reuse library.

      Can we create one generic SDK solution with custom BO and reuse library with function to get that custom BO instance and then use that library function in other custom solution with custom BO action script?

      I did same like created one generic custom solution with custom BO and then custom library for example ‘MyCustomLib’ with function. But when I try to reuse that custom created library in other custom solution BO action script, it am getting error like "identifier ‘MyCustomLib’ does not exist". Anything I need to declare to use that library or we can not use since that library is not in the same solution.

       

      Regards,

      Harshad Patel

       

      Author's profile photo Horst Schaude
      Horst Schaude
      Blog Post Author

       

      Hello Patel,

      The "generic SDK solution" must simply be a "Solution Template", not a "Customer-Specific Solution".

      If you are done with our development of the CRL and all other stuff, simply import that Solution Template into your current solution and you can use the CRL.

       

      HTH,
      Horst

      Author's profile photo HARISH R
      HARISH R

      Hello Horst Schaude.

      I'am trying to reset the number range object. It's not working for me
      Can you help me on this.

      Author's profile photo Horst Schaude
      Horst Schaude
      Blog Post Author

      Hello Harish,

      Did you ensure that "RECORD" and "AutoNumbersList" is the same?

      Maybe you should first define a variable for the NumberRange name and then re-use it to ensure it is the same everywhere.

      HTH,
      .    Horst

      Author's profile photo Vinutha E
      Vinutha E

      Hi Horst Schaude,

      What could to be the approach if we want to use the number range functionality in offline mode.

       

      Since NumberRange.Drawnumber not supported in offline absl

       

      Kindly pass the inputs.

       

      thanks in advance

       

      Best Regards,

      Vinutha

      Author's profile photo Horst Schaude
      Horst Schaude
      Blog Post Author

      Hello Vinutha,

      As in offline there may be several parallel running instances which do not know from each other (due to being offline) this may not feasible.

      You will only be able to draw valid & unique numbers after going online.

      Sorry,
      Horst

      Author's profile photo Vinutha E
      Vinutha E

      Thanks Horst for your reply.

       

      Regards,

      Vinutha