Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Search a File into a PC

Former Member
0 Kudos

Hi Experts, I need a FM to search a file into a directory of a PC. The class cl_gui_frontend_services is not good for me because i don´t execute ths SAP GUI, I´m conecting with SAP via WEB.

Thanks.

17 REPLIES 17

athavanraja
Active Contributor
0 Kudos

you shoul use html code

<input type="file" that will automatically bring the file browse button

0 Kudos

Thanks but I need to know if a file exists in a PC but from a FM in SAP.

0 Kudos

i dont know of a FM which can work from web. but you can do this (checking whether file exists in users comupter) using javascript file system object.

check this link for sample code

http://www.codeproject.com/useritems/JavaScript__File_Handling.asp

0 Kudos

thanks, but I only need a FM to search a file into a PC that not use the GUI.

Former Member
0 Kudos

Hi,

The function module 'RZL_READ_DIR_LOCAL' can be used to retrieve the files in the application server directory.

CALL FUNCTION 'RZL_READ_DIR_LOCAL'

EXPORTING

NAME =

TABLES

FILE_TBL =

  • EXCEPTIONS

  • ARGUMENT_ERROR = 1

  • NOT_FOUND = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Regards,

Aparna

0 Kudos

Thanks. I'm trying with this FM and a file stored in my C: and the result is bad.

Do you have an example??

0 Kudos

Do you have an example??

Thank you very much

Former Member
0 Kudos

Hi Jorge,

try this:

DATA: LV_CNT TYPE I,

LS_FILENAME TYPE FILE_TABLE,

LT_FILENAME TYPE FILETABLE.

*

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES

EXPORTING

DIRECTORY = 'C:\'

FILTER = '.'

FILES_ONLY = 'X'

CHANGING

FILE_TABLE = LT_FILENAME

COUNT = LV_CNT.

*

LOOP AT LT_FILENAME INTO LS_FILENAME.

WRITE: / LS_FILENAME.

ENDLOOP.

Regards, Dieter

0 Kudos

This class is not good for me.

Somebody can help me??

0 Kudos

you are working on webfrontend and all these classes and FMs mentioned here wont work without SAPgui (are you working on BSP?)

you have to follow the approach given in the link i had provided

http://www.codeproject.com/useritems/JavaScript__File_Handling.asp

0 Kudos

Hi Jorge,

can you explane why this CLASS isn't good for you?

Does this class exist?

Which release do you have.

Regards, Dieter

Hi,

forget my question, i see it in your thread

Sorry.

regards, Dieter

Message was edited by:

Dieter Gröhn

0 Kudos

Durairaj Athava I'm usin WebDynpro.

Thanks

0 Kudos

ABAP or JAVA webdynpro?

whatever be the case, i would suggest you to post the question either in java webdynpro or abap webdynpro forum for a quicker response.

Raja

0 Kudos

JAVA webdynpro. Thanks a lot.

0 Kudos

i am not a java expert, but to handle client machine file system from java apps. you should use something like

if ( new java.io.File("C:\test.txt").exists() ) ...

for more on this check this link

http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html

dev_parbutteea
Active Contributor
0 Kudos

Hi,

try this:

data:c_x type c value 'X'.

selection-screen begin of block blk1 with frame title text-000.

parameters : p_file type localfile obligatory,

selection-screen end of block blk1.

at selection-screen on value-request for p_file.

call function 'KD_GET_FILENAME_ON_F4'

exporting

static = c_x

mask = text-013

changing

file_name = p_file

exceptions

mask_too_long = 1

others = 2.

if sy-subrc <> 0.

  • do nothing

endif.

regards,

Sooness

0 Kudos

text-013 = <b>,All Files,..</b>