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

Dump while selecting the folder for EXPORT

Former Member
0 Likes
1,077

We are on ECC6.0 & one of the old programs uses SKTX_DIRECTORY_SELECT.

Can I use CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE for my purpose to choose the folder.

Thanks,

Kiran

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
1,030

Hi Kiran, <li>I could not find that function module SKTX_DIRECTORY_SELECT in 4.6 and ECC 6.0 also. But anyhow you seem to be looking for function module or method which needs to select directory with a dialog. <li>Try this way.

REPORT ztest_program.
DATA: window_title TYPE string VALUE 'Set download directory'.
DATA: sapworkdir   TYPE string VALUE 'C:\'.

PARAMETERS folder TYPE string.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR folder.
  CALL METHOD cl_gui_frontend_services=>directory_browse
    EXPORTING
      window_title         = window_title
      initial_folder       = sapworkdir
    CHANGING
      selected_folder      = folder
    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.
  IF folder IS INITIAL.
    MESSAGE 'No folder has been selected' TYPE 'S'.
    EXIT.
  ENDIF.

START-OF-SELECTION.
  WRITE folder.
Thanks Venkat.O

8 REPLIES 8
Read only

former_member156446
Active Contributor
0 Likes
1,030

Make sure the types of initial folder and picked folders are strings.

CL_GUI_FRONTEND_SERVICES=>directory_browse( exporting initial_folder = initialFolder
                               changing selected_folder = pickedFolder
                               exceptions cntl_error = 1
                                          error_no_gui = 2
                                          not_supported_by_gui = 3 ).

Read only

0 Likes
1,030

Initial Folder is not a mandatory one. Can you please explain the purpose of this.

Thanks,

Kiran

Read only

0 Likes
1,030

It will give you a popup which will allow to browse the directories in windows.

Read only

0 Likes
1,030

Thanks. But when I select a folder, it doesn't come on to the parameter box.

Thanks,

Kiran

Read only

0 Likes
1,030

try using DIRECTORY_GET_CURRENT method of the class after DIRECTORY_BROWSE

Read only

0 Likes
1,030

Hi Kartik,

That did not work.

data: p_sel_folder type string,

p_ini_folder type string.

CALL METHOD cl_gui_frontend_services=>directory_browse

EXPORTING

window_title = 'Choose a Folder for the Export Data.'

initial_folder = p_ini_folder

CHANGING

selected_folder = p_sel_folder

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.

CALL METHOD cl_gui_frontend_services=>directory_get_current

CHANGING

current_directory = p_sel_folder

EXCEPTIONS

directory_get_current_failed = 1

cntl_error = 2

error_no_gui = 3

not_supported_by_gui = 4

others = 5.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Thanks,

Kiran

Read only

venkat_o
Active Contributor
0 Likes
1,031

Hi Kiran, <li>I could not find that function module SKTX_DIRECTORY_SELECT in 4.6 and ECC 6.0 also. But anyhow you seem to be looking for function module or method which needs to select directory with a dialog. <li>Try this way.

REPORT ztest_program.
DATA: window_title TYPE string VALUE 'Set download directory'.
DATA: sapworkdir   TYPE string VALUE 'C:\'.

PARAMETERS folder TYPE string.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR folder.
  CALL METHOD cl_gui_frontend_services=>directory_browse
    EXPORTING
      window_title         = window_title
      initial_folder       = sapworkdir
    CHANGING
      selected_folder      = folder
    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.
  IF folder IS INITIAL.
    MESSAGE 'No folder has been selected' TYPE 'S'.
    EXIT.
  ENDIF.

START-OF-SELECTION.
  WRITE folder.
Thanks Venkat.O

Read only

Former Member
0 Likes
1,030

Thanks Venkat.

I forgot to pass my directory back to selection-screen parameter.

Regds,

Kiran