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: 

uploading file from Application server

Former Member
0 Kudos
879

Hi Experts

I am writing a report for uploading and reading a .csv file from the application server.

what function module shd i use for these:

1> Upload file : so that user can searcg the file from application server.

2> Read file : Read the uploaded file .

Regards

Dhanya

1 ACCEPTED SOLUTION

Former Member
0 Kudos
161

Use gui_upload method of CL_GUI_FRONTEND_SERVICES class...

anything you want to do between AS and presentation layer, please use methods of this class...

Regards

Puru

9 REPLIES 9

Former Member
0 Kudos
162

Use gui_upload method of CL_GUI_FRONTEND_SERVICES class...

anything you want to do between AS and presentation layer, please use methods of this class...

Regards

Puru

0 Kudos
161

Thanks puru

May i have the sample code for that. I m new to Abap.

0 Kudos
161

DATA l_file_length TYPE i.

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = a_full_filename

filetype = a_filetype

  • HAS_FIELD_SEPARATOR = SPACE

  • HEADER_LENGTH = 0

read_by_line = 'X'

  • DAT_MODE = SPACE

  • CODEPAGE = SPACE

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

IMPORTING

filelength = l_file_length

  • HEADER =

CHANGING

data_tab = at_stream

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

not_supported_by_gui = 17

error_no_gui = 18

OTHERS = 19

.

IF sy-subrc > 0.

CALL METHOD me->handle_up_download_error

EXPORTING

im_subrc = sy-subrc

im_download = space

im_called_method = 'CL_APL_ECATT_EXT_DATA->UPLOAD_CALL'

  • IM_PREVIOUS =

.

ENDIF.

If you want more example.. Just use Where-used for GUI_UPLOAD method.. There will more than 10 examples on each server for this.

Former Member
0 Kudos
161

Refer this link

http://www.sapdevelopment.co.uk/file/file_updown.htm

*   Retrieve Data file from Application server(Upload from Unix)
DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

    OPEN DATASET i_file FOR INPUT IN TEXT MODE.
    IF sy-subrc NE 0.
      MESSAGE e999(za) WITH 'Error opening file' i_file.
    ENDIF.
    DO.
*     Reads each line of file individually
      READ DATASET i_file INTO wa_datatab.
*     Perform processing here
*     .....   
    ENDDO.

Former Member
0 Kudos
161

Hi Dhanya,

For uploading the file from application server u can use

UPLOAD_FILES function module.

regards ,

Santosh Thorat

Former Member
0 Kudos
161

hi dhanya,

u can use the fm F4_FILENAME for the user to searcrh for the file

and WS_UPLOAD to upload to the aplication server..

after that u can open and read the file...

folllowing are the links with sample code which can help u

http://abapexample.blogspot.com/

http://www.sap-img.com/ab004.htm

and follow the procedure given above by judith for opening and reading the file

hope this helps u a bit,

all the best,

regards,

sampath

  • mark helpful answers

0 Kudos
161

Hi Sampath

I think F4_FILENAME for the user to search for the file

and WS_UPLOAD to upload from "Presentation Server".

I m looking for Application Server.

Former Member
0 Kudos
161

Hi dhanya,

am sorry for that..my mistake..

however try these fm's

EPS_GET_DIRECTORY_LISTING ---puts result into internal table but doesnt prompt...

SAPDMC/LSM_F4_SERVER_FILE --prompts for the selecvtion

hope this helps u a bit,

all the best,

regards,

sampath

  • mark helpful answers

Message was edited by:

sampath pilla

Former Member
0 Kudos
161

solved.