2016 Jul 14 10:11 AM
Hi Experts,
I have a requirement to Compare Sales order line item entered Net price(NETPR) with one of the Condition value 'VPRS' (KOMV-KSCHL) based on KPOSN.
I have enhanced the User exit USEREXIT_PRICING_PREPARE_TKOMK and written code in MV45AFZZ with error message.
it will through an error message if user enters the wrong amount but it is not allowing to change.
will it be the right enhancement Point?
FIELD-SYMBOLS : <fs_komv> LIKE LINE OF xkomv.
DATA wa_xvbap1 LIKE LINE OF xvbap.
DATA wa_xkomv LIKE LINE OF xkomv.
DATA lw_nprs(20).DATA lw_vprs(20). data lw_posnr(20).
LOOP AT XKOMV ASSIGNING <fs_komv> WHERE KSCHL = 'VPRS'.
READ TABLE xvbap INTO wa_xvbap1 WITH KEY posnr = <fs_komv>-kposn.
IF sy-subrc = 0 AND wa_xvbap1-matnr IS NOT INITIAL.
if <fs_komv>-KBETR gt wa_xvbap1-netwr.
WRITE wa_xvbap1-netwr TO lw_nprs CURRENCY vbak-waerk.
WRITE <fs_komv>-KBETR TO lw_vprs CURRENCY vbak-waerk.
write <fs_komv>-kposn to lw_posnr.
CONDENSE : lw_netwr,lw_sum,lw_posnr.
CONCATENATE lw_nprs 'line item' lw_posnr INTO lw_nprs SEPARATED BY space.
MESSAGE e000(Zsd_msg) WITH 'Internal Price' lw_vprs 'greater than Net Price :' lw_nprs.
endif.
endif.
ENDLOOP.
Please help with solution.
2016 Jul 14 1:17 PM
Hi,
Just give a try with USEREXIT_CHECK_VBAP in include MV45AFZB. I am not sure if you will be able to access the condition details here.
Also, USEREXIT_SAVE_DOCUMENT_PREPARE , in include MV45AFZZ can be used for checking before save ( as per sap help :Use this user exit to make certain changes or checks immediately before saving a document. It is the last possibility for changing or checking a document before posting.)
2016 Jul 14 2:52 PM
Hi Kesav
user Exit USEREXIT_CHECK_VBAP is not solving problem. it worked only in VA02 one line item. while entering second line item it was throwing error with first line value and not able to edit the line.
VA01 is not allowing to save even single. XVBAP-NETPR is taking value as 0.0.
I think we have to find some different User exit.
Even in USEREXIT_SAVE_PREPARE also not working after throwing error it is not allowing to edit sales order.
2016 Jul 15 10:02 AM
Hello Jagadish,
USEREXIT_CHECK_VBAP can be used for validating each and every fields of item(s). I was not sure if the condition details were accessible there, but from your response I see it can be accessed.
I have not faced any disabling issues when raising error messages here, I guess you are doing some thing wrong.
Could you please me more clear about the issue you are facing in using USEREXIT_CHECK_VBAP
Regards
Kesav
2016 Jul 18 5:28 AM
Hi Keshav.
Thanks for your Response.
I have captured sales order error screen in attached document. Please refer.
It is working fine in VA02 but it is not working in VA01.
when Enter first line item it is comparing with net price 0.0.
Thanks
Regards
Jagadish
*Condition Pricing check with netprice.
*********<<< start of AFDK902632
FIELD-SYMBOLS : <fs_komv1> LIKE LINE OF xkomv,
<fs_vbap1> like line of Xvbap.
DATA wa_xvbap1 LIKE LINE OF xvbap.
DATA wa_xkomv1 LIKE LINE OF xkomv.
DATA lw_nprs(20).DATA lw_vprs(20). data lw_posnr(20).
data lv_msg(100).
Loop at xvbap ASSIGNING <fs_vbap1>.
read table Xkomv into wa_xkomv1 with key kposn = <fs_vbap1>-posnr
kschl = 'VPRS'.
if sy-subrc is INITIAL.
if <fs_vbap1>-netpr LT wa_xkomv1-KBETR.
WRITE <fs_vbap1>-netpr TO lw_nprs CURRENCY vbak-waerk.
WRITE wa_xkomv1-KBETR TO lw_vprs CURRENCY vbak-waerk.
write wa_xkomv1-kposn to lw_posnr.
CONDENSE : lw_nprs,lw_vprs,lw_posnr.
CONCATENATE 'Internal Price' lw_vprs 'greater than Net Price :' lw_nprs 'line item' lw_posnr INTO lv_msg SEPARATED BY space.
* MESSAGE 000(Zsd_msg) WITH 'Internal Price' lw_vprs 'greater than Net Price :' lw_nprs.
MESSAGE lv_msg TYPE 'E' DISPLAY LIKE 'W'.
endif.
endif.
ENDLOOP.
2016 Jul 18 6:11 AM
Try out some thing like this. You need not loop xvbap in this routine, for new items posnr will be initial ( based on your post )
if vbap-posnr is not initial.
read table xkomv into wa_xkomv with key kposn = vbap-posnr
kschl = 'VPRS'.
if sy-subrc = 0 and vbap-netpr < wa_xkomv-kbetr.
WRITE vbap-netpr TO lw_nprs CURRENCY vbak-waerk.
WRITE wa_xkomv1-KBETR TO lw_vprs CURRENCY vbak-waerk.
write wa_xkomv1-kposn to lw_posnr.
CONDENSE : lw_nprs,lw_vprs,lw_posnr.
CONCATENATE 'Internal Price' lw_vprs 'greater than Net Price :' lw_nprs 'line item' lw_posnr INTO lv_msg SEPARATED BY space.
MESSAGE lv_msg TYPE 'E'.
endif.
endif.
2016 Jul 18 6:25 AM
HI Keshav
Thanks,
I changed as your code but in VA01, after throwing error message it is not allowing to edit amount filed.
This time it is comparing with some other value instead of 0.0.
I have entered in screen 1000 but it comparing with 1300.
please find below image.
2016 Jul 18 7:59 AM
Hello,
I haven't faced such disabling issues in this routine, it was for different fields in my case. I am lost of ideas here. Wait for somebody to respond, If no enhancements work for you, then opt for implicit enhancement as a last resort.
Kesav
2016 Jul 18 9:57 AM
Thanks,
But when I enter second line item the value in VBAP-NETPR is taking some different value instead of screen line item value.
in that time XVBAP-NETPR is empty.
2016 Jul 18 11:31 AM
Hi,
You can try incompletion log by setting this field in Tr OVA2 and then passing error/message in XVBUV in USEREXIT_CHECK_VBAP of MV45AFZB.
Thanks,
Ashok
2016 Jul 19 10:54 PM
There is a good document on SCN on how to implement the minimum price check, you might want to discuss this alternative with the SD consultant:
Don't recall any issues with displaying error messages in USEREXIT_CHECK_VBAP or USEREXIT_SAVE_PREPARE, but then I never used DISPLAY AS 'W' for the error messages. There were some SCN posts though on the fields not editable after a message in some scenarios. Make sure to search in Google.