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

CL_GUI_FRONTEND_SERVICES

Former Member
0 Likes
399

I am currently amending a program which makes use of the class CL_GUI_FRONTEND_SERVICES with method - file_open_dialog, to support the selection of a file from any of our network directories.

At the moment when the program is executed in foreground, and a push button is used to select the name of a file to be uploaded, the directory name always appears to default to the - SAP Work Directory on my 'C' drive. What I would like to happen is for the directory path to default to the last one used by the user. This functionality appears to happen OK with one of our old EBP programs which use the function - KD_GET_FILENAME_ON_F4, however I believe this function should really no longer be used.

Does anyone how I might be able to achieve the required functionality using - CL_GUI_FRONTEND_SERVICES?

Thanks

Claire Crosby-Clarke

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
349

If you don't specify a default directory, then you will get the functionality that you require. It is performing like this in my system. I browse to a different directory, the next time I do F4, it goes to that last directory.



report zrich_0001.

data: ifiletable type filetable.
data: xfiletable like line of ifiletable.
data: rc type i.

parameters: p_file1 type localfile default'C:test.txt'.

at selection-screen on value-request for p_file1.

  call method cl_gui_frontend_services=>file_open_dialog
    changing
      file_table              = ifiletable
      rc                      = rc
    exceptions
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      others                  = 4.
  .
  read table ifiletable into xfiletable index 1.
  if sy-subrc = 0.
    p_file1 = xfiletable-filename.
  endif.

Regards,

Rich Heilman

I am currently amending a program which makes use of the class CL_GUI_FRONTEND_SERVICES with method - file_open_dialog, to support the selection of a file from any of our network directories.

At the moment when the program is executed in foreground, and a push button is used to select the name of a file to be uploaded, the directory name always appears to default to the - SAP Work Directory on my 'C' drive. What I would like to happen is for the directory path to default to the last one used by the user. This functionality appears to happen OK with one of our old EBP programs which use the function - KD_GET_FILENAME_ON_F4, however I believe this function should really no longer be used.

Does anyone how I might be able to achieve the required functionality using - CL_GUI_FRONTEND_SERVICES?

Thanks

Claire Crosby-Clarke

1 REPLY 1
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
350

If you don't specify a default directory, then you will get the functionality that you require. It is performing like this in my system. I browse to a different directory, the next time I do F4, it goes to that last directory.



report zrich_0001.

data: ifiletable type filetable.
data: xfiletable like line of ifiletable.
data: rc type i.

parameters: p_file1 type localfile default'C:test.txt'.

at selection-screen on value-request for p_file1.

  call method cl_gui_frontend_services=>file_open_dialog
    changing
      file_table              = ifiletable
      rc                      = rc
    exceptions
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      others                  = 4.
  .
  read table ifiletable into xfiletable index 1.
  if sy-subrc = 0.
    p_file1 = xfiletable-filename.
  endif.

Regards,

Rich Heilman