Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to Implement Number Ranges in SD ?

former_member258592
Participant
0 Kudos

Hi friends,

My requirement is that Once you create Sales order in VA01, that Sales order number range interval should be different for different Company codes, Sales organization and Document type.

Step 1

for that I have created 1 custom table(ZSD_va01) with 4 fields

1 MANDT

2 Company code

3 Sales org

4 Document type

5 Num_range

and assigning value to above declared field like

Company code    Sales organization   Document type        Num_range

1000                         1000                        OR                         26

Step 2

Created Number range interval in t code  'VN01'

Added  like 

            Num-        From value          To value

               26            4100000             510000

Step 3

Assigned number interval  to  SD document type in 'VOV8'

Sales document type-  'OR'

Sales document Category-  'C'

Number range internal assignment-   '26'

and saved it

Step 4

Open include MV45AFZZ in SE38 editor

and clicked on enhancement then clicked on show implicit enhancement after that created enhancement

Form

User_exit_num_range using number_range_intern

Enhancement 340   Znum_range

Tables: Zsd_va01

                 Select single * from Zsd_va01

                                               where  bukrs =  vbak-bukrs,

                                                          vkorg  = vbak-vkorg

                                                          auart  = vbak-auart

                 if sy -subrc = 0.

                    if not zsd_va01-num_range is initial.

                    us_range_intern = zsd_va01-Num_range.

                 end if.

                 end if.

End enhancement

Endform

finally activate the enhancement,

but my problem is that whenever I am crating a sales order for OR, 1000(sales org) then sales order is creating between interval 41000001 whatever value I assigned above but while I am changing Sales org(3000) in Va01 and try to create another order then order range interval is same 4100002,

for that I checked in SNRO, one object is there, RV_BELEG, this object hold all the number range internal for Document type 'OR'.

Could you guide me, how number range will be change for different sales organization.

Thanks and regards

Sandeep

7 REPLIES 7

Former Member
0 Kudos

Hi

You make sure the range for sales org. 3000 is defined in your table Zsd_va01, if there isn't, the system will use the range assigned to your sales order type in the customizing

Max

0 Kudos

Hi Max

Thank you for your valuable feedback, I have declared 3 record in my zsd_tabel like

Company code     Sales org      Document type      Num_range

1000                       1000                OR                    26    

1000                       2000                OR                    27

1000                       3000                OR                    28

and created number range interval in VN01 for the same num_range like

NO         From                To

26          1100000        1200000

27          1300000        1400000

28          1500000        1600000

and assigned that above same declared number in VOV8  t code for Document type 'OR'.

but same problem whenever I am creating Sales order for above declared sales org with document type 'OR' but its assigning last number range interval 1500000 for all the sales org.

Thank you

Sandeep 

juan_suros
Contributor
0 Kudos

Sandeep,



I don't think it is a good idea to try to do this with a coding solution. I think this is in the configuration area.

There are a couple of steps to do this in system configuration:

1) Document number ranges are assigned to Sales Order document types in transaction VOV8.

  • The document ranges are assigned in the "Number Systems" section of this transaction

2) There is a config option "Assign sales order types permitted for sales areas" that can help you restrict document types by Sales Organization:

  • SPRO -> Sales and Distribution -> Sales -> Sales Documents -> Sales Document Header -> Assign Sales Area to Sales Document Type

0 Kudos

Thank you Juan

I have seen that Tcode whatever you suggested me, but there was a combination of Sales Org, distribution channel and division, but my requirement is quite different like if you will create Sales order for diffrent2 Sales org with same document type(OR). for more details you can see my above conversion with Max.

Thank you

sandeep

0 Kudos

Hi

Your code is right,

I mean if you use the user-exit  userexit_number_range of MV45AFZZ and you transfer the range to parameter us_range_intern, you have done all needs to be done

Max

0 Kudos

Thank you Max,

I knew my code is right but why its not impacting on Standard SAP User_exits, right now problem is that whenever I am creating Sales order for different Sales org with same document type(OR) so its assigning latest number range given in 'Vov8' for document type(OR) instead of different number ranges for different sales org.

could you think any other idea about it ?

Thank you

sandeep

0 Kudos

Hi

It's strange, but I suppose you can try to check what happens by debug, the user-exit is called in the form  BELEG_SICHERN:


if vbak-vbeln is initial.

         da_numki = tvak-numki.

* Userexit

         perform userexit_number_range using da_numki.

* interne Nummernvergabe

         data: da_rc like inri-returncode.

         call function 'NUMBER_GET_NEXT'

           exporting

             nr_range_nr = da_numki

             object      = 'RV_BELEG'

           importing

             returncode  = da_rc

             number      = vbak-vbeln.

         case da_rc.

           when '1'.

             message i532 with da_numki 'RV_BELEG'.

           when '2'.

             message i533 with da_numki 'RV_BELEG'.

         endcase.

       endif.

As you can see, the range is initialized with the range from customizing (TVAK table) and then it can be replaced by user-exit:

the range is not longer changed after the exit

Max