2022 Jan 07 9:10 AM
I found something interesting.
I think ABAP debugger has a problem with handling a exception because of below.
When I executed below program on Debugging Enviornment,
I found the cursor moved to wrong position.
I tested it repeatly on SAP BASIS 46C, 751, 753 and the result was the same.
So, I would like to know this reason.
Below is my test code.
REPORT yfic2rasing.
"This statement doesn't affect sy-subrc.
MESSAGE s001(00) WITH 'Test raising exception' RAISING xyz.
IF sy-subrc = 0.
"So we expect ABAP executes this statement.
"And it does actually.
WRITE:/1 'TRUE'.
ELSE.
"However, on debugging enviornment, we can see that debugging cursor enters this point.
"Actually ABAP doesn't execute this statement.
"Just it is shown as like executing that.
WRITE:/1 'FALSE'.
ENDIF.
2022 Jan 07 12:44 PM
It's nothing to do with the exception - you don't need the MESSAGE statement to get the same result! I added a WRITE /1 'FINISHED' statement after the ENDIF; the debugger then behaves as expected. I think I know what is happening.
It seems the debugger will always go to the last actually executable line in the program. Even if it doesn't actually execute it. The debugger just can't stop at ENDIF or a blank line, so it stops at the line before ENDIF. The WRITE:/1 'FALSE'.
I can't really think of what else it could do! Same behaviour in Eclipse and SAPGui btw.
2022 Jan 07 12:44 PM
It's nothing to do with the exception - you don't need the MESSAGE statement to get the same result! I added a WRITE /1 'FINISHED' statement after the ENDIF; the debugger then behaves as expected. I think I know what is happening.
It seems the debugger will always go to the last actually executable line in the program. Even if it doesn't actually execute it. The debugger just can't stop at ENDIF or a blank line, so it stops at the line before ENDIF. The WRITE:/1 'FALSE'.
I can't really think of what else it could do! Same behaviour in Eclipse and SAPGui btw.
2022 Jan 07 2:56 PM
Thanks for your opinion.
After more consideration, my conclusion is this.
"The conditional statement (like IF, CASE) out of procedure(subroutine, function modules, methods)" causes the debugger to act incorrectly.
I was in a hurry to test the statement of "Message ~ Raising~" and made just simple code without procedure such a Form.
And then it made me thought the reason was the exception statement.
Generally ABAP program has processing blocks and our executable program is called by MODULE statement in screen 1000 on SAPMSSY0.
So, my if statments is not in procedure but screen event.
Anyway, I think this situation isn't good at all.
What I'm seeing is not true!
2022 Jan 09 7:31 PM
Yes. It should really quit debugging after the WRITE:/1 'TRUE'. instead of jumping to line WRITE:/1 'FALSE'.