Enterprise Resource Planning Blog Posts by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
BethBerr
Product and Topic Expert
Product and Topic Expert
1,599

 Introduction

    Custom number ranges for serial numbers are helpful when users want to automatically create serial numbers for materials instead of barcode scanning or manually entering long, tedious numbers. By creating and implementing a custom number range, you ensure that any user who selects ‘Auto-Create’ serial numbers while performing business processes will input serial numbers that meet your specific serial number requirements. Your serial numbers will be consistent and easier to track. 

     In this blog, we will show how you can create a custom number range for serial numbers in your system. This demonstration will be done using the BAdI Internal Serial Number Assignment using Developer Extensibility (LOSN_SER_NUM_INT_CREATE) which is available for developer extensibility.   

For more details on Developer Extensibility, see Developer Extensibility.

Note: Developer extensibility is only available in a 3-system landscape. For more information about system landscapes, see System Landscapes in SAP S/4HANA Cloud.

 
Prerequisites 

 

Basic Implementation 

    We will show you a basic implementation of this BAdI using ADT and then create custom serial numbers in the Manage Stock app by posting the initial entry of a serialized material and auto-creating the serial numbers for that material.

Example showing the assignment of automatically created serial numbers in the Mange Stock app.Example showing the assignment of automatically created serial numbers in the Mange Stock app.

To get started, create your own BAdI implementation in ADT. Right click on your package, select New > Other ABAP Repository Object.

BAB_UA_1-1726145430422.png

Then, filter for “BAdI.” Select “BAdI Enhancement Implementation” and click Next 

BAB_UA_2-1726145457479.png

Enter a name and description. In this example, I have entered the name “ZTESTIMPLEMENTATION” and the description “Test Creation of custom SN.” Next, search for the enhancement spot: LOSN_SERIAL_NUMBER_ASSIGNMENT. 

BAB_UA_3-1726145745416.png

Once the enhancement implementation is created, click on the button Add BAdI Implementation. 

BAB_UA_4-1726145769591.png

Enter the BADI Definition  LOSN_SER_NUM_INT_CREATE and create an implementation name. I entered ”zBAdItestSN.” Click Add. 

BAB_UA_5-1726145812129.png

Next, enter a class name of your choosing in the Implementing Class field, and click on the Implementing Class hyperlink to create the class. 

BAB_UA_6-1726145839784.png

Enter the class details and click next.

BAB_UA_7-1726145871172.png

Activate the class. Now go to the class and write your code in the method ' if_losn_ser_num_int_create~get_serial_number '.

In the following example case, we have used the code from the example implementation.  

BAB_UA_8-1726145893761.png

Save and activate. 
 
Now login to your S/4 HANA Cloud, Public Edition system and open the Manage Stock app. Select a serialized material. Enter the quantity of materials which you would like to post for initial entry, navigate to the value help in serial numbers field and select “Auto-Create.” After posting, navigate to the Material Documents Overview app by clicking on the link of the success dialog. In the material document that you just created, you can view the serial numbers that were automatically created using the internal numbering system that you implemented. 

For more information, see the SAP Help Portal: Extensibility for Serial Number Creation.

I hope this blog helps you to create your own custom serial numbers! If you liked it, please comment below!