1. The static method of the cl_abap_list_utilities => dynamic_output_length class can calculate the string length. The output below is 7
Data: lv_str type string, lv_len type I, lv_char type C. lv_str = 'abc China '. * lv_char = lv_str + 3 (0 ). lv_len = cl_abap_list_utilities => dynamic_output_length (lv_str ). * lv_len = strlen (lv_str ). * lv_len = cl_abap_list_utilities => defined_output_length (lv_str ). write lv_len.
2. The strlen function only obtains the number of characters in the string and cannot obtain the string length. The output below is 5.
Data: lv_str type string, lv_len type I, lv_char type C. lv_str = 'abc China '. * lv_char = lv_str + 3 (0 ). * lv_len = cl_abap_list_utilities => dynamic_output_length (lv_str ). lv_len = strlen (lv_str ). * lv_len = cl_abap_list_utilities => defined_output_length (lv_str ). write lv_len.
There are many other static methods in the class cl_abap_list_utilities, which are worth studying.
Calculate the length of a string