‎2009 Apr 16 7:27 AM
Hi Friends
Can anyone help me in this problem.
1.I have to select the particular path
Ex: c:\new folder\prog
2.Then i want to display the list (file names) in that particular folder in ABAP .
Ex: in prog i have 5 excel files.i want to display the list(file names).
3.when i click on the particular file it has to open .
Ex: in prog folder a.doc file is there when i click that file a.doc file has to open using ABAP
Regards
Kiran
‎2009 Apr 16 7:28 AM
‎2009 Apr 16 7:56 AM
Use this method cl_gui_frontend_services=>directory_list_files
‎2009 Apr 16 7:59 AM
Hi,
Check these two FM's
C13G0_GET_FILENAME_F4
KD_GET_FILENAME_ON_F4 Filemanager support to locate file in a directory (on value request)
Regards,
Jyothi CH.
‎2009 Apr 16 8:17 AM
‎2009 Apr 16 9:50 AM
Hello Kiran,
I have developed a demo program now for this. Please check:
REPORT z_test_open_file NO STANDARD PAGE HEADING.
PARAMETERS:
p_folder TYPE localfile.
DATA:
v_folder TYPE string,
it_file_tab TYPE STANDARD TABLE OF file_info,
wa_file_tab TYPE file_info.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
* Browse the directory you want to
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = 'Directory Browse'
initial_folder = 'C:\Documents and Settings\ssaha\Desktop'
CHANGING
selected_folder = v_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.
p_folder = v_folder.
START-OF-SELECTION.
DATA: l_v_count TYPE i.
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = v_folder
* filter = '*.*'
* files_only =
* directories_only =
CHANGING
file_table = it_file_tab
count = l_v_count
EXCEPTIONS
cntl_error = 1
directory_list_files_failed = 2
wrong_parameter = 3
error_no_gui = 4
not_supported_by_gui = 5
OTHERS = 6
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
END-OF-SELECTION.
LOOP AT it_file_tab INTO wa_file_tab.
WRITE: / wa_file_tab-filename HOTSPOT.
ENDLOOP.
AT LINE-SELECTION.
DATA:
l_v_line TYPE i,
l_v_doc TYPE string.
GET CURSOR LINE l_v_line.
IF l_v_line IS NOT INITIAL.
READ TABLE it_file_tab INTO wa_file_tab INDEX l_v_line.
IF sy-subrc = 0.
CONCATENATE v_folder '\' wa_file_tab-filename INTO l_v_doc.
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = l_v_doc
* application =
* parameter =
default_directory = v_folder
* maximized =
* minimized =
* synchronous =
* operation = 'OPEN'
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
synchronous_failed = 8
not_supported_by_gui = 9
OTHERS = 10
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDIF.Hope this helps.
BR,
Suhas
‎2009 Apr 16 10:00 AM
Hi
use F4_IF_FIELD_VALUE_REQUEST or F4IF_INT_TABLE_VALUE_REQUEST to have F4 help for file path,
EPS_GET_DIRECTORY_LISTING to get the list of files.
To open the file when clicked, use interactive reports. Use AT line selection event. IN that get the clicked file name and open it using GUI_UPLOAD.