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é