05-08-2013 3:55 PM
Hi Gurus,
I ahve developed one program where it will accept single file for upload.
I want to upload the mulple files in same program, not able to code please suggest how to do it in attached program.
Please suggest asap....
Moderator message: Formulations like "ASAP" , “Urgent “ and "Please send step by step" are easilyinterpreted as orders to people who offer help for nothing more but the satisfaction to being helpful.
Thank you for taking more time to understand community help.
regards
Ravi
Message was edited by: Kesavadas Thekkillath
05-08-2013 11:52 PM
Hi,
If your files are in a directory in application server. You can use the FM EPS2_GET_DIRECTORY_LISTING to get the list of files in that directory. Then loop pn the return table gt_filelist and do a OPEN DATASET, READ DATASET and CLOSE DATASET to read the various file entries in a single internal table or multiple ones as suitable to you.
CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING'
EXPORTING
iv_dir_name = p_fapp "Directory path
TABLES
dir_list = gt_filelist "Table with list of files in folder
EXCEPTIONS
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT gt_filelist INTO w_filelist.
*Check keyword documentation to find how these statements work
OPEN DATASET...
READ DATASET...
CLOSE DATASET...
ENDLOOP.
There is a similar FM for Presentation server also. FM TMP_GUI_DIRECTORY_LIST_FILES same logical construct would help you in that case too.
Cheers,
Arindam
05-09-2013 4:39 AM
Hi,
In the code only one parameter(p_infile) is declared to get the input file location from user. Please create a second parameter similar to p_infile, to accept the file location of second file that you want to upload.
Best practice would be to write the common logic such as "on value request" on the input fields and the file upload logic, in subroutines and reuse the subroutines for both the parameters.
Regards,
Kartik
05-09-2013 5:03 AM
05-09-2013 5:25 AM
Why dont you have your paramters as select options which will allow use to enter multiple paths. Then for each path use GUI_UPLOAD
05-09-2013 5:53 AM
Couple of points to note:
You can replace this with the method CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG( ) and pass the 'X' to the param MULTISELECTION. Multiple files can be selected by pressing the Ctrl key & are returned to the caller via the FILE_TABLE param.
BR,
Suhas
PS - If you have aversion to calling methods , then you can use the unreleased FM ITS_FILE_OPEN_DIALOG. I won't do that personally though!
05-09-2013 9:16 AM
Hi Ravi,
Please use the below FM:
value_tab table must have all the files to be uploaded.
return_tab table will have the user selected files.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'INFTY'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_INFTY' * Pass your selection screen field name
window_title = text-004
value_org = 'S'
multiple_choice = 'X' * For multiple chice please mark it as 'X'.
TABLES
value_tab = it_infty
return_tab = lt_ret
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc IS INITIAL.
LOOP AT lt_ret INTO ls_ret.
* Here you can do the process with the user selected files.
ENDLOOP .
With Regards,
Giriesh M
05-09-2013 9:27 AM
Hi Ravi Kumar,
Please check the below Function Module and also refer the below document for the further coding help.
'TMP_GUI_DIRECTORY_LIST_FILES', 'GUI_UPLOAD'
http://wiki.sdn.sap.com/wiki/display/ABAP/Send+Emails+with+Attachments+of+any+Format
Hope this helps