08-20-2009 12:10 AM
hi experts,
how can i validate a path... i tried to use cl_gui_frontend_services=>directory_exist
but it gives me an error
for a local path and an app server path??
thx in advance
08-20-2009 1:20 AM
cl_gui_frontend_services=>directory_exist is for checking directories (not files) on the presentation server ( on local pc, laptop)... You cannot use it for validating path on App server. For App server you need to use open dataset... read dataset. etc...
Edited by: Karthik on Aug 20, 2009 2:21 AM
08-20-2009 2:19 AM
you can use CL_GUI_FRONTEND_SERVICES=>FILE_EXIST to check for file on the desktop.
for the App server use Open dataset. If it fails then there is no file at the specified location.
08-20-2009 4:46 AM
hi Carlos Venturo,
use the method
file_exist from the class cl_gui_frontend_services...
this will return you wether you have the file on the specified path or not...
You can use method CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
Or you can also refer FM's:
CONV_UTIL_CHECK_FILE_EXISTENCE
CV120_DOC_FILE_EXISTENCE_CHECK
CV122_DOC_FILE_EXISTENCE_CHECK
DX_FILE_EXISTENCE_CHECK
PFL_CHECK_OS_FILE_EXISTENCE
Or when you simply upload a file using any FM, just check sy-subrc.
If not equal to 0, then display message Invalid Directory or File Name.
Hope this helps you.
-Thanks & Regards
Saurabh Goel
08-20-2009 4:47 AM
08-20-2009 5:54 AM
cl_GUI_FROMENT_services
from the name itself its says its from front end only. so it doesnt checks app server path.
now. directory_exist from the name it checks directory.
so need fle_exist for a file in presentation server.
and for a path in app server use OPEN DATASET and read dataset.
Edited by: soumya prakash mishra on Aug 20, 2009 10:24 AM
08-20-2009 6:08 AM
08-20-2009 6:15 AM
Hi,
You could use the FM to find the file path. See if this of some to you
parameters: p_fname type string.
data: GV_FPATH TYPE FILEEXTERN.
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
EXPORTING
CLIENT = SY-MANDT
logical_path = 'HOME'
* OPERATING_SYSTEM = SY-OPSYS
* PARAMETER_1 = ' '
* PARAMETER_2 = ' '
* PARAMETER_3 = ' '
* USE_BUFFER = ' '
file_name = P_FNAME
* USE_PRESENTATION_SERVER = ' '
* ELEMINATE_BLANKS = 'X'
IMPORTING
FILE_NAME_WITH_PATH = GV_FPATH
EXCEPTIONS
PATH_NOT_FOUND = 1
MISSING_PARAMETER = 2
OPERATING_SYSTEM_NOT_FOUND = 3
FILE_SYSTEM_NOT_FOUND = 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.
WRITE:/ 'File Path:',GV_FPATH.
08-20-2009 7:04 AM
08-20-2009 8:09 AM
there is no yet a file... im gonna create the pdf. file
all i want to validate is that for example if the user input 'C:\dir\' that PATH exist (NOT FILE), thats it ..
thx for the previous answers
08-20-2009 8:14 AM
Hi,
Check use the method CL_GUI_FRONTEND_SERVICES->DIRECTORY_EXIST for path validation in the presentation server.
Regards,
Vik
08-20-2009 8:15 AM
thats great,.
now
pass your path to the method directory_exist as : 'C:\DIR\' ... case is not a problem and last '\' also is not a problem you may or may not give.
that result parameter = X means directory exist. if not then it ddoesnt
08-20-2009 6:26 AM
Hi Carlos,
you follow the below coding, where you will get to separate validation
for presentation server & application server file path.
FORM present_validation .
DATA: lw_check TYPE c,
lw_file TYPE string.
IF po_psv IS INITIAL.
IF sy-ucomm = 'ONLI' OR sy-ucomm = space.
MESSAGE 'Please input the file name' TYPE lc_e.
ENDIF.
ELSE.
lw_file = po_psv.
lw_check = cl_gui_frontend_services=>file_exist( lw_file ).
IF lw_check IS INITIAL.
MESSAGE 'Please input the correct file path' TYPE lc_e.
ENDIF.
ENDIF.
ENDFORM. " PRESENT_VALIDATION
FORM application_validation .
DATA: lw_file TYPE string.
lw_file = po_asv.
IF po_asv IS INITIAL.
IF sy-ucomm = 'ONLI' OR sy-ucomm = space.
MESSAGE 'Please input the file name' TYPE lc_e.
ENDIF.
ELSE.
OPEN DATASET lw_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
MESSAGE 'Please input the correct file path' TYPE lc_e.
ENDIF.
ENDIF.
ENDFORM. " APPLICATION_VALIDATION
Hope this can solve your problems.
Regards,
Tutun
08-20-2009 6:47 AM
08-20-2009 6:54 AM
Is there a \ or a / at the end of your path?
Maybe
c:\xyz\wherever\whatever
is treated as a file. So please check if your path ends with one ofdof the path delimters and check with
c:\xyz\wherever\whatever\
again
08-20-2009 6:59 AM
hii carlos,
for validation of path on application server
use fm EPS_GET_DIRECTORY_LISTING
Second use FM PFL_CHECK_OS_FILE_EXISTENCE which perfectly working fine for application server file validation. Here also file name is case sensitive. Check this FM in SE37 by giving ur file name and check the check box Lower case
rgrds,
shweta
Edited by: Shweta Joon on Aug 20, 2009 8:01 AM
08-20-2009 8:23 AM
thx for the answer ... but PLEASE read at least the first post.. i'm looking for another way to valdiate because the FM cl_gui_frontend_services=>directory_exist gives me an error!!! it says there is no method (probably because its an old version).. because its works fine in another server...but in the one im programming it doesnt
thx
08-20-2009 8:30 AM
Well my mistake i dint read the first post. In case cl_gui_frontend_services=>directory_exist is not working check if the FM's
PC_CHECK_PATH or PC_CHECK_PATH_WITH_DRIVE work for you.
Regards,
Vik
08-20-2009 8:33 AM
may be you are using a lower version.
any ways
i have tried FM GUI_CREATE_DIRECTORY
if a directory exist it just doesnt harm the directory. but if the directory is not present it create it and raises exception FAILED.
you can try this FM