07-22-2009 7:22 AM
hi
my requirement is that a Ztable is been given and in that a field called number range is given RV60AFZZ program , now i need to use the user exit
userexit_number_range to update the system field us_range_intern .
I would like to know the logic which i need to put in the above exit ..
kindly please help me out
07-22-2009 7:44 AM
Hi Shilpa,
First you need to define the number range object for that field using Tcode SNRO and then use the following logic to get sequence number.
*&---------------------------------------------------------------------*
*& Form GET_NEXT_NUMBER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_next_number .
DATA: w_quant LIKE inri-quantity, "dummy
w_code LIKE inri-returncode. "returncode
* To lock the number range object
CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
EXPORTING
object = 'ZLCBGREG'
EXCEPTIONS
foreign_lock = 1
object_not_found = 2
system_failure = 3
OTHERS = 4.
* To raise the exception to the corresponding exception of
* 'NUMBER_RANGE_ENQUEUE'
IF sy-subrc NE 0.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc NE 0
* To get the next number from the object
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = 'Z2'
object = 'ZLCBGREG'
toyear = '2008'
IMPORTING
number = l_lbc_next
quantity = w_quant
returncode = w_code
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.
CLEAR ok_code.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc <> 0
* To unlock the number range object
CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
EXPORTING
object = 'ZLCBGREG'
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
IF sy-subrc NE 0.
CLEAR ok_code.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc NE 0
ENDFORM. " GET_NEXT_NUMBER
Regards,
Raju.
07-22-2009 7:44 AM
Hi Shilpa,
First you need to define the number range object for that field using Tcode SNRO and then use the following logic to get sequence number.
*&---------------------------------------------------------------------*
*& Form GET_NEXT_NUMBER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_next_number .
DATA: w_quant LIKE inri-quantity, "dummy
w_code LIKE inri-returncode. "returncode
* To lock the number range object
CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
EXPORTING
object = 'ZLCBGREG'
EXCEPTIONS
foreign_lock = 1
object_not_found = 2
system_failure = 3
OTHERS = 4.
* To raise the exception to the corresponding exception of
* 'NUMBER_RANGE_ENQUEUE'
IF sy-subrc NE 0.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc NE 0
* To get the next number from the object
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = 'Z2'
object = 'ZLCBGREG'
toyear = '2008'
IMPORTING
number = l_lbc_next
quantity = w_quant
returncode = w_code
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.
CLEAR ok_code.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc <> 0
* To unlock the number range object
CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
EXPORTING
object = 'ZLCBGREG'
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
IF sy-subrc NE 0.
CLEAR ok_code.
MESSAGE e368(00) WITH text-006."'Object is not found'
ENDIF. "IF sy-subrc NE 0
ENDFORM. " GET_NEXT_NUMBER
Regards,
Raju.
07-22-2009 10:32 AM
Hi,
in the USEREXIT_NUMBER_RANGE (include RV60AFZZ) the internal number range specified in the billing type table (TVFK-NUMKI) can be changed.
So in your coding, you must get from the Ztable, the custom number range and, if valued, replace the value US_RANGE_INTERN with the new value determined.
Hereafter an example:
FORM userexit_number_range USING us_range_intern.
data: my_numki type tvfk-numki.
SELECT SINGLE numki INTO my_numki FROM ztable "This is an example
WHERE bukrs EQ vbrk-bukrs "This is an example
AND vkorg EQ vbrk-vkorg "This is an example
AND fkart EQ vbrk-fkart. "This is an example
IF my_numki IS INITIAL.
MESSAGE e333(s1) WITH ....... "Send Error Message?
ENDIF.
us_range_intern = my_numki .
ENDFORM. "USEREXIT_NUMBER_RANGE
Kind Regards.
Andrea