Copyright 2021 - BV TallVision IT

If you need to select a filename from the server, function module /SAPDMC/LSM_F4_SERVER_FILE can be used. It's output looks a bit outdated (output composed with WRITEstatements) but it does the trick nicely. Considering that this is not a common user matter (chosing files at the back end shouldn't be) here's an example using a class:


CLASS lcl_f4_processing DEFINITION. PUBLIC SECTION. CLASS-METHODS: f4_server_file CHANGING filepath TYPE any. ENDCLASS. "lcl_f4_processing DEFINITION CLASS lcl_f4_processing IMPLEMENTATION. METHOD f4_server_file. DATA: lv_old_filepath TYPE string. lv_old_filepath = filepath. CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE' EXPORTING directory = filepath filemask = ' ' IMPORTING serverfile = filepath EXCEPTIONS canceled_by_user = 1 OTHERS = 2. CASE sy-subrc. WHEN 1. filepath = lv_old_filepath. WHEN 2. MESSAGE 'Server file open error' TYPE 'E'. ENDCASE. ENDMETHOD. "f4_server_file ENDCLASS.

To implement this on a typical selection screen parameter field, follow this example:

PARAMETERS: pa_file2 TYPE c LENGTH 100 
  LOWER CASE VISIBLE LENGTH 56.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_file2.
  lcl_f4_processing=>f4_server_file(
    CHANGING filepath = pa_file2 ).

Alternatively

Do consider the CL_RSAN_UT_FILES=>F4 method. It caters for server file selection too.

Or what about function module F4_DXFILENAME_TOPRECURSION, which even requests whether a file is to be picked up from the presentation server or the backend (application server).