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

sequential number for records each time the program was run

Former Member
0 Likes
3,369

Hi All,

In my report I am displaying two fields ZSEQNO(Sequential number) and BELNR from table ZDOCNUM. I am fetching ZSEQNO and BELNR from table ZDOCNUM. When I execute the report for company code 2500, I am having the below output:

Sequential No.        Document No.

00011100001           78454445

00011100002           78454687

When I execute the report for the second time for the same company code my output should be as below:

Sequential No.        Document No.

00011100003           78454445

00011100004           78454687

For next run the sequential number should start from 00011100005 and so on. How to achieve this functionality? Please help.

Thanks,

Venkata

Hi All,

In my report I am displaying two fields ZSEQNO(Sequential number) and BELNR from table ZDOCNUM. I am fetching ZSEQNO and BELNR from table ZDOCNUM. When I execute the report for company code 2500, I am having the below output:

Sequential No.        Document No.

00011100001           78454445

00011100002           78454687

When I execute the report for the second time for the same company code my output should be as below:

Sequential No.        Document No.

00011100003           78454445

00011100004           78454687

For next run the sequential number should start from 00011100005 and so on. How to achieve this functionality? Please help.

Thanks,

Venkata

6 REPLIES 6
Read only

hiriyappa_myageri
Participant
2,436

Hi Venkat,

You Can Achieve this Using Number range objects.

Go to T-code SNRO . HERE you can create number objects according requirement. call that same number range object in your loop . and modify your internal you will get different sequence numbers .

when ever you run the report.

for You reference this is code .define number range object in SNRO AND use that in you Loop.

Loop AT.

call function 'NUMBER_GET_NEXT'

         exporting

         nr_range_nr                   = '01'

         object                        = 'ZSEQ'    "Number Range Object Defined in  SNRO

         quantity                      = '1'

*       SUBOBJECT                     = ' '

*       TOYEAR                        = '0000'

         ignore_buffer                 = 'X'

         importing

         number                        = l_number

*       QUANTITY                      =

         returncode                    = ld_error  " Number generated Sequentially

          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.

* Implement suitable error handling here

                 endif.

********pass every time number generated by that L_NUMBER TO ZSEQUENCE AND MODIFY you internel table .*******

endloop.

Regards,

Hiriyappa.

Read only

Former Member
0 Likes
2,436

Hello

This can be done by using the no. range object, you need to create a no. range object using t code SNRO and provide a starting range of  00011100001(numc11) and interval 99999999999(Numc11)..

Here is one document which can help you for better understanding..

document link...

Read only

0 Likes
2,436

Hi Chandra Sekhar,

I tried to create number range as in the document. When creating a number range for field ZBELNR(data element ZBELNR) having domain CHAR20 and after clicking on save it is showing me the message as "Domain CHAR20 of data element ZBELNR does not have a value table" . Can we create number range for custom fields and custom domains. Please help me.

Thanks,

Venkata

Read only

0 Likes
2,434

Try using help from Snap shot and now save it..

Try this..

Read only

venkat_aileni
Contributor
0 Likes
2,434

Hi-

Another approach would be adding an additional field (or even fields) in your 'ZDOCNUM' TABLE which indicates whether those documents have considered previously.

Field can be like : ZPROGRAM_RUN type C, set this field value to 'X' every time you run your report. If you want more specific details then you can think of adding date and time fields too.

-Venkat

Read only

sivaganesh_krishnan
Contributor
0 Likes
2,434

Hi venkata,

You can use the concept called Number range in your program,this number range will create numbers automatically when ever you call NUMBER_GET_NEXT by passing the number range object along with it.

Check the following link , this will give u a definite solution to you.

How to Create you own Number Range  SNRO - ABAP Development - SCN Wiki

Regards,

Sivaganesh