Below is the SAP ABAP code to split filename from file path, this logic will work for both application server path and presentation server path.
DATA: it_parts TYPE string_table, lv_split TYPE c, lv_lines TYPE i. DATA: lv_path type STRING, lv_file type STRING. lv_path = 'C:\Users\sapnuts\Desktop\sapnuts.xlsx'. IF lv_path IS INITIAL. RETURN. "Return if path is initial ENDIF. IF lv_path CS '/'. lv_split = '/'. ELSEIF lv_path CS '\'. lv_split = '\'. ELSE. lv_file = lv_path. "no path separator is found, then the path must be the filename RETURN. ENDIF. SPLIT lv_path AT lv_split INTO TABLE it_parts . "Split path at "/\" into string table DESCRIBE TABLE it_parts LINES lv_lines. READ TABLE it_parts INTO lv_file INDEX lv_lines. "Return last part
Other alternatives for getting file name from file path, Function Modules CH_SPLIT_FILENAME and RSDS_SPLIT_PATH_TO_FILENAME