Skip to end of metadata
Go to start of metadata

-->User Exit for NumberRanges In a global SAP implementation often there are several sales organizations that are defined in SAP. Many a times there is a need for using the same sales order type across all the sales organizations and a need to have different number ranges depending on the sales organization. This enables an experienced end user to quickly identify which sales organization the document belongs to without checking the document in sales transaction. Standard SAP has configuration where we can assign only one number range to a document type. SAP has provided a form in the user exit program MV45AFZZ where we can overwrite the number range object number that has been assigned in sales document type configuration.  The following is the procedure which we can use to achieve one number range for each sales organization per document type: # Create a new table ZSD_DOCTYP_NUMBER with the fields Sales Organization, Order type and Number range.

  1. Create a table maintenance generator for the same so that we can maintain entries using T-code SM30,
  2. In the program MV45AFZZ and in the form FORM userexit_number_range USING us_range_intern, write the following piece of code.

DATA: l_numki LIKE nriv-nrrangenr.

*// Initialize the varaible.

 CLEAR: l_numki.

*// Retrive the number range from the custom table

   SELECT SINGLE numki

           INTO l_numki

           FROM zsd_doctyp_number

           WHERE vkorg = vbak-vkorg AND

                 auart = vbak-auart.

   IF l_numki IS NOT INITIAL.

*// If Number range found, Move the Number range to the field.

     MOVE l_numki TO us_range_intern.

   ELSE.

*// If Number range not found Raise an error message.

     MESSAGE e901 WITH l_numki vbak-vkorg vbak-auart.

   ENDIF.

*// Initialize the varaible.

     CLEAR: l_numki.