This commit is contained in:
danrega
2024-06-10 16:25:44 +02:00
parent e2655e8ddf
commit 1120480ac5
9 changed files with 720 additions and 112 deletions

View File

@@ -17,6 +17,7 @@
- [Loops Across Tables](#loops-across-tables)
- [Calling Procedures](#calling-procedures)
- [Excursion: RETURN](#excursion-return)
- [Interrupting the Program Execution](#interrupting-the-program-execution)
- [Handling Exceptions](#handling-exceptions)
- [Notes on Exception Classes](#notes-on-exception-classes)
- [Raising Exceptions](#raising-exceptions)
@@ -613,6 +614,32 @@ ENDCLASS.
<p align="right"><a href="#top">⬆️ back to top</a></p>
## Interrupting the Program Execution
Using [`WAIT UP TO`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapwait_up_to.htm) statements, you can interrupt the program execution by a specified number of seconds.
```abap
"First retrieval of the current time stamp
DATA(ts1) = utclong_current( ).
...
WAIT UP TO 1 SECONDS.
...
WAIT UP TO 3 SECONDS.
...
"Second retrieval of the current time stamp after the WAIT statements
DATA(ts2) = utclong_current( ).
"Calcularing the difference of the two time stamps
cl_abap_utclong=>diff( EXPORTING high = ts2
low = ts1
IMPORTING seconds = DATA(seconds) ).
"The 'seconds' data object holding the delta of the time stamps
"should be greater than 4.
ASSERT seconds > 4.
```
<p align="right"><a href="#top">⬆️ back to top</a></p>
## Handling Exceptions
- [Exceptions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenexception_glosry.htm) ...
- are events during the execution of an ABAP program that interrupt the program flow because it is not possible for the program to continue in a meaningful way. For such situations, you can implement an exception handling in which you can react on the situations appropriately. Consider, for example, the implementation of a simple calculation. If there is a division by zero, the program will be terminated with a [runtime error](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenruntime_error_glosry.htm) unless you handle the exception appropriately.