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

Restrict Save after error message

narendar_naidu
Active Participant
0 Likes
5,021

Dear All,

i am displaying an error message in VA41 and VA42 using a Pricing routine.

After error display i want the user to correct the entries and process the Contract for Save.

I am displaying the error  and fields become non editable and  When i press ENTER twice i am able make the fields editable.

My concern is  when i Press 'SAVE' i am able to restrict the contract for SAVE ,but the fields become grayed (non-editable).

And when i press 'ENTER'  more than twice after the 'SAVE'  the contract gets saved automatically.

if xkwert GT gd_var----(this is my condition) .
   MESSAGE 'The Difference is Greater than 50' TYPE 'W' DISPLAY LIKE 'E'.

-------For restricting the save.

   if sy-ucomm  = 'SICH' "function code for Save.

    set SCREEN sy-dynnr.

   exit.

endif.

endif.

have gone thru all the relevant posts but could not solve my issue.

regards,

14 REPLIES 14
Read only

mdruhul_amin
Explorer
0 Likes
2,892

Hi Naren,

Please use like this

MESSAGE 'The Difference is Greater than 50' TYPE 'S' DISPLAY LIKE 'E'.

leave to screen sy-dnnr.

I think it can solve your problrm.

Regards,

Ruhul


Read only

arindam_m
Active Contributor
0 Likes
2,892

Hi,

MESSAGE 'The Difference is Greater than 50' TYPE 'I' DISPLAY LIKE 'E'.

This should work.

Cheers,

Arindam

Read only

0 Likes
2,892

Hi,

Only when you use a message of type "E", no further processing will take place. So please try giving your message statement as below:

Message '<Your Message>' TYPE 'E' Display Like 'S'.

Regards,

Kartik

Read only

arindam_m
Active Contributor
0 Likes
2,892

Hi Please respond to actual user who asked the question

Cheers,

Arindam

Read only

Former Member
0 Likes
2,892

Hi Naren,

You can try this as I have used this before for a similar requirement and it has worked.

MESSAGE <YOUR MESSAGE> TYPE I DISPLAY LIKE E.

SET SCREEN 0.

LEAVE SCREEN.

Hope this helps!

Read only

Former Member
0 Likes
2,892

Hi Naren ,

Check this :

       MESSAGE 'The Difference is Greater than 50' TYPE 'W' DISPLAY LIKE 'E'.

       LEAVE TO SCREEN sy-dynnr.

Regard's

Smruti

Read only

former_member193464
Contributor
0 Likes
2,892

I think you can use the suggestions given above...
also it might be happening because the sy-ucomm value would be changing when you press enter twice or so as it is only a warning message the If condition would be executed and it would be failing... so it is being saved.... you can put a break point just before the if statement and check the values of sy-ucomm ... hope it helps...

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
2,892

Hi

First of all can you please provide the details of which exit,badi etc you have used to display the error message? W

Thanks

Nabheet

Read only

narendar_naidu
Active Participant
0 Likes
2,892

hi All ,

thanks for your replies...i have tried all the suggestions but im ending in an SAVING the contract.

the process how im getting the screens

1. when i try to open a existing contract, the contract is displayed with values in conditions tab.

2. i am changing values in a condition and press 'ENTER'  the error message is displayed.second time when i press 'ENTER'  the fields become editable to change.

3. Till here it is fine,now when i press 'SAVE' after changing the values, the error message(warning message) is displayed as error and screen is in non-editable.

4. Now if i press 'ENTER' more than thrice the contract gets saved.

5. In the Debug the Sy-ucomm value is 'SICH' for save even if i press enter any number of times.

my requirement is to Stop the contract from saving and make the fields editable.


i have used SET SCREEN and LEAVE SCREEN .

this is my code in the VOFM routine.

if xkwert GT gd_var----(this is my condition) .
   MESSAGE 'The Difference is Greater than 50' TYPE 'W' DISPLAY LIKE 'E'.

-------For restricting the save.

   if sy-ucomm  = 'SICH' "function code for Save.

    set SCREEN sy-dynnr.

   exit.

endif.

endif.

regards,

Read only

0 Likes
2,892

Hi,

Not sure if it works but try to clear sy-ucomm in that case and see what happens.

Thanks & Regards,

Swarna

Read only

0 Likes
2,892

Hi,

Try doing a ROLLBACK WORK after the message to stop the save and check if the COMMIT happens before the message.

Cheers,

Arindam

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
2,892

Hi

Why dont you use MV45AFZZ pricing sub routines for validating your requirment and throw your error messages at the right place.

Put a break point in document_prepare or pricing one.

Thanks

Read only

0 Likes
2,892

hi All,

the MV45AFZZ does not trigger in this case.

i have tried the ROLLBACK  both before the message and after the message but still contract gets saved. and clearing the sy-ucomm also did not work.

Read only

0 Likes
2,892

Hi,

Try doing Chain and Endchain and in that call the field validation. Do this in the PAI of the screen, the PAI modules ( Include MV45AIZZ ). This should address the first issue of field greying out on error and thus allow the user to correct entries. Check the link below for details info on the exits available.


http://help.sap.com/saphelp_46c/helpdata/en/1c/f62c7dd435d1118b3f0060b03ca329/content.htm

Sample code should look like this. In the module have your normal error message of TYPE 'E' no DISPLAY LIKE required.

CHAIN.

FIELD <field-name> MODULE <validation_mod>.

ENDCHAIN.

Cheers,

Arindam