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: 

Serial Number in SAP Query !!!

former_member795356
Participant
0 Kudos
142

Hi Gurus

How can we add Serial Number in SAP Query? There is a field named Counter which gives Total number of count. But i need numbers to be displayed with each line item.

3 REPLIES 3

rxsalomone
Explorer
0 Kudos
105

Hi MAZ,

What means "Serial Number" for you? please be more specific...

Do you mean a field with unique number across all live of table?

0 Kudos
105

Yes.

rxsalomone
Explorer
0 Kudos
105

OK,

So you need to create a Number Range Object (tr SNRO), this create a object like ZNUM.

then, each time you need insert a new record to table only call this FM:

CALL FUNCTION 'NUMBER_GET_NEXT'
    EXPORTING
      nr_range_nr             = '01'
      object                  = 'ZNUM'
    IMPORTING
      number                  = itab-field
    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.

at this point, ITAB-FIELD contains the next number in the range ZNUM.

I hope this help,

X.S.