Application Development 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: 

ME51N modify line after save - ME_PROCESS_REQ_CUST

Former Member
0 Kudos

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 REPLIES 10

venkateswaran_k
Active Contributor
0 Kudos

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


michael_kozlowski
Active Contributor
0 Kudos

Hi,

create customer number object with transaction SNRO.

Use FM 'NUMBER_GET_NEXT' to retrieve next unique number.

Br

Michael

Former Member
0 Kudos

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.

0 Kudos

You can do that as well

Create a different object in that function and provide different number range.

0 Kudos

hi, from my understanding. if i have 25 plants do i need to create 25 ranges in snro?

0 Kudos

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

0 Kudos

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

0 Kudos

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?

Former Member
0 Kudos

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.

0 Kudos

Hi,

please check SAP OSS-Note 611175 - ME_PROCESS_REQ_CUST: Documentation