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: 

Sales order enhancement USEREXIT_PRICING_PREPARE_TKOMK

Jagadish_ac
Explorer
0 Kudos
2,613

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.

10 REPLIES 10

kesavadas_thekkillath
Active Contributor
0 Kudos
676

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

0 Kudos
676

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.

0 Kudos
676

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

0 Kudos
676

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.

0 Kudos
676

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.

0 Kudos
676

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.

0 Kudos
676

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

0 Kudos
676

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.

Ashokv
Explorer
0 Kudos
676

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

Jelena_Perfiljeva
Active Contributor
0 Kudos
676

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.