Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

F4 help for a selection screen parameter with filename created dynamically

Former Member
0 Likes
934

Hi All,

I have a requirement where in an F4 help should be present for a selection screen parameter. After selecting the filepath and clicking OK button on the Dialog, the filename should be dynamically get created in the selection screen parameter field. For example:

if the path is D:\DOCS then at the end of DOCS the filename should automatically get populated.

Like below string:

D:\DOCS\new.txt

Is there any function module or method which does this kind of activity.

Thanks in advance,

Deepak

1 ACCEPTED SOLUTION
Read only

former_member451655
Active Participant
0 Likes
814

hi ,

After You get the File Browsed Name from KD_GET_FILENAME_ON_F4 .just Assign the Required Dynamic File Format to the Return Variable ,

Br

Dilum

Hi All,

I have a requirement where in an F4 help should be present for a selection screen parameter. After selecting the filepath and clicking OK button on the Dialog, the filename should be dynamically get created in the selection screen parameter field. For example:

if the path is D:\DOCS then at the end of DOCS the filename should automatically get populated.

Like below string:

D:\DOCS\new.txt

Is there any function module or method which does this kind of activity.

Thanks in advance,

Deepak

3 REPLIES 3
Read only

Former Member
0 Likes
814

Check this sample code.

PARAMETERS : p_path TYPE RLGRAP-FILENAME.
DATA : v_path1 TYPE string.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE
*  EXPORTING
*    WINDOW_TITLE         =
*    INITIAL_FOLDER       =
  CHANGING
    SELECTED_FOLDER      = v_path1
*  EXCEPTIONS
*    CNTL_ERROR           = 1
*    ERROR_NO_GUI         = 2
*    NOT_SUPPORTED_BY_GUI = 3
*    OTHERS               = 4
        .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
p_path = v_path1.
CALL FUNCTION 'ISH_N2_CREATE_FILENAME'
 EXPORTING
   SS_PFADNAME             = p_path
   SS_FILE_EXTENSION       = 'txt'
   SS_MODE                 = 'PC '
   SS_LETTER               = 'D'
 IMPORTING
   SS_DATEINAME             = p_path
* EXCEPTIONS
*   ERROR                   = 1
*   OTHERS                  = 2
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Read only

former_member451655
Active Participant
0 Likes
815

hi ,

After You get the File Browsed Name from KD_GET_FILENAME_ON_F4 .just Assign the Required Dynamic File Format to the Return Variable ,

Br

Dilum

Read only

Former Member
0 Likes
814

this code will help:

FORM get_filename CHANGING p_filename.

DATA : lv_filename TYPE string,

lv_rc TYPE i,

li_filetable TYPE filetable.

CONSTANTS : lc_fname TYPE string VALUE 'ZRPP4000.XLS',

lc_fpath TYPE string VALUE 'C:\',

lc_extn TYPE string VALUE 'XLS'.

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

default_filename = lc_fname

initial_directory = lc_fpath

default_extension = lc_extn

CHANGING

file_table = li_filetable

rc = lv_rc

EXCEPTIONS

file_open_dialog_failed = 1

cntl_error = 2

error_no_gui = 3

not_supported_by_gui = 4

OTHERS = 5.

IF sy-subrc = 0 .

READ TABLE li_filetable INTO lv_filename INDEX 1.

IF sy-subrc = 0.

p_filename = lv_filename.

ENDIF.

ENDIF.

REFRESH li_filetable.

CLEAR:lv_filename.

ENDFORM. "get_filename

" p_filename is selection screen parameter