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

auto number generation

Former Member
0 Likes
3,481

hi experts,

I am working with smartforms .I want to generate numbers automatically for each form when it is executed.what shall i do .that number must be unique .

thanks

mani

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
2,246

Hi,

Create a number range object using transaction SNRO and then use the FM

NUMBER_GET_NEXT to get the uniqueue number every time.

Regards,

Sesh

hi experts,

I am working with smartforms .I want to generate numbers automatically for each form when it is executed.what shall i do .that number must be unique .

thanks

mani

7 REPLIES 7
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
2,247

Hi,

Create a number range object using transaction SNRO and then use the FM

NUMBER_GET_NEXT to get the uniqueue number every time.

Regards,

Sesh

Read only

0 Likes
2,246

thasnk u .pls tell me what are the necessary parameters and how to enter value????

Read only

0 Likes
2,246

Hi,

You need to pass the number range object name in "OBJECT" and also the interval in "NR_RANGE_NR" that you create using transaction SNRO.

Also Check this documentation for the FM.

The function module assigns the next free numbers of a number range. A number is assigned as a default if no larger number is demanded in the parameter QUANTITY. If more than one number is demanded and not enough numbers are available up to the interval limit, the numbers are only assigned up to the interval limit. If the last number was assigned, the first interval number is provided again during the next call.

The length of the number depends on the definition of the number range object. However, the length is not determined from the definition when allocating, but is calculated from the length of th from-number of the number range.

All exceptions are created with MESSAGE ... RAISING ... .

Example:

1. Object HUGO, not year-dependent, next free number searched for

DATA: RC LIKE INRI-RETURNCODE,

NUMBER(10) TYPE C.

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING OBJECT = 'HUGO'

NR_RANGE_NR = '01'

IMPORTING RETURNCODE = RC

NUMBER = NUMBER.

CASE RC.

WHEN ' '.

  • everything o.k.

WHEN '1'.

  • the assigned number lies in the critical area.

WHEN '2'.

  • this was the last number, next time the first number

  • will be assigned

ENDCASE.

2. Object EGON, year-dependent, next 5 free numbers for 1992 in company code 0001 searched for.

DATA: RC LIKE INRI-RETURNCODE,

NUMBER(10) TYPE C,

YEAR LIKE INRI-TOYEAR,

QUAN LIKE INRI-QUANTITY.

YEAR = '1992'.

QUAN = 5.

T001-BUKRS = '0001'.

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING OBJECT = 'EGON'

NR_RANGE_NR = '01'

SUBOBJECT = T001-BUKRS

TOYEAR = YEAR

IMPORTING RETURNCODE = RC

QUANTITY = QUAN

NUMBER = NUMBER.

  • the last assigned number is in NUMBER

  • the number of the assigned numbers is in QUANTITY

  • the first free number is calculated from:

  • NUMBER - QUANTITY + 1.

CASE RC.

WHEN ' '.

  • everything o.k.

WHEN '1'.

  • the assigned number lies in the critical area.

WHEN '2'.

  • this was the last number, next time the first number will be assigned

*

WHEN '3'.

  • more numbers are demanded than are available,

  • the number of the assigned numbers is in QUAN.

ENDCASE.

Message was edited by:

Seshatalpasai Madala

Read only

0 Likes
2,246

hi mainkandan,

this smple code for the fm 'NUMBER_GET_NEXT',

data : lv_po(10) type c .

clear: lv_po.

call function 'NUMBER_GET_NEXT'

exporting

nr_range_nr = '01'

object = 'ZPO_APPL'

quantity = '01'

  • SUBOBJECT = ' '

  • TOYEAR = '0000'

  • IGNORE_BUFFER = ' '

importing

number = lv_po

  • QUANTITY =

  • RETURNCODE =

  • EXCEPTIONS

  • INTERVAL_NOT_FOUND = 1

  • NUMBER_RANGE_NOT_INTERN = 2

  • OBJECT_NOT_FOUND = 3

  • QUANTITY_IS_0 = 4

  • QUANTITY_IS_NOT_1 = 5

  • INTERVAL_OVERFLOW = 6

  • BUFFER_OVERFLOW = 7

  • OTHERS = 8

.

  • IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • ENDIF.

before this u should activate your progarm in T.code <b>snro</b> to get next number to your smartform.

that smartform name u can pass into object parameter in the<b> fm.</b>

regards,

seshu.

Read only

Former Member
0 Likes
2,246

create number ranges :

the transaction SNRO. / the Table NRIV.

number ranges are two types :

1 internal : automatically generated

2 external : user has to pass the number manually.

-


points plz (if usefull this information).

Regard's

Raghunath.S

Read only

anversha_s
Active Contributor
0 Likes
2,246

hi,

General - Number Range Generation 
* In the 4.6x environment, SAP have included a number range generation
* program just like those used for Purchase Order, Sales Order etc.
*
* This SAP number range generation is an include program.
*
* INCLUDE ZRANGENO.
*
* Always have to be included in the main program data declaration
*
* data: wnorange like INRI-NRRANGENR,            "number range,
*       wsubobj  like inri-SUBOBJECT,            "sub object
*       wdocno(12).
*
* Steps :-
* 1. Number range Sub Object must be maintain in table ZSGRP
*    You can used transaction SE16 to create a table entries.
* 2. Maintain number range and intervals in transaction code SNUM
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*              <a href="http://www.sap-img.com" TARGET="test_blank">http://www.sap-img.com</a>
*

call function 'NUMBER_RANGE_ENQUEUE'
         exporting
               object              = 'ZOWNNO'   "Create with SNUM
         exceptions
               foreign_lock        = 1
               object_not_found    = 2
               system_failure      = 3
               others              = 4.
  if sy-subrc ne 0.
*   message e086 with 'Lock error' sy-subrc.
  endif.

  call function 'NUMBER_GET_NEXT'
         exporting
               nr_range_nr         = wnorange
               object              = 'ZOWNNO'
               subobject           = wsubobj
         importing
               number                  = wdocno  "Number generated by SAP
         exceptions
               interval_not_found      = 1
               number_range_not_intern = 2
               object_not_found        = 3
               quantity_is_0           = 4
               quantity_is_not_1       = 5
               internal_overflow       = 6
               others                  = 7.
  if sy-subrc ne 0.
*   message e086 with 'Number Range' sy-subrc.
  endif.

  call function 'NUMBER_RANGE_DEQUEUE'
    exporting
      object                 = 'ZOWNNO'.

  if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

Regards

Anversha

Read only

0 Likes
2,246

HI EXPERTS,

pLS TELL ME HOW TO CONFIGURE IN SNRO?IE CREATING AN OBJECT...STEP BY STEP