This commit is contained in:
danrega
2023-09-25 08:44:48 +02:00
parent 7e03cae97c
commit f06e7719da
2 changed files with 61 additions and 6 deletions

View File

@@ -1,5 +1,20 @@
ABAP cheat sheets for classic ABAP
[![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/abap-cheat-sheets)](https://api.reuse.software/info/github.com/SAP-samples/abap-cheat-sheets)
ABAP version: 756
# ABAP Cheat Sheets for Classic ABAP
More information: [https://github.com/SAP-samples/abap-cheat-sheets](https://github.com/SAP-samples/abap-cheat-sheets)
- ABAP version: **7.56**
- More Information: [https://github.com/SAP-samples/abap-cheat-sheets](https://github.com/SAP-samples/abap-cheat-sheets)
## ⚠️ Disclaimer
The code examples presented in this repository are only syntax examples and are not intended for direct use in a production system environment. The code examples are primarily intended to provide a better explanation and visualization of the syntax and semantics of ABAP statements and not to solve concrete programming tasks. For production application programs, a dedicated solution should therefore always be worked out for each individual case.
There is no guarantee for either the correctness or the completeness of the code. In addition, there is no legal responsibility or liability for possible errors or their consequences, which occur through the use of the example code.
<br>
## 📟 Support and Contribution
This is not intended to be a contribution repository, so please do not create pull requests. If you like to address issues or suggestions, please create an issue. However, this project is provided "as-is": there is no guarantee that raised issues will be answered or addressed in future releases.
<br>
## 📜 License
Copyright (c) 2022 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSE) file.

View File

@@ -1468,8 +1468,8 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
**********************************************************************
output->next_section( `37) Excursion: Multiple Dynamically Specified ` &&
`Clauses in an ABAP SQL SELECT Statement` ).
output->next_section( `37a) Excursion: Multiple Dynamically ` &&
`Specified Clauses in an ABAP SQL SELECT Statement` ).
"In this example, multiple clauses in a SELECT statement are
"determined at runtime to demonstrate the rich variety of possibilities.
@@ -1504,6 +1504,46 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
output->display( `There's an issue with syntax elements.` ).
ENDIF.
**********************************************************************
output->next_section( `37b) Excursion: Checking the validity of dynamic specifications` ).
"The following example uses the CL_ABAP_DYN_PRG class, which supports
"dynamic programming by checking the validity of dynamic specifications.
"Check out the class documentation for more information.
"In the example, several table names are provided in a string table that
"is looped over. Some wrong table names are intentionally included.
"You can provide the "packages" formal parameter with a table that contains
"the names of packages in which the tables should be included. The
"assumption is that you imported the repository into the package
"specified. If you imported it into a package with a different name,
"change the value accordingly. Otherwise, none of the tables is found.
DATA(table_names) = VALUE string_table( ( `ZDEMO_ABAP_CARR` )
( `ZDEMO_ABAP_FLI` )
( `NO_DBTAB` )
( `ZDEMO_ABAP_FLSCH` )
( `ZDEMO_ABAP_FLI2` )
( `WRONG_DBTAB` ) ).
DATA(check_packages) = VALUE string_hashed_table( ( `TEST_ABAP_CHEAT_SHEETS` ) ).
DATA dbtab TYPE string.
LOOP AT table_names INTO DATA(wa_tab).
TRY.
dbtab = cl_abap_dyn_prg=>check_table_name_tab( val = to_upper( wa_tab )
packages = check_packages ).
SELECT SINGLE * FROM (dbtab) INTO NEW @DATA(ref_wa).
output->display( |Result for { wa_tab }| ).
output->display( ref_wa->* ).
CATCH cx_abap_not_a_table cx_abap_not_in_package INTO DATA(err).
output->display( |Result for { wa_tab }| ).
output->display( err->get_text( ) ).
ENDTRY.
ENDLOOP.
**********************************************************************
output->next_section( `38) Dynamic Invoke` ).
@@ -2058,4 +2098,4 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
output->display( input = ref_tab->* name = `ref_tab->*` ).
ENDMETHOD.
ENDCLASS.
ENDCLASS.