07-11-2014 12:20 AM
Hello gurus,
I'm using FM F4_FILENAME, but I need filter for excel only, I want validate string like this:
P_FileName = 'C:\Documents and Settings\lfranco\Mis documentos\Mis imágenes\INDICADORES POOL\Prueba_Layout.xlsx'
I wnat validate this string finish in .xls or .xlsx
Could any one help me? I
07-11-2014 4:00 AM
Hi Luis,
SEARCH gv_string for '.xls'.
IF sy-subrc eq 0.
..........
Regards,
Archer
07-11-2014 1:00 AM
Hi Luis,
You can to use SPLIT sentence.... Like this
DATA: p_filename TYPE string,
data1 TYPE string,
data2 TYPE string.
p_filename = 'C:\Documents and Settings\lfranco\Mis documentos\Mis imágenes\INDICADORES POOL\Prueba_Layout.xlsx'.
SPLIT p_filename AT '.' INTO data1 data2.
Work validating data2 variable ----> XLS or XLSX.
Regards,
07-11-2014 2:56 AM
There are several options.
1- Use the cl_gui_fronend_services=>FILE_OPEN_DIALOG( . . .)
You can set the parameter FILE_FILTER = "X.XLS"
this will let user open only XLS type of files.
2-. Incase you want to check the file name after callinf f4 (What ever logic you are following) You can use string functions.
I can think of s simple one like.
data: filename type string VALUE 'C:/abc/XYZ/me.xls',
xls type boolean VALUE abap_false.
(Assuming you want to check for .xls i.e 4 chars).
if '.xls' = substring( VAL = filename off = strlen( filename ) - 4 len = 4 ).
xls = abap_true.
endif.
I hope this is what you were after.
Regards,
07-11-2014 4:00 AM
Hi Luis,
SEARCH gv_string for '.xls'.
IF sy-subrc eq 0.
..........
Regards,
Archer
07-11-2014 5:55 AM
Hi,
You may use the below code.
SPLIT LS_PATH AT LS_DELI INTO LS_PATH LS_EXTENSION.
TRANSLATE LS_EXTENSION TO UPPER CASE.
IF P_UP EQ 'X'.
IF LS_EXTENSION NE TEXT-012 AND LS_EXTENSION NE TEXT-023 AND LS_EXTENSION NE TEXT-024. "XLS/XLSX/CSV
MESSAGE E023(ZXXX). "Incorrect file extension(valid only XLS/XLSX/CSV)
ENDIF.
ELSE.
IF LS_EXTENSION NE TEXT-012 AND LS_EXTENSION NE TEXT-024. "XLS/CSV
MESSAGE E024(ZXXX). "Incorrect file extension(valid only XLS/CSV)
ENDIF.
ENDIF.
Regards,
Vadamalai A
07-11-2014 5:56 AM
Hi,
You may use the below code.
SPLIT LS_PATH AT LS_DELI INTO LS_PATH LS_EXTENSION.
TRANSLATE LS_EXTENSION TO UPPER CASE.
IF P_UP EQ 'X'.
IF LS_EXTENSION NE TEXT-012 AND LS_EXTENSION NE TEXT-023 AND LS_EXTENSION NE TEXT-024. "XLS/XLSX/CSV
MESSAGE E023(ZXXX). "Incorrect file extension(valid only XLS/XLSX/CSV)
ENDIF.
ELSE.
IF LS_EXTENSION NE TEXT-012 AND LS_EXTENSION NE TEXT-024. "XLS/CSV
MESSAGE E024(ZXXX). "Incorrect file extension(valid only XLS/CSV)
ENDIF.
ENDIF.
Regards,
Vadamalai A
07-30-2014 9:56 PM
Easiest way is to get the file name and validate based on the code below...
FIND FIRST OCCURRENCE OF '.XLS' IN <filename> IGNORING CASE.
if syst-subrc eq 0.
* send an error message
endif.