2008 Jun 30 11:50 AM
Hi,
I have a Z table, it has a component serial no.
My requirement is to auto generate a serial no. when a record is inserted.
Please help me solve the problem.
Thanks.
Sai.
Hi,
I have a Z table, it has a component serial no.
My requirement is to auto generate a serial no. when a record is inserted.
Please help me solve the problem.
Thanks.
Sai.
2008 Jun 30 11:53 AM
YOu have to create a number range for your Z table:
http://help.sap.com/saphelp_nw04/helpdata/en/b4/185f28179c4f3cb8d00988cd139500/frameset.htm
YOu have to use the function module:
NUMBER_GET_NEXT to get the next free number in your number range.
Regards,
ravi
2008 Jun 30 11:53 AM
Hi...
Before using the insert statement,
read the last record , u ll get the current value of the field and add 1 to it.
I hope this ll be simple 2 line code.
Thanks & Regards
vinsee
2008 Jun 30 11:53 AM
from where ll u insert the record, se11 or u ll code some thiing
if u code then it is very simple.send me the further information.
2008 Jun 30 11:53 AM
Hi,
Define a number range object using tcode "SNUM" for data element serial no. and generate next number using function module "NUMBER_GET_NEXT" passing object no.
2008 Jun 30 11:54 AM
Hi Sai,
Chk this link..
[https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/table%2bmaintenance%2bin%2babap]
Reward If helpful.
Regards,
Sachin M M
2008 Jun 30 12:01 PM
Hi,
Thanks for your help, I am inserting records into Z table from an alv grid. I this is done when the user performs save.
Which is the best way to handle this sutation.
Thanks.
Sai.
2008 Jun 30 12:12 PM
Hi Mohan Das,
The function module you have to use is Number_get_next.
Check out the sample implementation of that Function module..
DATA:
NUMBER TYPE I.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = 'ZDEMO'
IMPORTING
NUMBER = NUMBER
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.
Write :/ 'Next available number is: ', Number.
Before doing the above process check in SNUM transaction whether the number range has buffering or not.
so, if you do not want to have any gaps on your range, on transaction SNUM , from the menu choose "Edit -> Set-up buffering":
1 - no buffering (with this you will have gaps on your range)
2 - main memory (no gaps on your range)
On both you have to consider your "update methods".
Hope this would help you.
Regards
Narin Nandivada.
Edited by: Narin Nandivada on Jun 30, 2008 4:44 PM
2008 Jun 30 12:56 PM
Hi,
Create a Number range using the Transaction SNRO.
By doing this you can create a number range object
NUMBER_GET_INFO
Number range: Provides information for a number range number
Regards,
VIjay
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |