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: 

VA02 USEREXIT_SAVE_DOCUMENT_PREPARE

Former Member
0 Kudos

Hi All,

I am working on FORM USEREXIT_FIELD_MODIFICATION.my requirement is that when user uses VA02 to change a sale order and suppose he forget to fill the entry in "Tax classification" it should show an error.I have added following enhancement code   in the user exit 'MV45AFZZ' .now its working.

ENHANCEMENT 313  OIU_LO_SAPMV45A.    "inactive version

if sy-tcode = 'VA02' .

    IF  VBAP-TAXM1 = ' ' '.

       MESSAGE ' Enter Tax classifc ..... ' type 'E'.

    ENDIF.

endif.


But m facing one problem now.suppose I enter tcode VA02.Fill the order no. and press enter.It shows sale order now if i select a line item press SAVE button directly  without making any chages it showing the same error.Can anyone help me with this problem.

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

in your code, instead of checking values in VBAP, check values in XVBAP as below

if sy-tcode = 'VA02' .

loop     at  xvbap.

    IF  XVBAP-TAXM1 = ' ' '.

       MESSAGE ' Enter Tax classifc ..... ' type 'E'.

    ENDIF.

endloop.

endif.


Its becuse XVBAP contains the data.


-Regards

Rohit

9 REPLIES 9

AnoopMayamkote
Participant
0 Kudos

Go to program MV45AFZZ, check tables XVBUK,XVBUP & YVBUK,YVBUP, there you can view the old values and new values of overall status changes. I hope it may work out . debug with both the scenario

0 Kudos

Hello anoop,

                   Actually the problem is not with the values.Its with the coding.Tcode gives correct error message if i make  "Tax classification" field empty its showing error and after filling it program saved.

problem is that whenever i open new sale order click on any line item and click SAVE it shows the same error.which is not supposed to give because I didnt make any changes in "Tax classification".It should save the sale order without showing error.

Thanks for reply

Former Member
0 Kudos

Hi,

in your code, instead of checking values in VBAP, check values in XVBAP as below

if sy-tcode = 'VA02' .

loop     at  xvbap.

    IF  XVBAP-TAXM1 = ' ' '.

       MESSAGE ' Enter Tax classifc ..... ' type 'E'.

    ENDIF.

endloop.

endif.


Its becuse XVBAP contains the data.


-Regards

Rohit

shashi_thakur
Contributor
0 Kudos

Hi Sam,

Your code should ideally be a LOOP on XVBAP structure and each line item should be checked for the taxm1.

Also, do you want the message to be triggered only when  the user changes something in the line item?. Then what happens in the scenario where they do not change anything but taxm1 is still empty-is that supposed to be okay?.

If that is indeed the case, the use the updkz indicator value in the loop to decide which line item to check and which to not check. The updkz will be blank when user has not made any changes to the line item.

Regards,

Shashi Thakur

0 Kudos

Hi,

I am not wrong;

your requirement is if TAXM1 is missing then it should prompt error to user on changed data then follow below.

See, we have 2 table XVBAP and YVBAP, XVBAP contains the latest data and YVBAP contains the old data.

You can check the records with these to tables if you get any changed record then trigger your message.

or

If you want to give error on all the items where TAXM1 is missing, just follow loop.

-Regards

Rohit

0 Kudos

sorry *if I am not wrong

0 Kudos

Hi Rohit,

Agree with what you say.

Regards,

Shashi Thakur

Former Member
0 Kudos

Hi all,

        Thanks all for your help.Rohit i m sorry you were right.Problem solved.

0 Kudos

Please close the thread, and reward point if your query is solved.

-Regards

Rohit