Application Development and Automation 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: 
Read only

blocking negative stock orders...

Former Member
0 Likes
518

Hello,

I have this user exit.......I have fixed quantity for this order process not to exceed 6...if I give 7 or more than that........it should not take and error...message should come....I made this code.....every thing working fine....except this error message and stoping the negative stock........actually in the below problem.......zfreegoods-quantity is 6 (its fixed)..based on that i made this code......

but the problem is when I am calculating <b>v_new qty = v_quantity - it_fg_xvbap-lsmeng</b> if i give more than 6 qty then its a negative quantity......

how to stop this.......my code is below for ur reference....

read table it_zfreegoods with key matnr = it_fg_xvbap-matnr.

if sy-subrc eq 0.

v_mitem1_qty = it_fg_xvbap-kwmeng.

v_quantity = it_zfreegoods-quantity.

clear v_lines.

continue.

endif.

if it_zfreegoods-matnr ne it_fg_xvbap-matnr.

it_fg_xvbap-kwmeng = it_fg_xvbap-kmpmg.

modify it_fg_xvbap.

endif.

v_lines = v_lines + 1.

if it_zfreegoods-zfreemodel eq it_fg_xvbap-matnr.

<b> v_newqty = v_quantity - it_fg_xvbap-lsmeng.</b>

it_fg_xvbap-kwmeng = v_newqty.

modify it_fg_xvbap.

  • if v_mixitem_qty ne it_zfreegoods-quantity.

<b> if v_quantity ne it_zfreegoods-quantity.</b> if fcode eq 'SICH'.

message e020(zsnd) with it_zfreegoods-quantity .

else.

message s020(zsnd) with it_zfreegoods-quantity .

endif.

endif.

endif.

endloop.

xvbap[] = it_fg_xvbap[].

endif. " it_zfreegoods table

Thanks in advance for you valuable advices,,

Madhu.

3 REPLIES 3
Read only

Former Member
0 Likes
491

Hello MAdhu,

Check like this:


if  it_fg_xvbap-lsmeng ge 1.
v_newqty = v_quantity - it_fg_xvbap-lsmeng.
endif.

Regards,

Vasanth

Read only

Former Member
0 Likes
491

Hi,

You have not told what should happen if the it_fg_xvbap-lsmeng values comes more than 6.

It should accept or it should skip that?

You keep a IF statement before that

if it_fg_xvbap-lsmeng < v_quantity.

v_new qty = v_quantity - it_fg_xvbap-lsmeng

endif.

so now it won't calculate or

you can multiply with '-1' when it becomes more than 6 also.

if it_fg_xvbap-lsmeng > v_quantity.

it_fg_xvbap-lsmeng = it_fg_xvbap-lsmeng * -1.

endif.

v_new qty = v_quantity - it_fg_xvbap-lsmeng

regards,

Anji

Read only

0 Likes
491

Hi Anji,

it should not accept if it_fg_xvbap-lsmeng is grater than v_quantity....

v_quantity(base quantity) is fixed as 6 taking from the custom table.....

but if the user enters 7 or more.....it should not accept.....

thanks.