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

va01-netwr control

Former Member
0 Likes
1,847

I want to control "amount " field of item of va01.

if amount >10000 , I'll give a error message according to item of va01.

I used mv45afzz and userexit_pricing_prepare_tkomp

But vbap-netwr doesn't change.it has same value.

how can I control this field.

I want to control "amount " field of item of va01.

if amount >10000 , I'll give a error message according to item of va01.

I used mv45afzz and userexit_pricing_prepare_tkomp

But vbap-netwr doesn't change.it has same value.

how can I control this field.

8 REPLIES 8
Read only

Former Member
0 Likes
1,514

Hi,

try using exits like userexit_move_field_to_vbak / userexit_save_document_prepare in MV45AFZZ.

Thanks,

Sam.

Read only

0 Likes
1,514

hi,

One doubt. if you are giving error message, then why do you have to change the value for vbap-netwr. you just have to compare the value and then throw an error message with type 'E' rite.. ??

Read only

Former Member
0 Likes
1,514

if you're looking for an item/amount that changed, in much of MV45AFZZ, the changed item will be in XVBAP, the old version of the item YVBAP. At least that's how SD was done when I was writing code for SD exits. XVBAP-UPDKZ will indicate Insert, Update or Delete for each XVBAP row. In a subroutine that pertains to VBAP, you could do something like:

loop at XVBAP where UPDKZ eq 'I' or updkz eq 'U'.
  read table YVBAP with key posnr = xvbap-posnr.
   if sy-subrc ne 0.  " this is an insert...new item
      if Xvbap-netwr > 1000.
 * error message.
   endif.
elseif XVBAP-NETWR > YVBAP-netwr and
          XVBAP-NETWR > 1000.  "this is an update with a price increase...
*error message.
endif.
endloop.

Edited by: DaveL on Aug 11, 2011 9:20 PM

Read only

Former Member
0 Likes
1,514

My code is like this;

in MV45AFZZ

form userexit_pricing_prepare_tkomp.

if xvbap-PSTYV = 'ZS01'.

if xvbap-netwr > '10000'.

message 'Bir seferde 10.000 den fazla tutar giremessiniz.'

type 'E'.

endif.

endif.

endform.

But xvbap-netwr doens't change,same so I can't see new value and I can't compare with 10000

Read only

0 Likes
1,514

Perhaps it's the wrong point...at this point, SAP is moving values to the communications structure for pricing. I would try to do at save_document_prepare, which is for data value checks, etc. Here in VA02, by comparing XVBAP to YVBAP items, you can detect which items have been updated, deleted or inserted before SAVE was pressed. In VA01, just check for your VBAP-NETWR value.

Edited by: DaveL on Aug 12, 2011 6:40 PM

Read only

0 Likes
1,514

try using exits like userexit_move_field_to_vbak / userexit_save_document_prepare in MV45AFZZ.. there are other exit points where you can update this info. userexit_save_document, which is another point you can check. but this one will be called only when you save something. when values in screens are changed, this exit is not called i believe. need to check in debugging mode.

Thanks,

Sam.

Read only

0 Likes
1,514

Beware! Do NOT use DOCUMENT_SAVE to do anything except fire off additional processes, etc. Nothing you change in DOCUMENT_SAVE will be useful....it's the wrong place to check values.

VBAK exits are not the place to manipulate item level values, IMHO...that's header structure at that point.

SAVE_DOCUMENT_PREPARE is fired after save...read the comments in MV45AFZZ. If you can't make your mods or issue your message before document save exit, it's too late and you can't do what is needed.

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
1,514

userexit_pricing_prepare_tkomp is initiated before pricing takes place. It is used to influence the result of the pricing. Naturally, Net Value (NETWR), which is the result of the pricing, cannot possibly be already filled in in that user exit.

I'd check user exit ...CHECK_VBAP and, if it's not triggered at the right time, then SAVE_DOCUMENT_PREPARE. The last one is triggered only on save but, unfortunately, sometimes data is just not available at the right time in the right place.

It also seems that you're trying to impose some kind of a limit on how large of an order item could be placed. You might want to check with the SD functional analyst - maybe there is a better option. Besides, if you're checking at the line item, what's preventing the users from placing multiple line items with smaller amount? I'd understand if the total net value of the order was checked, but this limit just doesn't make much sense to me...