Application Development and Automation 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: 
Read only

Error with Filename

Former Member
0 Likes
1,168

Hi,

I am trying to get an Excel File Name using the function module KD_GET_FILENAME_ON_F4 on a Module Pool program. I can see the name of the file but when I click on it it just does not move the filename to the screen field.

Using the DEBUGger, I found that in KD_GET_FILENAME_ON_F4 when he calls the FM WS_FILENAME_GET it returns sy-subrc as 4 (selection error).

Could you please help me with this problem?

Here is the code sample.

Best regards.

********************************************************************************************

CONSTANTS: C_XLS(25) TYPE C VALUE ',Arquivos do Excel,*.XLS'.

CONCATENATE RLGRAP-FILENAME C_XLS INTO V_TEMPARQ.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

STATIC = ' '

MASK = V_TEMPARQ

CHANGING

FILE_NAME = RLGRAP-FILENAME.

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
981

Hi,

Try with fm OCS_FILENAME_GET may suit your need

aRs

8 REPLIES 8
Read only

Former Member
0 Likes
981

Check this..

CONSTANTS: C_XLS(25) TYPE C VALUE <b>',Arquivos do Excel,*.XLS'.</b>

CONCATENATE RLGRAP-FILENAME C_XLS INTO V_TEMPARQ.

CONCATENATE RLGRAP-FILENAME '*.xls' INTO V_TEMPARQ.

Thanks

Mahesh

Read only

0 Likes
981

It has not worked. =/

In the same program, the user can upload TXT and XLS files. With txt it's ok, but the excel files just does not work.

=/

Thank's and regards.

Read only

Former Member
0 Likes
981

Check the below Code


CONSTANTS: C_XLS(25) TYPE C VALUE ',Arquivos do Excel,*.XLS'.
data:  V_TEMPARQ(25) type c.

data:  file_name like RLGRAP-FILENAME value ''.

move c_xls to v_temparq.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
STATIC = ' '
MASK = V_TEMPARQ
CHANGING
FILE_NAME = file_name.

write:/ file_name.

reward if helpful

Regards

Prax

Read only

0 Likes
981

I tried it but it did not worked. =(

Thank's for your help.

Read only

former_member194669
Active Contributor
0 Likes
981

Hi,

Try to use


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.

aRs

Read only

0 Likes
981

I can see the files listed in directory C:/ but how can i make the user search the directory he wants the same way that KD_GET_FILENAME_ON_F4 do?

Read only

former_member194669
Active Contributor
0 Likes
982

Hi,

Try with fm OCS_FILENAME_GET may suit your need

aRs

Read only

0 Likes
981

It worked!

Thanks ARS... I've added reward points for you all.

Regards!!!