*&---------------------------------------------------------------------* *& Report _LIB_BASIC_06_STRING *& *&---------------------------------------------------------------------* *& Description: *& String Operations *& *& Technical description: *& *& More Information: *& *&---------------------------------------------------------------------* *& Change log: *& Date Author Action *& xxxx-xx-xx ABAP_ACADEMY Created *& *&---------------------------------------------------------------------* REPORT _LIB_BASIC_06_STRING. *-----------------------------------* * DECLARATIONS TYPES: tv_path TYPE c LENGTH 255, tv_path_part TYPE c LENGTH 30. CONSTANTS: gc_original_path TYPE tv_path VALUE '\\192.168.101.168\root\Documents\_PROJECTS\ABAP Academy\Assignment Codes\xyz_aaa_basic_06_string.abap', gc_project_root TYPE tv_path VALUE '\\192.168.101.168\root\'. CONSTANTS: BEGIN OF gc_separator, win TYPE c VALUE '\', unix TYPE c VALUE '/', END OF gc_separator. DATA: gv_project_path TYPE tv_path, gv_length_path TYPE i, gv_length_root TYPE i, gv_folder_document TYPE tv_path_part, gv_folder_scope TYPE tv_path_part, gv_folder_project_name TYPE tv_path_part, gv_folder_area TYPE tv_path_part, gv_file_name TYPE tv_path_part, gv_file_extension TYPE c LENGTH 4. *-----------------------------------* * MAIN LOGIC " Display original path WRITE: / 'Original Path: ', gv_project_path. SKIP. ULINE. *------------------------------* " CONDENSE - Optimize path string by removing reduntant spaces between two words in text " Remove leading, closing and consecutive blanks CONDENSE gv_project_path. WRITE: / 'CONDENSE: Removed leading, closing and consecutive blanks: ', gv_project_path. " Remove all blanks CONDENSE gv_project_path NO-GAPS. WRITE: /, 'CONDENSE using NO-GAPS: Removed all blanks: ', gv_project_path. SKIP. ULINE. *------------------------------* " STRLEN - Get string length WRITE: / 'STRLEN: Path Length: ', gv_length_path. SKIP. ULINE. *------------------------------* " SHIFT - Remove ROOT part form the string by moving whole string " Remove first two '\\' by using SHIFT statement WRITE: / 'SHIFT: Shifted Path to Left (Deleted Leading ', gc_separator-win, '): ', gv_project_path. " Shift all remaining part letters from path containing ROOT path WRITE: /, 'SHIFT: Shifted Path to Left (Deleted ROOT directory): ', gv_project_path. SKIP. ULINE. *------------------------------* " REPLACE - Change Windows separator '\' to Unix '/' WRITE: / 'REPLACE: Windows separator replaced with Unix one: ', gv_project_path. SKIP. ULINE. *------------------------------* " SPLIT - Get the name of file WRITE: / 'SPLIT: Document Folder - ', 35 gv_folder_document. WRITE: / 'SPLIT: Scope Folder - ', gv_folder_scope UNDER gv_folder_document. WRITE: / 'SPLIT: Project Name Folder - ', gv_folder_project_name UNDER gv_folder_document. WRITE: / 'SPLIT: Project Area Folder - ', gv_folder_area UNDER gv_folder_document. WRITE: /, 'SPLIT: Filename - ', gv_file_name UNDER gv_folder_document. SKIP. ULINE. *------------------------------* " DIRECT PLACEMENT " Change filename prefix from 'xyz'to 'zaa' " string+offset(length). In this case is offset '0' so there is no need to mention it in the code WRITE: / 'DIRECT PLACEMENT: Prefix of filename changed to ZAA - ', gv_file_name. " Change string in the middle. 'aaa' to 'hpl' " string+offset(length) WRITE: /, 'DIRECT PLACEMENT with Offset: Project scope of filename changed to HPL - ', gv_file_name. SKIP. ULINE. *------------------------------* " CONCATENATE - joining strings together " Since no '.abap' extension exists in real, change it to '.txt' WRITE: / 'Filename - ', gv_file_name. WRITE: / 'File Extension - ', gv_file_extension. " Change file extension to TXT " Join strings together " Modern approach which is not backward compatible *gv_file_name = gv_file_name && '.' && gv_file_extension. WRITE: / 'CONCATENATE: Filename and File Extension joined together - ', gv_file_name. SKIP. ULINE. *------------------------------* " CHANGE CASE - Get filename in Uppercase WRITE: / 'TO_UPPER( ): Filename in Uppercase: ', gv_file_name. WRITE: / 'TO_LOWER( ): Filename in Lowercase: ', gv_file_name.