Skip to Content

First step:
Create two number ranges for business requirement
path: Spro->Sales and Distribution->Sales->Sales Documents->Sales Document Header->Define Number Ranges For Sales Documents
TCODE: VN01

Second Step:
Configure the number ranger of sale document type.
path: Spro->Sales and Distribution->Sales->Sales Documents->Sales Document Header->Define Sales Document Types
TCODE: VOV8

/wp-content/uploads/2013/01/num_range_171812.jpg

Third Step:
modify the source code to control use different number range for different sale organiztion
3.1 you can use se38 to open source code MV45AFZZ and find the form userexit_number_range.
*———————————————————————*
*       FORM USEREXIT_NUMBER_RANGE                                    *
*———————————————————————*
*       This userexit can be used to determine the numberranges for   *
*       the internal document number.                                 *
*                                                                     *
*       US_RANGE_INTERN – internal number range                       *
*                                                                     *
*       This form is called from form BELEG_SICHERN                   *
*                                                                     *
*———————————————————————*
form userexit_number_range using us_range_intern.

* Example: Numer range from TVAK like in standard
* US_RANGE_INTERN = TVAK-NUMKI.

endform.

3.2 change the source code as the following
*———————————————————————*
*       FORM USEREXIT_NUMBER_RANGE                                    *
*———————————————————————*
*       This userexit can be used to determine the numberranges for   *
*       the internal document number.                                 *
*                                                                     *
*       US_RANGE_INTERN – internal number range                       *
*                                                                     *
*       This form is called from form BELEG_SICHERN                   *
*                                                                     *
*———————————————————————*
form userexit_number_range using us_range_intern.

* Example: Numer range from TVAK like in standard
* US_RANGE_INTERN = TVAK-NUMKI.
*{   INSERT         TASK912652                                        1
  IF us_range_intern = ’13’.
    CASE vbak-vkorg.
      WHEN ‘0029’.
        us_range_intern = ’13’.
      WHEN ‘0143’.
        us_range_intern = ’14’.
    ENDCASE.
  ENDIF.
*}   INSERT

endform.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. TW Typewriter

    Jack,

    In the code, are you saying if

    – VKORG = 0029, then the sales order number shall come from number range 13.

    – VKORG = 0143, then the sales order number shall come from number range 14?

    Many thanks for your document!

    (0) 
    1. Jack Wu Post author

      Dear,

      Yes, the 0029 and 0143 use same order type. the order type was set with number range 13. So the code uses difference number range for sale organization according to  sale organization code.

      Thanks.

      (0) 
        1. Malte Klesen

          Dear all,

          to make it more flexible you might use a little add-on customizing table to read the correct number range ID from. In our case, this table uses sales organisation and document type to determine the number range:

             FORM USEREXIT_NUMBER_RANGE USING US_RANGE_INTERN.

            data : lt_zvsteu like zvsteu occurs 50 with header line.

            select single       * from  zvsteu into lt_zvsteu
                 where  vkorg       = vbakvkorg
                 and    vbtyp       = vbakvbtyp
                 and    beart       = vbakauart.

            if sysubrc = 0.
              us_range_intern = lt_zvsteunumki.
            else.
          *  

            endif.
            clear: lt_zvsteu.

          ENDFORM.

          I hope this helps.

          Malte

          (0) 

Leave a Reply