Sie sind auf Seite 1von 4

Log In Register About Us How to Contribute

Welcome Guest

SDN Community BPX Community BusinessObjects University Alliances SAP EcoHub


Home Forums Wiki Blogs Articles Downloads Code Exchange eLearning Career Center Events InnoCentive Idea Place Shop

SAP Community Network Forums » ABAP Development » Enhancements and Modifications

Thread: MV45AFZZ cancel document saving process


This question is answered.
Latest ABAP Jobs on SCN Career Center »
SAP WOrkflow - Denovo Hitech Solutions -
Welcome, Guest
Jeddah, Saudi Arabia
Want to post to the Expert Forums? Published 1 day ago
SAP ABAP Consultant - Confidential - Singapore,
Reply to this Thread Search Forum Back to Thread List Singapore
Published 3 days ago

Replies: 12 - Pages: 1 - Last Post: Oct 12, 2009 8:55 PM Last Post By: Tamas Hoznek

Michael Fritz MV45AFZZ cancel document saving process Reply


Posted: Aug 21, 2009 11:29 AM
Posts: 86
Registered: 7/26/04
Forum Points: 22
Hi,

I'm investigating an option on how to cancel the saving process of a document in user-exit include MV45AFZZ from within transaction
VA01/VA02.

Currently I've tried to do some MESSAGE E in FORM USEREXIT_SAVE_DOCUMENT_PREPARE or FORM


USEREXIT_SAVE_DOCUMENT w/o any success so far.
Of course MESSAGE A is possible but does a hard break and is not the best solution at all.

Setting any screen like SET SCREEN 0 or LEAVE TO SCREEN 0 or any similar things did not work either.

What am I trying to do? I would like to check some VBAP/VBAK fields if certain conditions are met and cancel the saving process if
necessary - of course without dropping the complete document.

I've already searched the forum here and only found hints like those already mentioned above - but nothing really specific.

Another thing which came into my mind is what about storing some a line into the incomplete log of the transaction to prevent from
saving? However, I did not found any function module to add some lines to the log in user-exit MV45AFZZ so far.

Any hints on how to accomplish this?

Marcin Milczynski Re: MV45AFZZ cancel document saving process Reply


Posted: Aug 21, 2009 11:39 AM in response to: Michael Fritz
Posts: 106
Registered: 8/20/07
Forum Points: 308 Hi,

You should achieve it by calling message type E in user-exit USEREXIT_SAVE_DOCUMENT_PREPARE - I've done it many times and
it worked.

Best regards,
Marcin

Michael Fritz Re: MV45AFZZ cancel document saving process Reply


Posted: Aug 21, 2009 12:28 PM in response to: Marcin Milczynski
Posts: 86
Registered: 7/26/04
Forum Points: 22
Marcin,

thanks for your reply!

I've tried this already, however the problem is after confirming the red error message by pressing ENTER, the transaction immediately
enters FORM USEREXIT_SAVE_DOCUMENT_PREPARE again and shows this error again - this continues unless I switch to another
transaction.

The user is not able to change the field values which caused the error message to appear anymore.

So basically I'm searching for a way to cancel document saving with e.g. an error message or similar and let the user, after confirming
the message, modify the document again to get rid of this error.

Michael

Kiran Sure Re: MV45AFZZ cancel document saving process Reply


Posted: Aug 21, 2009 3:01 PM in response to: Michael Fritz
Posts: 118
Registered: 9/8/08
Forum Points: 164 Michael, Why don't you try the exit FORM userexit_move_field_to_vbak.in MV45AFZZ

Raymond Giuseppi Re: MV45AFZZ cancel document saving process Reply


Posted: Aug 21, 2009 3:24 PM in response to: Michael Fritz
Posts: 4,818
Registered: 1/24/05
Forum Points: 10,032 Why don't you use USEREXIT_CHECK_VBAK, VBAP, VBKD or VBEP, those exits exist for that... Which data are you checking, which
is not editable after USEREXIT_SAVE_DOCUMENT_PREPARE ?

Regards,
Raymond

Naimesh Patel Re: MV45AFZZ cancel document saving process Reply


Posted: Aug 21, 2009 3:38 PM in response to: Michael Fritz
Posts: 4,732
Registered: 5/19/05
Forum Points: 13,036 You can try like this in user exit USEREXIT_SAVE_DOCUMENT_PREPARE. NEVER try to trigger error from the
USEREXIT_SAVE_DOCUMENT.

fcode = 'ENT1'.
message e999(Z1) with 'Error occurred, press enter to continue...'.

Regards,
Naimesh Patel

Tamas Hoznek Re: MV45AFZZ cancel document saving process Reply


