From 82a3b64986f6a529d59232f864224073eb17eee6 Mon Sep 17 00:00:00 2001 From: danrega <16720986+danrega@users.noreply.github.com> Date: Tue, 27 Aug 2024 16:38:07 +0200 Subject: [PATCH] Update --- 04_ABAP_Object_Orientation.md | 2 +- 07_String_Processing.md | 3 ++ 13_Program_Flow_Logic.md | 2 +- 16_Data_Types_and_Objects.md | 7 +++- 23_Date_and_Time.md | 7 ++++ src/zcl_demo_abap_date_time.clas.abap | 43 +++++++++++++++++++-- src/zcl_demo_abap_dtype_dobj.clas.abap | 26 ++++++++++++- src/zcl_demo_abap_prog_flow_logic.clas.abap | 2 +- src/zcl_demo_abap_string_proc.clas.abap | 12 +++++- 9 files changed, 93 insertions(+), 11 deletions(-) diff --git a/04_ABAP_Object_Orientation.md b/04_ABAP_Object_Orientation.md index 3282dd5..7978d1b 100644 --- a/04_ABAP_Object_Orientation.md +++ b/04_ABAP_Object_Orientation.md @@ -2367,7 +2367,7 @@ ENDCLASS. ``` 3) -- The following example class represents an exectuable example that displays output in the ADT console. +- The following example class represents an executable example that displays output in the ADT console. - Apart from simple demo implementations, it includes alias names specified for interface components. - The interface methods declared with `DEFAULT IGNORE` and `DEFAULT FAIL` are intentionally not implemented, but the methods are nevertheless called. - Interface method declared with `DEFAULT IGNORE`: No implementation available, and no value is assigned for the returning parameter. Therefore, the value is initial. diff --git a/07_String_Processing.md b/07_String_Processing.md index 3af5663..06a0dc7 100644 --- a/07_String_Processing.md +++ b/07_String_Processing.md @@ -223,6 +223,9 @@ FINAL(final_string)  = `zyx`. "Since char2 is of type c length 4 (the length is also derived), "characters are truncated in the following example assignment +"Note: 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. char2 = 'ijklmnopq'. "ijkl "Trailing blanks after assigning fixed length to variable length string diff --git a/13_Program_Flow_Logic.md b/13_Program_Flow_Logic.md index e4e9db7..50fedfe 100644 --- a/13_Program_Flow_Logic.md +++ b/13_Program_Flow_Logic.md @@ -216,7 +216,7 @@ AND 4 - 3 + 1 = num AND `ha` && `llo` = "Constructor expression -AND CONV i( '2.03' ) = num +AND VALUE i( ) = 0 AND VALUE string_table( ( `a` ) ( `b` ) ( `c` ) ) = str_table "Table expression diff --git a/16_Data_Types_and_Objects.md b/16_Data_Types_and_Objects.md index 7a96398..41b28b5 100644 --- a/16_Data_Types_and_Objects.md +++ b/16_Data_Types_and_Objects.md @@ -1286,7 +1286,12 @@ DATA do_i_str TYPE string. "Assignments do_h_c3 = 'abc'. -do_h_c3 = 'defghi'. "only 'def' assigned -> length and memory use do not change + +"only 'def' assigned -> length and memory use do not change +"Note: 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. +do_h_c3 = 'defghi'. "Memory consumption changes for dynamic data objects do_i_str = `abc`. diff --git a/23_Date_and_Time.md b/23_Date_and_Time.md index 2f255ba..de78e9e 100644 --- a/23_Date_and_Time.md +++ b/23_Date_and_Time.md @@ -205,6 +205,9 @@ TRY. ENDTRY. "Assignment of an invalid date of type d to type i; the initial value is produced +"Note: In newer ABAP releases, the following statement shows a syntax +"warning that the value of the literal (intentionally specified +"here like this) does not match type d. DATA(inv_date3) = CONV i( CONV d( '20240231' ) ). ASSERT inv_date3 = 0. ``` @@ -841,6 +844,10 @@ DO 6 TIMES. dls_test = abap_false. tz_test = `EST`. + "Note: In newer ABAP releases, some of the following statements + "show a syntax warning. The values of some literals (intentionally + "specified here like this) are not admissable values for the target + "types. CASE sy-index. WHEN 1. "No data object change. The statement below should return a valid time stamp. diff --git a/src/zcl_demo_abap_date_time.clas.abap b/src/zcl_demo_abap_date_time.clas.abap index 41e899c..02f94d1 100644 --- a/src/zcl_demo_abap_date_time.clas.abap +++ b/src/zcl_demo_abap_date_time.clas.abap @@ -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. diff --git a/src/zcl_demo_abap_dtype_dobj.clas.abap b/src/zcl_demo_abap_dtype_dobj.clas.abap index 9aa469b..5e8f5e4 100644 --- a/src/zcl_demo_abap_dtype_dobj.clas.abap +++ b/src/zcl_demo_abap_dtype_dobj.clas.abap @@ -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`. diff --git a/src/zcl_demo_abap_prog_flow_logic.clas.abap b/src/zcl_demo_abap_prog_flow_logic.clas.abap index e4998ca..34ca4a4 100644 --- a/src/zcl_demo_abap_prog_flow_logic.clas.abap +++ b/src/zcl_demo_abap_prog_flow_logic.clas.abap @@ -415,7 +415,7 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION. AND `ha` && `llo` = "Constructor expression - AND CONV i( '2.03' ) = num + AND VALUE i( ) = 0 AND VALUE string_table( ( `a` ) ( `b` ) ( `c` ) ) = str_table "Table expression diff --git a/src/zcl_demo_abap_string_proc.clas.abap b/src/zcl_demo_abap_string_proc.clas.abap index 027f426..683ff90 100644 --- a/src/zcl_demo_abap_string_proc.clas.abap +++ b/src/zcl_demo_abap_string_proc.clas.abap @@ -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 '.