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

Use of Function Module

Former Member
0 Likes
835

Dear All,

Can anyone tell me how to use the function module

DX_FILE_READ? Also, can I use it for downloading a file from application server?

Thanks.

Regards,

Rupesh

5 REPLIES 5
Read only

Former Member
0 Likes
738

have you tried SE37.COM?

regards,

Guido

Read only

0 Likes
738

Yes, I did but of no use

Regards,

Rupesh

Read only

0 Likes
738

hi Rupesh,

Yes. You can use the function module DX_FILE_READ to read file from Application server.

Regards,

Hema

Read only

Former Member
0 Likes
738

Hi,

go thru this:

FUNCTION dx_file_read.

*"----


""Lokale Schnittstelle:

*" IMPORTING

*" VALUE(FILENAME) LIKE DXFILE-FILENAME

*" VALUE(SERVER) LIKE MSXXLIST-NAME OPTIONAL

*" VALUE(PC) LIKE DXFIELDS-CHECKBOX

*" TABLES

*" DATA_TAB STRUCTURE DXRAWDATA

*" EXCEPTIONS

*" NO_FILE_ON_SERVER

*" NO_DATA_ON_SERVER

*" GUI_UPLOAD_FAILED

*" NO_AUTHORITY

*"----


DATA: l_filename TYPE string,

l_ret_auth LIKE sy-subrc,

l_modetext TYPE xutxt30.

CALL FUNCTION 'DX_AUTH_MAIN'

EXPORTING

mode_desired = 'DISPLAY'

IMPORTING

RETURN = l_ret_auth

MODE_DESIREDT = l_modetext.

IF l_ret_auth <> 0.

MESSAGE e069(s_dx_bapi) with l_modetext

RAISING no_authority.

ENDIF.

CLEAR data_tab.

REFRESH data_tab.

l_filename = filename.

IF pc = c_true.

  • read file from frontend

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = l_filename

has_field_separator = c_false

TABLES

data_tab = data_tab

EXCEPTIONS

OTHERS = 17.

IF sy-subrc <> 0.

MESSAGE e116(lx) WITH filename RAISING gui_upload_failed.

ENDIF.

DELETE data_tab WHERE data IS initial.

RETURN.

ENDIF.

IF server IS INITIAL.

  • read file from this server

OPEN DATASET filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc <> 0.

MESSAGE e105(lx) WITH filename RAISING no_file_on_server.

ENDIF.

READ DATASET filename INTO data_tab-data.

IF sy-subrc <> 0.

CLOSE DATASET filename.

MESSAGE e109(lx) WITH filename RAISING no_data_on_server.

ENDIF.

APPEND data_tab.

DO.

READ DATASET filename INTO data_tab-data.

IF sy-subrc <> 0.

EXIT.

ENDIF.

APPEND data_tab.

ENDDO.

CLOSE DATASET filename.

RETURN.

ENDIF.

  • read file from other server

CALL FUNCTION 'DX_FILE_READ' DESTINATION server

EXPORTING

filename = filename

pc = c_false

TABLES

data_tab = data_tab

EXCEPTIONS

communication_failure = 1

system_failure = 2

OTHERS = 4.

CASE sy-subrc .

WHEN 0.

WHEN '1' OR '2'.

MESSAGE e139(lx) WITH server.

WHEN OTHERS.

MESSAGE e114(lx) WITH filename server.

ENDCASE.

ENDFUNCTION.

Read only

Former Member
0 Likes
738

hi

DX_FILE_READ is used to read the file from PS or AS ....

if you pass X to the PC in exporting parameter it will pick file from Presentation Server ....

or else ir will search for the file in the server which u specified ....