Posted: Aug 21, 2009 7:43 PM in response to: Michael Fritz
Posts: 237
Registered: 4/2/04
Forum Points: 556 I used this code snippet to achieve your goal:

MESSAGE Sxxx. "to tell the user what's the problem


PERFORM FOLGE_GLEICHSETZEN(SAPLV00F).
FCODE = 'ENT1'.
SET SCREEN SYST-DYNNR.
LEAVE SCREEN.

This will display a message about the problem or the reason for not saving the document, and stay on the same screen where the
user was when clicking on 'Save'.

This should theoretically work in either USEREXIT_SAVE_DOCUMENT_PREPARE or USEREXIT_SAVE_DOCUMENT as far as I


remember. USEREXIT_SAVE_DOCUMENT_PREPARE is a better location to do something like this though.

Michael Fritz Re: MV45AFZZ cancel document saving process Reply


Posted: Aug 24, 2009 10:55 AM in response to: Tamas Hoznek
Posts: 86
Registered: 7/26/04
Forum Points: 22 Hi Tamas,

that's the best solution ever- Thanks for this! This solved my problem at the end - points awarded!

Michael

Christian Kniesel Re: MV45AFZZ cancel document saving process Reply


Posted: Sep 30, 2009 9:04 AM in response to: Michael Fritz
Posts: 3
Registered: 9/30/09
Forum Points: 0
Hi,

I got the same problem and the solution posted here has some major drawbacks: the user exit is also performed by several BAPIs
which will not work as they should anymore!

The reason for that is that is because the BAPI doesn't terminate with an error as it should. The code after calling the BAPI cannot be
reached anymore and if the BAPI is called within a loop you terminate this to. And last but not least you cannot handle this error in
your code so the user just won't know what just happened.

Has anyone got an better solution? Maybe use another userexit to fill a message table and stop the Fuba from saving the sales
document?

/chris

Michael Fritz Re: MV45AFZZ cancel document saving process Reply


Posted: Sep 30, 2009 9:19 AM in response to: Christian Kniesel
Posts: 86
Registered: 7/26/04
Forum Points: 22 Christian,

you may be right that this will cause some troubles when the User-Exit has been called from a previous BAPI call.

In my case I would like to stop the saving process when the user has entered some values into the material configuration which are
not allowed. This condition, too, depends on some more conditions and cannot be caught elsewhere.

In my specific case, I don't execute this check (and hence the cancellation of the saving process) when the user-exit was called from
within a BAPI.

Michael

Christian Kniesel Re: MV45AFZZ cancel document saving process Reply


Posted: Sep 30, 2009 9:35 AM in response to: Michael Fritz
Posts: 3
Registered: 9/30/09
Forum Points: 0 Michael,

how do you achieve that the check/cancellation is not performed in a BAPI call?

in my case the check/cancellation should always be performed so that the same restrictions are valid for all transactions on the
system. why would you like to prevent the creation of faulty sales documents in VA01/VA02 but not in other transactions.

in my case i implemented the check before calling the BAPI as a work around till i find a better solution.

still other developers have will have trouble with these codings either the will wonder why the desired check does not work or they will
wonder why their BAPI call leads to a leave to screen.

Michael Fritz Re: MV45AFZZ cancel document saving process Reply


Posted: Sep 30, 2009 11:00 AM in response to: Christian Kniesel
Posts: 86
Registered: 7/26/04
Forum Points: 22 > Christian Kniesel wrote:

> how do you achieve that the check/cancellation is not performed in a BAPI call?

Currently I'm using a coding like

IF CALL_BAPI IS INITIAL. MESSAGE...

CALL_BAPI is available at least in MV45AFZB and MV45AFZZ, if I create a sales order from e.g. SD_SALESDOCUMENT_CREATE
or SD_SALESDOCUMENT_MAINTAIN.

Better would be of course to show the warning/error message only when the user-exit is called from online processing and when
called from batch or BAPI or similar it should write a message into the BAPIRET* structures or perhaps into the incompletion log of the
document. So far I could not figure out how to do logging.

Michael

Tamas Hoznek Re: MV45AFZZ cancel document saving process Reply


Posted: Oct 12, 2009 8:55 PM in response to: Christian Kniesel
Posts: 237
Registered: 4/2/04
Forum Points: 556 I'm not exactly sure why is this a problem... when your transaction is called from a BAPI, just issue an error message instead of a
success message. That should end up in the BAPIRET* structure of the BAPI, or am I wrong?
Then you can handle the error in the calling program and inform the user etc.

Pages: 1 Back to Thread List

Powered by Jive Software


Contact Us Site Index Marketing Opportunities Privacy Impressum Legal
Powered by SAP NetWeaver

Das könnte Ihnen auch gefallen