‎2007 Dec 21 8:45 AM
Hi friends,
Is there a way to determine the format of the flat file ( eg: Excel, notepad etc ) based on the file path where the file is located.
Thanks in Advance,
Ram.
‎2007 Dec 21 9:13 AM
Hai,
Try like this:
1. Get file using :
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = sy-dynnr
field_name = space
IMPORTING
file_name = p_local.
where P_local is parameter ( p_local TYPE rlgrap-filename MODIF ID m2.)
2. Check file as following:
DATA: lv_file TYPE string, "File path with name
lv_ext(3) TYPE c.
Get file extension
SPLIT p_local AT c_dot INTO lv_file lv_ext.
TRANSLATE lv_ext TO UPPER CASE.
IF file is excel get data from excel sheet
IF lv_ext = 'XLS'.
PERFORM get_xls_file USING lv_file.
ELSE.
Else get file from gui download
PERFORM get_txt_file USING lv_file.
ENDIF. "lv_ext
‎2007 Dec 21 8:56 AM
i can suggest onse solution.
Get the file path. Get the string after last '.'(dot).
Compare this string with known file extensions.
Award Points if useful
Bhupal
‎2007 Dec 21 9:12 AM
Hi Ram,
U can mention the files as
c_doa0001 sy-datum sy-uzeit '-' t_vsart-vsart '.txt'
this file is text file..which is gonna store in application server..under the repectively path..
Like that u can give the .XXX respective extension..to XL or watever u nee...
Regards,
Ari
‎2007 Dec 21 9:13 AM
Hai,
Try like this:
1. Get file using :
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = sy-dynnr
field_name = space
IMPORTING
file_name = p_local.
where P_local is parameter ( p_local TYPE rlgrap-filename MODIF ID m2.)
2. Check file as following:
DATA: lv_file TYPE string, "File path with name
lv_ext(3) TYPE c.
Get file extension
SPLIT p_local AT c_dot INTO lv_file lv_ext.
TRANSLATE lv_ext TO UPPER CASE.
IF file is excel get data from excel sheet
IF lv_ext = 'XLS'.
PERFORM get_xls_file USING lv_file.
ELSE.
Else get file from gui download
PERFORM get_txt_file USING lv_file.
ENDIF. "lv_ext
‎2007 Dec 21 9:40 AM