Update
This commit is contained in:
@@ -160,7 +160,7 @@ CLASS zcl_demo_abap_cloud_excursion IMPLEMENTATION.
|
||||
DATA(up_to_year) = 2050.
|
||||
|
||||
"The statement retrieves the leap years between the current year and
|
||||
"the specfied years. A released CDS view is used as data source.
|
||||
"the specified year. A released CDS view is used as data source.
|
||||
SELECT calendaryear
|
||||
FROM i_calendaryear
|
||||
WHERE calendaryear BETWEEN @current_year AND @up_to_year
|
||||
@@ -221,7 +221,7 @@ CLASS zcl_demo_abap_cloud_excursion IMPLEMENTATION.
|
||||
AND ReleasedObjectName LIKE 'CL_ABAP_RANDOM_P%'
|
||||
INTO TABLE @DATA(rel_cl_abap_random).
|
||||
|
||||
out->write( |\nRead result::| ).
|
||||
out->write( |\nRead result:| ).
|
||||
out->write( data = rel_cl_abap_random name = `rel_cl_abap_random` ).
|
||||
|
||||
"Getting the number of all released classes in the system
|
||||
|
||||
@@ -1662,10 +1662,11 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
||||
**********************************************************************
|
||||
|
||||
out->write( zcl_demo_abap_aux=>heading( `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.
|
||||
"The following examples use methods of the CL_ABAP_DYN_PRG class, which supports
|
||||
"dynamic programming by checking the validity for dynamic specifications.
|
||||
"Check out the class documentation for more information.
|
||||
"In the example, several table names are provided in a string table that
|
||||
|
||||
"In the following 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
|
||||
@@ -1673,6 +1674,9 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
||||
"specified. If you imported it into a package with a different name,
|
||||
"change the value accordingly. Otherwise, none of the tables is found.
|
||||
|
||||
out->write( `****** Checking if the input is a database table name, inlcuded in given packages ******` ).
|
||||
out->write( |\n| ).
|
||||
|
||||
DATA(table_names) = VALUE string_table( ( `ZDEMO_ABAP_CARR` )
|
||||
( `ZDEMO_ABAP_FLI` )
|
||||
( `NO_DBTAB` )
|
||||
@@ -1692,18 +1696,83 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
||||
SELECT SINGLE * FROM (dbtab) INTO NEW @DATA(ref_wa).
|
||||
|
||||
out->write( |Result for { wa_tab }:| ).
|
||||
out->write( |\n| ).
|
||||
out->write( |\n| ).
|
||||
out->write( ref_wa->* ).
|
||||
out->write( |\n| ).
|
||||
CATCH cx_abap_not_a_table cx_abap_not_in_package INTO DATA(err).
|
||||
out->write( |Result for { wa_tab }:| ).
|
||||
out->write( |\n| ).
|
||||
out->write( err->get_text( ) ).
|
||||
out->write( |\n| ).
|
||||
ENDTRY.
|
||||
ENDLOOP.
|
||||
|
||||
"In the following example, the check_allowlist method is used to check
|
||||
"whether the input is allowed or not. Similar to above, an internal
|
||||
"is filled with demo input. Here, a parameter is used that expects
|
||||
"a comma-separated list of allowed values.
|
||||
|
||||
out->write( `****** Checking if input is allowed or not ******` ).
|
||||
out->write( |\n| ).
|
||||
|
||||
DATA(to_be_checked) = VALUE string_table( ( `A` )
|
||||
( `B` )
|
||||
( `C` )
|
||||
( `D` )
|
||||
( `HALLO` )
|
||||
( `ABAP` ) ).
|
||||
|
||||
LOOP AT to_be_checked INTO DATA(chk).
|
||||
TRY.
|
||||
DATA(value) = cl_abap_dyn_prg=>check_allowlist( val = chk
|
||||
allowlist_str = `A,B,C,ABAP` ).
|
||||
out->write( |{ value } is allowed.| ).
|
||||
CATCH cx_abap_not_in_allowlist INTO err.
|
||||
out->write( err->get_text( ) ).
|
||||
ENDTRY.
|
||||
ENDLOOP.
|
||||
|
||||
out->write( |\n| ).
|
||||
|
||||
"The following example is similar to the one above. However, in this case,
|
||||
"a parameter is used that expects an internal table containing the allowed
|
||||
"values.
|
||||
|
||||
LOOP AT to_be_checked INTO chk.
|
||||
TRY.
|
||||
value = cl_abap_dyn_prg=>check_allowlist( val = chk
|
||||
allowlist_htab = VALUE #( ( `X` )
|
||||
( `B` )
|
||||
( `HALLO` )
|
||||
( `Y` )
|
||||
( `ABAP` ) ) ).
|
||||
out->write( |{ value } is allowed.| ).
|
||||
CATCH cx_abap_not_in_allowlist INTO err.
|
||||
out->write( err->get_text( ) ).
|
||||
ENDTRY.
|
||||
ENDLOOP.
|
||||
|
||||
out->write( |\n| ).
|
||||
out->write( `****** Checking if input can be a column name and does not contain invalid characters ******` ).
|
||||
out->write( |\n| ).
|
||||
|
||||
"The following example uses a method with which the validity of column names
|
||||
"of database tables can be checked.
|
||||
|
||||
to_be_checked = VALUE #( ( `CARRID` )
|
||||
( `CONNID` )
|
||||
( `SOME_COLUMN` )
|
||||
( `??NOPE??` )
|
||||
( `...!` ) ).
|
||||
|
||||
LOOP AT to_be_checked INTO chk.
|
||||
TRY.
|
||||
DATA(col_name) = cl_abap_dyn_prg=>check_column_name( val = chk
|
||||
strict = abap_true ).
|
||||
out->write( |{ col_name } is allowed.| ).
|
||||
CATCH cx_abap_invalid_name INTO err.
|
||||
out->write( err->get_text( ) ).
|
||||
ENDTRY.
|
||||
ENDLOOP.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
out->write( zcl_demo_abap_aux=>heading( `38) Dynamic Invoke` ) ).
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//////////////////////////------ NOTES ------//////////////////////////////////
|
||||
// - CDS view entity selects from a demo database table
|
||||
// - Demonstrates various aggregate expressions in the element list
|
||||
// - As a prerequisite, run the class zcl_abap_demo_cds_ve to populate the
|
||||
// - As a prerequisite, run the class zcl_demo_abap_cds_ve to populate the
|
||||
// database tables of the example. Otherwise, no data is displayed.
|
||||
//
|
||||
//////////////////////------ DATA PREVIEW ------///////////////////////////////
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// - CDS view entity that selects from a demo CDS view entity and demonstrates
|
||||
// associations. A selection of use cases of associations is covered. For
|
||||
// more information and examples, see the ABAP Keyword Documentation.
|
||||
// - As a prerequisite, run the class zcl_abap_demo_cds_ve to populate the
|
||||
// - As a prerequisite, run the class zcl_demo_abap_cds_ve to populate the
|
||||
// database tables of the example. Otherwise, no data is displayed.
|
||||
// - For further notes on associations, see the commented out information further
|
||||
// down.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// - CDS view entity that selects from a demo database table.
|
||||
// - The purpose of this CDS view entity is to demonstrate associations. The view
|
||||
// is used as a data source in another CDS view entity.
|
||||
// - As a prerequisite, run the class zcl_abap_demo_cds_ve to populate the
|
||||
// - As a prerequisite, run the class zcl_demo_abap_cds_ve to populate the
|
||||
// database tables of the example. Otherwise, no data is displayed.
|
||||
//
|
||||
//////////////////////------ DATA PREVIEW ------///////////////////////////////
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//////////////////////////------ NOTES ------//////////////////////////////////
|
||||
// - CDS view entity selects from a demo database table
|
||||
// - Demonstrates various joins
|
||||
// - As a prerequisite, run the class zcl_abap_demo_cds_ve to populate the
|
||||
// - As a prerequisite, run the class zcl_demo_abap_cds_ve to populate the
|
||||
// database tables of the example. Otherwise, no data is displayed.
|
||||
// It is particularly needed in this case because it contains entries to
|
||||
// visualize the effect of outer joins.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//////////////////////////------ NOTES ------//////////////////////////////////
|
||||
// - CDS view entity selects from a demo database table
|
||||
// - Demonstrates various syntax options regarding operands and expressions
|
||||
// - As a prerequisite, run the class zcl_abap_demo_cds_ve to populate the
|
||||
// - As a prerequisite, run the class zcl_demo_abap_cds_ve to populate the
|
||||
// database tables of the example. Otherwise, no data is displayed.
|
||||
//
|
||||
//////////////////////------ DATA PREVIEW ------///////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user