Application Development and Automation 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: 
Read only

number ranges

Former Member
0 Likes
1,442

Hi Experts,

I need some help on user exits for number ranges. In the implementation project I am doing, my functional consultant gave me a requirement in which the number ranges are fixed and documents are saved with the number ranges specified.

i.e. for sales organizaton 1000 : 1000000001 to 1000099999 for t.code vf01

2000 : 2000000001 to 200099999 for t.code vf01

i.e. for sales organizaton 1000 : 3000000001 to 3000099999 for t.code vlo1n

2000 : 4000000001 to 400099999 for t.code vl01n etc.

My functional consultant suggested me to use User Exit : USEREXIT_NUMBER_RANGE

Program : MV45AFZZ

T-code for Number Range Code : OVZC

I don't know how to use it. Can anybody please help me by telling how to use it.

Thanks and regards,

M.Madhusudan Rao.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,387

Hi Friend,

In that include (like MV45AFZZ for sales order, MV50AFZ1 for delivery, ) you will get one subroutine USEREXIT_NUMBER_RANGE.

There code according to your requirement and pass correct number range no to US_RANGE_INTERN parameter.

(ex: supposee number range no can be 01, 02 or Z1 for range 100000 to 199999).

Hope it will help you.

Regards

Krishnendu

Hi Friend,

In that include (like MV45AFZZ for sales order, MV50AFZ1 for delivery, ) you will get one subroutine USEREXIT_NUMBER_RANGE.

There code according to your requirement and pass correct number range no to US_RANGE_INTERN parameter.

(ex: supposee number range no can be 01, 02 or Z1 for range 100000 to 199999).

Hope it will help you.

Regards

Krishnendu

6 REPLIES 6
Read only

Former Member
0 Likes
1,388

Hi Friend,

In that include (like MV45AFZZ for sales order, MV50AFZ1 for delivery, ) you will get one subroutine USEREXIT_NUMBER_RANGE.

There code according to your requirement and pass correct number range no to US_RANGE_INTERN parameter.

(ex: supposee number range no can be 01, 02 or Z1 for range 100000 to 199999).

Hope it will help you.

Regards

Krishnendu

Read only

0 Likes
1,387

Hi Krishnendu Laha,

Thanks for your suggestion. Your reply was sure shot. It worked out for me. But for writing the code in subourtines userexit_number_range, I had to use object access key from the basis guy. Any how it worked, but I just wanted to know whether using of object access key was appropriate or not?. Is there any way by which we can write the code in future without using access key?.

Thanks and regards,

M.Madhusudan Rao.

Read only

0 Likes
1,387

hi madhu sudan,

This is bhanu.i also got the same requirement as u got.i need to write a code to generate a sales order number range baseed on sales organization given for the sales order for the same document type.could u send me that code.thanks in advance.bye...........

Read only

0 Likes
1,387

Hi Madhusudan

Regarding your query; "Could I have changed to code wothout the access key"; the answer is 'Yes'.

There are enhancement options available in the code. They can be at predefined places in the code (Implicit) or can be created by you (Explicit).

It is a simple way to enhance the SAP code; wherein your changes are attached to a package (...transport) and are not overwritten during upgrade.

Just go through the "Source Code Enhancement" section in the following article:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/bb54c452-0801-0010-0e84-a653307f...

Regards

Neeraj

Read only

0 Likes
1,387

HI Bhanu,

The following is the code which I wrote for Delivery Order number. This is working satisfactorily for my functional consultant.

FORM USEREXIT_NUMBER_RANGE USING US_RANGE_INTERN.

  • Example: Numer range from TVLK like in standard

  • US_RANGE_INTERN = TVLK-NUMKI.

*{ INSERT ED6K900416 1

  • Custom Number Range for Delivery Order :: Madhu : 07082008

case likp-vkorg.

when '2001'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AA'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'BZ'.

endif.

when '2002'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AB'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CA'.

endif.

when '2003'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AC'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CB'.

endif.

when '2004'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AD'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CC'.

endif.

when '2005'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AE'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CD'.

endif.

when '2006'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AF'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CE'.

endif.

when '2007'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AG'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CF'.

endif.

when '2008'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AH'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CG'.

endif.

when '2009'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AI'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CH'.

endif.

when '2010'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AJ'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CI'.

endif.

when '2012'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AK'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CJ'.

endif.

when '2013'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AL'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CK'.

endif.

when '2014'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AM'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CL'.

endif.

when '2015'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AN'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CM'.

endif.

when '2016'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AO'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CN'.

endif.

when '2017'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AP'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CO'.

endif.

when '2018'.

if ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LO' or tvlk-lfart eq 'LF' or tvlk-lfart eq 'ZLF' ).

us_range_intern = 'AQ'.

elseif ( sy-tcode eq 'VL01N' OR sy-tcode eq 'VL01NO' ) AND ( tvlk-lfart eq 'LR' ).

us_range_intern = 'CP'.

endif.

when others.

" do nothing

endcase.

*} INSERT

ENDFORM.

Regards,

M.Madhusudan Rao.

Read only

Former Member
0 Likes
1,387

Hi Friend,

You have to take Access key to write code in those subroutines. There is no harm on that.

Cheers!

Krishnendu