2006 Dec 18 7:49 PM
Hi All,
While creating a Sales Order the user enters the Material Number and quantity and presses the Enter key, I need an user-exit which gets triggered at this moment and checks for the value of Confirmed quantity (VBEP-BMENG)in the schedule lines tab for the material, and if its value is zero, then the "Reason for Rejection" field should be populated with some value.
2006 Dec 19 11:08 AM
2006 Dec 19 6:57 AM
Please try in subroutine: <b>USEREXIT_SAVE_DOCUMENT_PREPARE</b>. I guess it should work...
Kind Regards
Eswar
2006 Dec 19 8:09 AM
Hi Eswar,
The exit u've mentioned gets triggered only when the Save button is clicked however I'm looking for a exit which gets triggered when the Enter key is pressed.
2006 Dec 19 8:20 AM
How about: <b>USEREXIT_CHECK_VBEP</b> of include: MV45AFZB???
Kind Regards
Eswar
2006 Dec 19 7:04 AM
Yes there is an option.
Program : MV54AFZB.
Perform routine : USEREXIT_CHECK_VBAP.
you can put your check here and similarly change the values of reason for rejection.
2006 Dec 19 8:10 AM
Hi Sharath,
The include program u've mentioned doesn't exist
2006 Dec 19 8:29 AM
2006 Dec 19 10:57 AM
Hi Eswar/Sharath,
The user-exit u've mentioned is triggered when the Enter key is pressed however the changes made to the xvbap-abgru field in the user-exit(reason for rejection) are not reflected in the screen. Any ideas?
2006 Dec 19 11:08 AM
2006 Dec 19 11:54 AM
Hi Sharath,
Even the value of VBAP-ABGRU field is getting changed.
2006 Dec 19 2:50 PM
'm facing one more problem, the value of xvbep-bmeng(Confirmed Qunatity) is always zero irrespective of the availability of the stock. Will this user-exit be suitable for my requirement. Here I'm pasting the code that i'm using
IF xvbep[] IS NOT INITIAL.
SORT xvbep BY vbeln
posnr
etenr
edatu.
LOOP AT xvbap INTO r_xvbap.
v_index = sy-tabix.
CLEAR r_xvbep.
READ TABLE xvbep INTO r_xvbep
WITH KEY posnr = r_xvbap-posnr.
IF sy-subrc EQ 0 AND
r_xvbep-bmeng IS INITIAL.
r_xvbap-abgru = 'ZZ'.
MODIFY xvbap FROM r_xvbap. " INDEX v_index.
vbap-abgru = 'ZZ'.
ENDIF. " IF sy-subrc EQ 0 AND
CLEAR v_index.
ENDLOOP. " LOOP AT xvbap INTO r_xvbap.
ENDIF. " IF xvbep[] IS NOT INITIAL.
2006 Dec 20 2:41 AM
Hi Rajesh
If you are using, USEREXIT_CHECK_VBEP compare w.r.t VBEP-BMENG. I guess you will be reaching this for each item.
One more thing for you to notice is, the control comes to this routine twice. Once before the quantity is confirmed and after the quantity is confirmed. So you have to place a logic such that when confirmed qty is initial set the Reason for Rejection and when not initial clear the Reason for Rejection.
For more understanding, i advice you to place a break-point in this routine and observe the changes.
Hope this helps.
Kind Regards
Eswar
2006 Dec 20 6:35 AM
Hi Eswar,
What i've observed is that the user-exit is getting triggered sometimes for 4 times and sometimes for 2 times. When the user-exit is getting triggered for 4 times then the value of vbep-bmeng is populated with the value of confirmed quantity in the 3rd time and when it is getting triggered for 2 times the confirmed quantity is poulated with the correct value in the 2nd time. I don't why it is behaving the way it does. Any idea?
2006 Dec 20 6:55 AM
Irrespective of the number of iterations, if you follow the logic that i have specified in my earlier post. I guess it should solve your problem...
Regards
Eswar
2006 Dec 20 7:02 AM
Hi Eswar,
Ok fine, ur logic says to catch the value of vbep-bmeng after confirmation, the confirmation takes place sometimes for the 3rd time and sometimes for the 2nd time. Assuming that the confirmed quantity is populated in the 2nd time the exit triggered i've used the following logic, can u see anything missing here?
STATICS:
v_count TYPE sy-tabix.
v_count = v_count + 1.
IF xvbep[] IS NOT INITIAL AND
v_count EQ 2.
IF vbep-bmeng IS INITIAL.
vbap-abgru = 'ZZ'.
ENDIF. " IF VBEP-BMENG IS INITIAL.
v_count = 0.
ENDIF. " IF XVBEP[] IS NOT INITIAL...
2006 Dec 20 7:08 AM
You got me wrong...
Please try with below logic...
IF NOT xvbep[] IS INITIAL.
IF VBEP-BMENG IS INITIAL.
VBAP-ABGRU = 'ZZ'.
ELSE.
VBAP-ABGRU = ' '.
ENDIF.
ENDIF.
Hope this resolves your problem...
Kind Regards
Eswar
2006 Dec 20 7:33 AM
Hi Eswar,
ok good, consider the case when the user enters 2 materials and their corresponding quantities and pressed the Enter key then the logic works fine for the first item however for the 2nd item xvbep[] will not be initial and vbep-bmeng will be initial, the confirmed quantity will be populated with its correct value only in the 2nd time(for the 2nd item, 4th time if u consider the 2 items). For this reason i've to use the count variable and therefore it is necessary to know when exactly (whether it is 2nd time or 4th time) the confirmed quantity gets populated.
2006 Dec 20 8:22 AM
Then remove NOT XVBEP[] is initial.
Just...
IF VBEP-BMENG IS INITIAL.
VBAP-ABGRU = 'ZZ'.
ELSE.
VBAP-ABGRU = ' '.
ENDIF.
Kind Regards
Eswar
2006 Dec 20 8:46 AM
Hi Eswar,
Even then it will not work, because the value of <b>VBEP-BMENG</b> will be initial when the user-exit is triggered for the 1st time for the 2nd line item the correct value of confirmed quantity is only populated the 2nd time(sometimes 3rd time) for the 2nd line item. Hope i'm able to drive my point home .
2006 Dec 20 9:20 AM
Please do not presume, try to check the outcome after executing with the logic that i have provided.
Regards
Eswar
2006 Dec 20 1:47 PM
Hi Eswar,
I've tested with the logic provided by you. It doesn't work. For every item reason for rejection(VBAP-ABGRU) is set with the value 'ZZ' irrespective of the confirmed quantity.
2006 Dec 21 5:59 AM
I hope you havent missed the ELSE part of my code...
Kind Regards
Eswar
2006 Dec 21 6:01 AM
2006 Dec 21 6:08 AM
Maybe check with this code...
data: wa_vbap type vbap.
read table vbap into wa_vbap with key vbeln = vbep-vbeln
posnr = vbep-posnr.
check sy-subrc eq 0.
if vbep-bmeng is initial.
wa_vbap-abgru = 'ZZ'
else.
wa_vbap-abgru = ' '.
endif.
modify vbap from vbap transporting abgru where vbeln = wa_vbap-vbeln
and posnr = wa_vbap-posnr.
Regards
Eswar
2006 Dec 21 8:19 AM
Hi Eswar,
I was quite surpised to see the code which reads the structure "vbap" as if it were a table. May be u r referring "xvbap".
2006 Dec 21 8:40 AM
OOOPSSSSS....
Yah you were right.
Check this...
check vbep-posnr = vbap-posnr.
if vbep-bmeng is initial.
vbap-abgru = 'ZZ'.
else.
clear vbap-abgru.
endif.
Regards
Eswar
2006 Dec 26 5:27 PM
why don't you just use userexit_check_vbap or userexit_move_field_to_vbap and check VBAP-KBMENG instead of vbep-bmeng ? if vbap-kbmeng = 0 -> means there are no schedule lines woth confirmed qty and you can set ABGRU to 'ZZ' or wahever reason you need. It's easier to do and it will be more correct as VBEP (xvbep) may contain schedule lines with BMENG = 0.... like 1 line - with requested qty (WMENG >0) but BMENG = 0 and another line with WMENG = 0 but BMENG > 0.
2006 Dec 28 12:01 PM
Hi Eswar,
All these days i'm on vacation, so couldn't reply. Now, I'm using the following code and it works fine for us. Thanks for ur patience with me.
STATICS:
v_count TYPE sy-tabix.
v_count = v_count + 1.
IF xvbep[] IS NOT INITIAL AND
v_count EQ 2.
IF vbep-bmeng IS INITIAL.
vbap-abgru = 'Z2'.
ENDIF. " IF VBEP-BMENG IS INITIAL.
v_count = 0.
ENDIF. " IF XVBEP[] IS NOT INITIAL...
Hi Siarhei,
I'll get back to u, if my code doesn't work, anyways i'll allot points to u.