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 No increment

Former Member
0 Kudos

Dear SAP Guru's,

I created one table having key fields are mandt,sr_no,werks.My question is that when i create new entry in table it will check the client & plant and automatically take increase sr_no by 1. Is it possible

Thanks & Regards

Atul Singh

2 REPLIES 2

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

You have to create maintenace view and implement the logic for auto increment in the Event "on_save"to achieve the same.

bbalci
Contributor
0 Kudos

Hi Atulks

First create a maintenance screen for your table,

Go to transaction se55, specify your table table , click on "Generated Objects" and click Change/Create

it will move you to your maintenance screen dialog.

Now click on menu item Environment > Modification > Events

you will see the events table , just click "new entries"

You want to set a new number for your new records,

than u should use event "05 Creating a new entry" and specify a form name for it here.

Now go to your function group ( that you have used for creating table maintenance )

and create that form in that function group. ( You can use a Z include etc. )

Now when user creates new entries, your maintenance screen will call this subroutine

you can set values for fields in that subroutine.

my table and field name was : zxss_table / number :

Here is my subroutine example :

FORM zxss_table_event_05.

DATA nr_object TYPE inri-object VALUE 'ZSD_XSS1.

IF zxss_table-number IS INITIAL.

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

nr_range_nr = '00'

object = nr_object

  • QUANTITY = '1'

  • SUBOBJECT = ' '

  • TOYEAR = '0000'

  • IGNORE_BUFFER = ' '

IMPORTING

number = zxss_table-number

  • 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.

ENDIF.

ENDIF.

ENDFORM.

I hope it helps.

Bulent

Edited by: Bulent Balci on Jul 9, 2010 1:10 PM