10-18-2007 11:11 AM
Hi guys,
I m trying to upload a excel from presentation server.I m using F4 help for the field to find the location of the file in the presentation server.If i give some file name which doesn't exist in the file path and select execute it is going to dump.So i need to find whether the given file name exists or not in the system.
I have to search whether the give file name in the file path exists in the system or not.How can I do that.Any suggestions please.
Thank you.
10-18-2007 11:14 AM
Hi DP ,
I assume that you are using FM to give the F4 help for the file , in that FM are you handelling the exceptions.
If you do not handle the execptions then the program will Dump.
So please check in your code if the exceptions are commented , if they are the plase uncomment it , and handle the exception by giving some message.
Regards
Arun
10-18-2007 11:15 AM
Hi
May be if you handle the exception for the F4 help FM you may not get the dump itself. Or else you can use the class method cl_gui_frontend_services-FILE_EXIST
to check if the file is present or not in presentation server.
~Ranganath
Reward points for all useful answer !!
10-18-2007 11:16 AM
10-18-2007 11:28 AM
Hi..
You can call the method:
<b>CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST</b>
This method returns whether file exists on Not.
<b>REWARD IF HELPFUL</b>
10-18-2007 11:40 AM
Hi guys,
Thanks for the replies.
I too found the found the method.But I m having problem with the parameters.I m exporting the filename to the funtion module,but i don't find a parameter in the function exporting the result.but there is a parameter resulting.Can anyone tell me what are the parameters should i give for this method.
Thanks.
10-18-2007 11:46 AM
Hi ,
If you are using the method FILE_EXIST , then it is exporting a parameter called RESULT .
If the method return the value of this parameter as <b>X</b> it means that the file exist and if it is blank the the file does not exist.
Regards
Arun
10-18-2007 11:46 AM
Hi
Use the returning arguement to check the result whether file exitst or not ... And pass the file name for the importing arguement FILE to this method.
~Ranganath
10-18-2007 11:47 AM
Hi,
chek the below code
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
EXPORTING
FILE = W_FILENAME
RECEIVING
RESULT = W_RESULT
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
NOT_SUPPORTED_BY_GUI = 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.
IF W_RESULT IS INITIAL.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXIST
EXPORTING
DIRECTORY = W_FILENAME
RECEIVING
RESULT = W_RESULT
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
IF W_RESULT = 'X'.
RC = '1'.
ELSE.
RC = '0'.
ENDIF.
reward if helpful.
Regards,
nagaraj
10-18-2007 12:04 PM
Hi nagraj,
The answer u gave is helpful.I assigned points to u.But i still have a problem.When i gave a filename which doesn't exist (to test the method), it is still returning the result as 'X'.The prog is going for dump.Actually i have to upload only csv file everytime.Does the extension of the filename make any difference to this method.Any suggestions.
Thanks.