SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Number Range Generation



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Wed Oct 24, 2007 8:53 pm    Post subject: Number Range Generation Reply with quote

Tables used for ranges:
NRIV Number range intervals. Note: Field NRLEVEL Contains the last assigned number.
TNRO Definition of number range objects
Ranges are maintained in transaction SNRO

Q:
Just another chance to show my ignorance. Isn’t there a function for returning a unique key and isn’t there also a configuration method for describing the range of those objects. I know that there is something like that for EDI but I can’t identify it. I need to retrieve a key for a user defined field in IS-U CCS 1.2 for sap 4.0B.

A:
You can use a range object . You define ranges in transaction SNRO. The number in the ranges automatically increment ebvery time you use a new number.

Use the function NUMBER_GET_NEXT to get the next number in the range:
Code:

CALL FUNCTION ‘NUMBER_GET_NEXT’
  exporting
    nr_range_nr= ‘01’
    object= ‘ZCOSTA’
    quantity= ‘1’
  importing
    number= i_zcostafstm-zafstemnr
    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
    others = 7.


Example finding an accounting document number:
Code:

CALL FUNCTION ‘NUMBER_GET_NEXT’
  EXPORTING nr_range_nr = p_blart “Document type object = ‘RF_BELEG’
    QUANTITY = ‘1’
    SUBOBJECT = p_bukrs “Comapny (Comapny dependent range)
    TOYEAR = ‘2001’
    IGNORE_BUFFER = ’ ’
  IMPORTING
    number = p_belnr “Returned document 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
    OTHERS = 7


Code:
* 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
*              http://www.sap-img.com
*

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.