This commit is contained in:
danrega
2024-08-27 16:38:07 +02:00
parent 7eaeaeb844
commit 82a3b64986
9 changed files with 93 additions and 11 deletions

View File

@@ -187,7 +187,18 @@ CLASS zcl_demo_abap_date_time IMPLEMENTATION.
"Assignment of an invalid date of type d to type i; the initial value
"is produced
DATA(inv_date3) = CONV i( CONV d( '20240231' ) ).
"In newer ABAP releases, the following statement shows a
"syntax warning that the date (intentionally specified as
"invalid date here) does not match the type. Therefore,
"the example is provided differently to circumvent the
"syntax warning.
"DATA(inv_date3) = CONV i( CONV d( '20240231' ) ).
TYPES c8 TYPE c LENGTH 8.
DATA false_date TYPE c8 VALUE '20240231'.
DATA(inv_date3) = CONV i( CONV d( false_date ) ).
IF inv_date3 = 0.
out->write( `inv_date3 = 0` ).
ENDIF.
@@ -913,10 +924,27 @@ CLASS zcl_demo_abap_date_time IMPLEMENTATION.
"No data object change. The statement below should return a valid time stamp.
WHEN 2.
"Invalid date
date_test = '20249999'.
"In newer ABAP releases, the following statement shows a
"syntax warning that the date (intentionally specified as
"invalid date here) does not match the type. Therefore,
"the example is provided differently to circumvent the
"syntax warning.
"date_test = '20249999'.
TYPES c_l8 TYPE c LENGTH 8.
DATA falsedate TYPE c_l8 VALUE '20240231'.
date_test = falsedate.
WHEN 3.
"Invalid time
time_test = '992458'.
"The following statement is commented out for the reasons
"mentioned above.
"time_test = '992458'.
TYPES c_l6 TYPE c LENGTH 6.
DATA falsetime TYPE c_l6 VALUE '992458'.
time_test = falsetime.
WHEN 4.
"Invalid fractions of seconds
frac_sec_test = '1'.
@@ -925,7 +953,14 @@ CLASS zcl_demo_abap_date_time IMPLEMENTATION.
dls_test = 'X'.
WHEN 6.
"Invalid time zone
dls_test = `NOPE`.
"The following statement is commented out for the reasons
"mentioned above.
"dls_test = `NOPE`.
TYPES c_l4 TYPE c LENGTH 4.
DATA falsetimezone TYPE c_l4 VALUE 'NOPE'.
dls_test = falsetimezone.
ENDCASE.
TRY.

View File

@@ -1273,7 +1273,15 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
out->write( data = date name = `date` ).
out->write( |\n| ).
date = 20240101.
"In newer ABAP releases, the following statement shows a syntax
"warning that the value of the the data object (intentionally
"specified here like this) is not an admissable value for the
"target type. Therefore, the example is provided differently to
"circumvent the syntax warning.
"date = 20240101.
DATA falsedate TYPE i VALUE 20240101.
date = falsedate.
out->write( data = date name = `date` ).
**********************************************************************
@@ -1670,7 +1678,21 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
"Assignments
do_h_c5 = 'abc'.
do_h_c5 = 'defghi'. "only 'def' assigned -> length and memory use do not change
"In newer ABAP releases, the following statement shows a syntax
"warning that the value of the literal (intentionally specified
"here like this) is not an admissable value for the target type.
"Therefore, the example is provided differently to circumvent the
"syntax warning.
"do_h_c5 = 'defghi'.
TYPES c_l6 TYPE c LENGTH 6.
DATA some_char TYPE c_l6 VALUE 'defghi'.
"only 'def' assigned -> length and memory use do not change
do_h_c5 = some_char.
"Memory consumption changes for dynamic data objects
do_i_str = `abc`.

View File

@@ -415,7 +415,7 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
AND `ha` && `llo` = <fs>
"Constructor expression
AND CONV i( '2.03' ) = num
AND VALUE i( ) = 0
AND VALUE string_table( ( `a` ) ( `b` ) ( `c` ) ) = str_table
"Table expression

View File

@@ -99,7 +99,17 @@ CLASS zcl_demo_abap_string_proc IMPLEMENTATION.
DATA(str_a6) = `efgh`. "Type string
"Note: Variable is of type c length 4. Characters are truncated.
char_a2 = 'ijklmnopq'.
"In newer ABAP releases, the following statement shows a syntax
"warning that the value of the literal (intentionally specified
"here like this) is not an admissable value for the target type.
"Therefore, the example is provided differently to circumvent the
"syntax warning.
"char_a2 = 'ijklmnopq'.
TYPES c_l9 TYPE c LENGTH 9.
DATA some_char TYPE c_l9 VALUE 'ijklmnopq'.
char_a2 = some_char.
"Treating trailing blanks
DATA(char_a3) = 'ab '.