10-14-2015 10:50 AM
Hi Experts,
I have a requirement to save a unique number in tracking number(bednr) after saving ME51N(PR CRATE)
I have done it using ME_PROCESS_REQ_CUST and method PROCESS_ITEM but not after save. My problem here is if there are 2 or more users who are creating PR at the same time BEDNR(tracking number) which is supposed to be unique will be duplicated..
I need to automatically update BEDNR after save so that I will prevent duplicate BEDNR.
How can I do that ?
Thanks.
Here is my code.
data : l_item type mereq_item,
l_itemx type mereq_itemx,
s_item type mereq_item,
s_itemx type mereq_itemx,
lv_werks type eban-werks,
lv_bednr type eban-bednr,
lv_bednrlast type eban-bednr.
CALL METHOD im_item->get_data
receiving
re_data = l_item.
CALL METHOD im_item->get_datax
receiving
re_datax = l_itemx.
CLEAR: lv_bednrlast, lv_werks.
lv_werks = l_item-werks.
SELECT SINGLE MAX( bednr )
INTO lv_bednrlast
FROM eban
WHERE werks EQ lv_werks.
IF sy-subrc NE 0.
CONCATENATE lv_werks '000001' INTO lv_bednr.
ELSE.
IF lv_bednrlast = ''.
CONCATENATE lv_werks '000001' INTO lv_bednr.
ELSE.
lv_bednrlast = lv_bednrlast + 1.
lv_bednr = lv_bednrlast.
ENDIF.
ENDIF.
l_item-bednr = lv_bednr."'1002'.
l_itemx-bednr = 'X'.
call method im_item->set_data( l_item ).
10-14-2015 11:02 AM
Hi
Please do not use
SELECT SINGLE MAX( bednr )
INTO lv_bednrlast
FROM eban
WHERE werks EQ lv_werks.
This will have a chance of duplicate where users updating at same time.
Try to use a number generation FM in that place.
CALL FUNCTION 'NUMBER_GET_NEXT'
Regards,
Venkat
10-14-2015 11:09 AM
Hi,
create customer number object with transaction SNRO.
Use FM 'NUMBER_GET_NEXT' to retrieve next unique number.
Br
Michael
10-14-2015 1:59 PM
Hi, thanks for the reply.
I was thinking of using that fm but I need to have a new set of ranges for every plant.
bednr = plant +incnum.
example: 1714 have 1714000001 ...
1717 have 171700001.. every plant should start with plantcode plus incremented number..
every plant should start with 00001.
10-14-2015 2:04 PM
You can do that as well
Create a different object in that function and provide different number range.
10-14-2015 2:28 PM
hi, from my understanding. if i have 25 plants do i need to create 25 ranges in snro?
10-14-2015 2:30 PM
Hi,
simply create different number ranges in SNRO for that object and provide in FM NUMBER_GET_NEXT Exporting parameter "nr_range_nr" the particular range.
Br
Michael
10-14-2015 2:39 PM
Yes, You need to...
Set up a different number ranges in the same SRNO
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '1' "Plant seq goes here
object = 'PLANT'
I hope adding a new plant is not a frequent action at your end.
Regards,
Venkat
10-16-2015 2:20 AM
Hi,
Is it possible to update line item during save? Right now Im using Process Item to enter the number.
But is it possible to update it with method POST?
10-16-2015 6:05 AM
Is it possible to do this in method POST and not in PROCESS_ITEM ?
I have put this in method POST.
CALL METHOD lv_if_item->set_data( ls_itm_data ).
CALL METHOD lv_if_item->set_datax( ls_itm_datax ).
But its not updating table eban.
10-16-2015 8:31 AM
Hi,
please check SAP OSS-Note 611175 - ME_PROCESS_REQ_CUST: Documentation