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

File Upload

Former Member
0 Likes
540

I need to upload a text file to an ABAP program and needs to replace some characters and save file back again to the source. Which techniques or functions I can use to fulfil this requirement.

Thanks in Advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
513

use GUI_UPLOAD to read the data.

GUI_DOWNLOAD to save the data back.

u can do the required operations on the data on the data present in a internal table after the first fm

santhosh

5 REPLIES 5
Read only

Former Member
0 Likes
514

use GUI_UPLOAD to read the data.

GUI_DOWNLOAD to save the data back.

u can do the required operations on the data on the data present in a internal table after the first fm

santhosh

Read only

Former Member
0 Likes
513

1)upload file using gui_uplaod into internal table.

2) do changes required in internal table.

3)now download file from new internal table to frontend.

Read only

Former Member
0 Likes
513

Hello Eswar,

You can do this by the following way.

Declare a Itab whcih has same structure as that of file.

Use GUI_UPLOAD to upload the file to the itab.,

Change the content of the itab.

Use GUI_DOWNLOAD to download the file.

If useful reward.

Vasanth

Read only

Former Member
0 Likes
513

use fm 'WS_UPLOAD' to upload your data into internal table and then use 'WS_DOWNLOAD' to download the file and use the same filename.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

CODEPAGE = ' '

FILENAME = 'C:\file.txt'

FILETYPE = 'ASC'

HEADLEN = ' '

LINE_EXIT = ' '

TRUNCLEN = ' '

USER_FORM = ' '

USER_PROG = ' '

DAT_D_FORMAT = ' '

IMPORTING

FILELENGTH =

TABLES

DATA_TAB = internal table

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

NO_AUTHORITY = 10

OTHERS = 11

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

FILENAME = 'C:\file.txt '

FILETYPE = 'ASC'

  • MODE = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = internal table name

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_WRITE_ERROR = 2

  • INVALID_FILESIZE = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • NO_AUTHORITY = 10

  • OTHERS = 11

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

i think it should be helpful for u.

Shiba Prasad Dutta

Read only

Former Member
0 Likes
513

Hi

It depends on where the file u have to upload is.

Anyway to upload/download the file you have only two method:

- From Presentation Server: FM GUI_UPLOAD and GUI_DOWNLOAD

- From Application Server: statament OPEN DATASET/CLOSE DATASET

In both case I believe u should upload the data file into an internal table, modify the records in this table and downlad the records of the table to the file.

Max