2010 Jun 29 6:43 AM
Hii ,
I have designed a screen in module pool for end user to make entries in the screen and when he saves the data is saving in standard table and ztable. the main field in the screen is Batch number..from that batch number bag number will be generated. and consumed quantity will be saved in that bag no.Bag number will be generated like first 5 digits of batch number and bag number series of that batch number. for example if batch number is 12345 and already 5 times packing is done for same batch..last bag number in the ztable will be 123450005.so next time when user tries to pack using same batch number the new bag number will be 123450006 for batch 12345.Problem here is when user tries to make enrties in that Tx code and at the same time if another user opens same Tx code to make packing for same batch both of them are getting same bag numbers before saving.
I have called Enqueue and Dequeue FM's but still at a time for same batch user is able to do the packing.now my issue is i want to restrict 2 user to use same batch while packing in that Tx code.
I have written following code for enqueue and dequeue technics
data: B_matnr type mara-matnr,
B_charg type mchb-charg.
data : i_temp type TABLE OF zpackhdr WITH HEADER LINE,
i_temp1 type TABLE OF zpackhdr WITH HEADER LINE.
move : 1110 to WA_BCH-werks,
chk_matnr1 to WA_BCH-matnr,
v_bcharg to WA_BCH-charg,
vgrade to WA_BCH-grade,
new_batch to WA_BCH-bagno,
m_baleno to WA_BCH-baleno,
b_date to WA_BCH-indat.
APPEND wa_bch to i_bch.
clear b_date.
READ TABLE i_bch INTO wa_bch INDEX 1.
B_MATNR = WA_BCH-matnr.
B_CHARG = WA_BCH-bagno.
concatenate B_matnr B_charg into
WA_BCH-objek respecting blanks .
modify I_BCH from WA_BCH index sy-tabix.
CLEAR: B_MATNR,
B_CHARG.
call function 'ENQUEUE_EMMCH1E'
EXPORTING
MODE_MCH1 = 'E'
MANDT = SY-MANDT
MATNR = WA_BCH-MATNR
CHARG = WA_BCH-BAGNO
.
if sy-subrc <> 0.
endif.
call function 'DEQUEUE_EMMCH1E'
EXPORTING
MODE_MCH1 = 'E'
MANDT = SY-MANDT
MATNR = WA_BCH-MATNR
CHARG = WA_BCH-CHARG
Hii ,
I have designed a screen in module pool for end user to make entries in the screen and when he saves the data is saving in standard table and ztable. the main field in the screen is Batch number..from that batch number bag number will be generated. and consumed quantity will be saved in that bag no.Bag number will be generated like first 5 digits of batch number and bag number series of that batch number. for example if batch number is 12345 and already 5 times packing is done for same batch..last bag number in the ztable will be 123450005.so next time when user tries to pack using same batch number the new bag number will be 123450006 for batch 12345.Problem here is when user tries to make enrties in that Tx code and at the same time if another user opens same Tx code to make packing for same batch both of them are getting same bag numbers before saving.
I have called Enqueue and Dequeue FM's but still at a time for same batch user is able to do the packing.now my issue is i want to restrict 2 user to use same batch while packing in that Tx code.
I have written following code for enqueue and dequeue technics
data: B_matnr type mara-matnr,
B_charg type mchb-charg.
data : i_temp type TABLE OF zpackhdr WITH HEADER LINE,
i_temp1 type TABLE OF zpackhdr WITH HEADER LINE.
move : 1110 to WA_BCH-werks,
chk_matnr1 to WA_BCH-matnr,
v_bcharg to WA_BCH-charg,
vgrade to WA_BCH-grade,
new_batch to WA_BCH-bagno,
m_baleno to WA_BCH-baleno,
b_date to WA_BCH-indat.
APPEND wa_bch to i_bch.
clear b_date.
READ TABLE i_bch INTO wa_bch INDEX 1.
B_MATNR = WA_BCH-matnr.
B_CHARG = WA_BCH-bagno.
concatenate B_matnr B_charg into
WA_BCH-objek respecting blanks .
modify I_BCH from WA_BCH index sy-tabix.
CLEAR: B_MATNR,
B_CHARG.
call function 'ENQUEUE_EMMCH1E'
EXPORTING
MODE_MCH1 = 'E'
MANDT = SY-MANDT
MATNR = WA_BCH-MATNR
CHARG = WA_BCH-BAGNO
.
if sy-subrc <> 0.
endif.
call function 'DEQUEUE_EMMCH1E'
EXPORTING
MODE_MCH1 = 'E'
MANDT = SY-MANDT
MATNR = WA_BCH-MATNR
CHARG = WA_BCH-CHARG
2010 Jun 29 9:38 PM
Wouldn't you enqueue the batch, exclusive lock, releasing when user completes? Then when another user tries for the same batch your PBO process should find the enqueued batch number, and hide any buttons or menu choices that allow the batch to be processed....for ease of use, you could also report which user currently has that batch locked in a message. That should prevent two users trying to process the same batch at the same time.
2010 Jun 30 9:46 PM
You need to decide whether you're locking the whole batch or the batch/bag combination. The lock must be applied at the right time and for the right combination. It's really simple, you just need to think it through. You can also try using a [custom number range|http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=50004015].
There should be no need to "disable Txcode", as you're asking. Otherwise the systems like SAP would never exist.
2010 Jul 01 10:22 AM
Hi Jelena,
I have created a new lock for table AFPO as i am taking order and batch number from that table.
so when 2 users are using same order they are getting error message as 'ORDER 1111 IS ALREADY BEING PROCESSED...' but here i want to do one more modification ,that user should get that error message and should come out of the screen.
i have written the command leave program after dequeue function module but its not working.
Regards,
Venkat.
2010 Jul 01 3:26 PM
It seems you're approaching the problem from a wrong end, so to say. The users should not be able to open a document if it's already locked. Take, for example, transaction VA02. On the first screen, the users enter the order #. If it's already locked, there is a message and the users remain on the same screen where they can either change the order #, open the order in display mode or simply wait until the order is available. That's how it should work.
2010 Jul 02 8:20 AM
I do understand what u say...mine is a custom designed screen...when i open that screen i have around 15 input fields in which batch is obligatroy...when i give batch and hit enter all the other fields will be filled automatically picking from the table which are relevant for that batch..for example..material,order etc are picked from table...and bag number field will be generated taking first 5 digits of batch and followed by 0001 if its afirst time entry for that batch....so when a user is opening that screen in 2 different windows and giving details without saving any of the screens...in both screens bag number is generating as 001...and when saving it ..its saving 2 entries with same bag number...so i have created a lock entry for afpo table taking order field...so when a user opens 2 screens with same batch...and giving entries in those 2 screens without saving..he is getting same bag numbers as 001.....now when user saving the first screen and coming to second screen to save...he is gettimg message 'ORDER CURRENTLY BEING PROCESSED'..but after the data gettng saved in first screen,then when he saves the second screen it is getting saved...with same bag numbers as 001.so my issue is here...when he saves first screen and comes to second screen to save it the user should get that error message and should come out of the screen....so that he can make a fresh entry for that batch and bag number will be generated as 002 for that batch...
Regards,
venkat.
2010 Jul 02 3:34 PM
You're assigning the number too early. When the users just enter the screen, it's unknown if they will even save anything. Again, no need to reinvent the bicycle - look at any standard SAP transaction. While a user is working on a document, the number is not assigned (you might see something like $$$$$1 in some transactions). The correct way to assign the number is when the user clicks the save button and when all the pre-save checks have been passed.
Where do you store the bag numbers? If it's some Z table, I wouldn't bother including batch # in the bag # and would make both batch # and bag # the key fields and would just use the standard number range functionality (already mentioned) to assign the bag numbers independently. Then you would have none of these problems.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |