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: 

user exit in VA01(Availability Check)

Former Member
0 Kudos
1,779

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
571

populate VBAP-ABGRU instead of XVBAP.

27 REPLIES 27

Former Member
0 Kudos
571

Please try in subroutine: <b>USEREXIT_SAVE_DOCUMENT_PREPARE</b>. I guess it should work...

Kind Regards

Eswar

0 Kudos
571

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.

0 Kudos
571

How about: <b>USEREXIT_CHECK_VBEP</b> of include: MV45AFZB???

Kind Regards

Eswar

Former Member
0 Kudos
571

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.

0 Kudos
571

Hi Sharath,

The include program u've mentioned doesn't exist

Former Member
0 Kudos
571

Sorry it should be MV45AFZB.

0 Kudos
571

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?

Former Member
0 Kudos
572

populate VBAP-ABGRU instead of XVBAP.

0 Kudos
571

Hi Sharath,

Even the value of VBAP-ABGRU field is getting changed.

0 Kudos
571

'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.

0 Kudos
571

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

0 Kudos
571

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?

0 Kudos
571

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

0 Kudos
571

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...

0 Kudos
571

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

0 Kudos
571

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.

0 Kudos
571

Then remove NOT XVBEP[] is initial.

Just...

   IF VBEP-BMENG IS INITIAL.
      VBAP-ABGRU = 'ZZ'.
   ELSE.
      VBAP-ABGRU = ' '.
   ENDIF.

Kind Regards

Eswar

0 Kudos
571

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 .

0 Kudos
571

Please do not presume, try to check the outcome after executing with the logic that i have provided.

Regards

Eswar

0 Kudos
571

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.

0 Kudos
571

I hope you havent missed the ELSE part of my code...

Kind Regards

Eswar

0 Kudos
571

I didn't miss that.

0 Kudos
571

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

0 Kudos
571

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".

0 Kudos
571

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

Former Member
0 Kudos
571

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.

0 Kudos
571

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.