cancel
Showing results for 
Search instead for 
Did you mean: 

IF_EX_WORKORDER_CONFIRM->AT_SAVE broken

AndreM
Explorer
0 Kudos

Hello everybody,

I have already opened an incident about this, but maybe someone has a workaround for me until SAP provides a real solution.

Here is my problem:

1. I am confirming workorders sometimes via Button in a ALV-List instead of using CO11 directly (kind-of Batchinput, but don't care, this is not really relevant for the problem itself, I just tell you so you understand why I actually have a problem here) and sometimes using CO11.

2. Whenever a workorder is confirmed I want to make some checks as to whether some other process is complete. If not, confirmation should not be possible.

3. So I implemented method AT_SAVE from BADI WORKORDER_CONFIRM to make these checks. Its documentation says, that if I want to cancel saving the confirmation, I should use MESSAGE ... RAISING error_with_message.

4. All pretty and fine, but doing so results in SAP directly converting that message into a message type "A" (hardcoded right behind the BADI-call) thereby killing whatever programm is currently running. No chance for me to do anything about it. Not even a check if there is a GUI available so messages can be handled correctly. Worst-Programming-Style-Ever.

5. Investigating my options I found the reason for this poor implementation: the badi gets called from a function-module which itself has one single exception that never gets caught anywhere in the calling programs so is of no use to nobody. neither are there any checks or condition-checks in that function-module that would give me any chance to manipulate data in a way that the fm will terminate without saving anything - it doesn't even care about data-consistency, it just simply assumes everything is fine. If your data is broken, it gets written to the database no matter what.

All this happens in level 20-something or so of the program-stack. And while the upper levels work pretty well with bapi-return-structures and so on, the function-modules doing the real work are so badly programmed that it hurts looking at them.

So after even trying stuff like "LEAVE TO SCREEN sy-dynnr" (which doesn't work as sy-dynnr in this case seems to be the selection-screen), has anybody any solution for me to get this stuff working? Any dirty-assign or something alike? I won't care as long as it works ...

Regards

André

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

The documentation of the BAdI say

The Badi can be used for own checks and "The saving of the confirmations can be aborted"

So it's documented that not an error is send, the documentation refer to abort.

So system behavoir is as descriped in documentation as already said.

I leave the discussion here.

BR Sabine

Former Member
0 Kudos

Hello Andre

at_save is called while saving, if you send an exception there of course there is only the option to stop. This is correct and this is the idea of an exception.

You might rather use user exit CONFPPxx instead of BAdI for your own checks

BR Sabine

AndreM
Explorer
0 Kudos

What I am complaining about is not that it stops, but how. It is never a good Idea to stop execution of code with a type-"A"-message, except in 2 cases:

a) the raising code is handling GUI (PBO/PAI) and therefore knows what it is doing.

b) you have encountered a state of program where any continuation even by exception is of no more value to noone. In any other case exceptions should be handled by some kind of solution or be forwarded upwards in the call-stack to someone that can handle it. And especially exceptions raised by a BADI should be treated properly.

André

Former Member
0 Kudos

The documentation of the BAdI refer to an exception happen. So this is an exception, error type A.

You would like to have an error only but this is not possible at this point, only an exception is possible here.  If you don't like it, don't use this BAdI.

BR Sabine

AndreM
Explorer
0 Kudos

You seem to be reading a different documentation of that BADI than me. Mine says (I translate from german original):

"This method is called directly after calling function "save". Within this method you can do checks whether the confirmation is complete or not from your point of view. In case of errors you can raise the exception ERROR_WITH_MESSAGE. This will show the message sent with the exception and then stop saving of the confirmation."

So by documentation the BADI is exactly for what I want to do with it. It just behaves in a very unusual way. If I wanted to the program to break, I could easily send a type "A" or "X" message myself. The caller's task is to stop the saving-process, not to stop the whole program!

André

Former Member
0 Kudos

Hello Andre

but exactly this happen. Saving is prevented with exception. Exception mean message type A.

System behavoir is exactly as documented.

BR Sabine

AndreM
Explorer
0 Kudos

ehm. no.

"Exceptions" is a technical concept to inform a calling program of some kind of error-state. this ranges from "no such data found" to "your input is broken" or "cannot connect to server". How to handle any exception depends on the exception and the calling program. If the caller only tried to find out whether a key exists, a "no such data found"-exception is of no interest to the user and the program just takes another path through the code (for example by creating the missing key). If you cannot connect to a server you can tell the user (if there is one) or put that into a protocolentry in slg1 or retry connecting or just give up. What you do with any exception has nothing to do with it being an exception. But as described: if the only way to tell the caller of a BADI in which you should check some data that the data is incorrect is by a single exception, than it should be treated properly. And stopping a program from somewhere deep within is absolutely no option. Never. How can you be sure that you won't leave any corrupted data on some database? This is just plain bad style.