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

USEREXIT_SAVE_DOCUMENT_PREPARE

Former Member
0 Likes
1,725

Hello All.

I need to prevent a user from saving a contract (VA41 or VA42) when the Increase date field is not entered,

But the users normaly use the Edit->Log of incomplete items

menu path and then presses save.

If I post an error message the screen is frozen unless I use the following code:

IF ok_code <> 'SICH'.

CLEAR: ok_code.

LEAVE TO SCREEN sy-dynnr.

ENDIF.

But that does not take the user back to the previous screen, it saves the contract.

Any help will be appreciated.

Hello All.

I need to prevent a user from saving a contract (VA41 or VA42) when the Increase date field is not entered,

But the users normaly use the Edit->Log of incomplete items

menu path and then presses save.

If I post an error message the screen is frozen unless I use the following code:

IF ok_code <> 'SICH'.

CLEAR: ok_code.

LEAVE TO SCREEN sy-dynnr.

ENDIF.

But that does not take the user back to the previous screen, it saves the contract.

Any help will be appreciated.

13 REPLIES 13
Read only

Former Member
0 Likes
1,579

Hi,

Why don't you write an error message if you want to prevent user from saving:

if datefield is initial.

MESSAGE 'Date field can not be empty' TYPE 'E'.

endif.

Regards,

Dharitree

Read only

Former Member
0 Likes
1,579

better to tigger BADI.

Regards

Prabhu

Read only

0 Likes
1,579

How do I find the BAPI's for SD?

Regards

Read only

0 Likes
1,579

Does anybody know where to find the SD BADI's (sorry in

one of my previous messages I typed BAPI)

Thank you

Read only

Former Member
0 Likes
1,579

you need to give an error message.

for eg :

message E398(00) with 'Please enter date field'.

Regards,

Preema

*Reward points for helpful answers

Read only

former_member186741
Active Contributor
0 Likes
1,579

JJ, I have used an érror'message, as you say the screen does 'freeze' but only once....when the user hits enter normal service is then resumed.

But anyway, shouldn't your code be??:

IF ok_code

=

'SICH'.

CLEAR: ok_code.

LEAVE TO SCREEN sy-dynnr.

ENDIF.

Read only

0 Likes
1,579

Neil, If I press Enter the Error message is displayed.

I tried to Leave to the screen by checking the sy-ucomm code if it is not 'SICH'. Then it does not go to the previous screen, the contract is saved.

Read only

0 Likes
1,579

JJ, what is your code? The okcode will always be 'sich' in this routine (unless you have cleared it yourself).

I think it should be something like:

If error situation.....

message...

leave to screen sy-dynnr.

endif.

Read only

0 Likes
1,579

Neil,

The problem is that after the message statement the program does not return to the line below it. In your code, it will execute the leave to screen statement.

If you put he leave to screen statement before the message, then it will not execute the message.

Read only

0 Likes
1,579

Hi,

In this case don't write an error message write 'I' or 'W' mesage and then leave the screen.

Regards,

Dharitree

Read only

0 Likes
1,579

Dharitree

Nope, it displays the same message over and over.

Read only

0 Likes
1,579

ok, so you need to set a flag indicating an error has occurred.

So in your logic:

1. if your flag is set: clear it and the okcode and leave to screen sy-dynnr.

2. Then have your error test. If it's true set the flag and then issue the message.

Read only

0 Likes
1,579

Hi,

I think you want to go back to the previous screen after error/warning message gets displayed,

then why are you giving sy-dynnr.

Instead of this you should give the previous Screen number. If you give the current screen, system will again check the date field & find that it is intial & again dispay the warning message & so on..

Regards,

Dharitree