*&---------------------------------------------------------------------* *& Report ZLR_LIB_HPL_CH_01_VOWELS *& *&---------------------------------------------------------------------* *& Description: *& Return the number of vowels in a string *& Create a function that'll return an integer of the number of vowels *& found in a string. This is a great way to practice determining the *& features of a dataset. If you use JavaScript later in your career, *& you'll be well-prepared to determine what datasets (or just strings) *& consist of. If you feel like an extra challenge, consider returning *& the number of characters. *& *& Technical description: *& *& *&---------------------------------------------------------------------* *& Change log: *& Date Author Action *& XXXX-XX-XX ABAP ACADEMY Created *& *&---------------------------------------------------------------------* REPORT zlr_lib_hpl_ch_01_vowels. *-----------------------------------* * DECLARATIONS CONSTANTS: gc_original_string type string VALUE 'Enjoy coding', gc_list_of_vowels type c LENGTH 6 VALUE 'aeiouy'. DATA: gv_vowels_counter type i, gv_string_offset type i, gv_lenght_of_original_string type i, gv_current_char_from_string type c. *-----------------------------------* * MAIN LOGIC " Get the lenght of original string to be able to know how many times " we need to do DO cycle gv_lenght_of_original_string = strlen( gc_original_string ). " Vowels couunting algorithm DO gv_lenght_of_original_string TIMES. gv_current_char_from_string = gc_original_string+gv_string_offset(1). IF gv_current_char_from_string CA gc_list_of_vowels. gv_vowels_counter = gv_vowels_counter + 1. ENDIF. gv_string_offset = gv_string_offset + 1. ENDDO. WRITE: 'Original String:', gc_original_string. WRITE: / 'Number of Vowels:', gv_vowels_counter.