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

function module to upload and read the text file

Former Member
0 Likes
9,139

can anybody give me the function module to upload and read the text file

can anybody give me the function module to upload and read the text file

6 REPLIES 6
Read only

Former Member
0 Likes
3,227

Use GUI_UPLOAD and READ_TEXT Fm.

Amit.

Read only

Former Member
0 Likes
3,227

hi

WS_UPLOAD and UPLOAD are the function modules you can use to upload a file in text format

Read only

Former Member
0 Likes
3,227

Hi

To upload from the text file u can either use the funcion module

-- GUI UPLOAD and

-- UPLOAD

In these function modules you pass the name of the internal table as the parameter .

And then,

you can loop at that internal table to read the contents in the internal table.

Reward if useful.

Best Regards

Read only

Former Member
0 Likes
3,227

Hi,

You can use this code to upload the text file.

DATA : v_file TYPE string.

----


  • SELECTION SCREEN

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_file TYPE rlgrap-filename.

SELECTION-SCREEN END OF BLOCK b1.

----


  • AT SELECTION SCREEN ON VALUE-REQUEST

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = ' '

IMPORTING

file_name = p_file.

----


  • START-OF-SELECTION

----


START-OF-SELECTION.

v_file = p_file.

*gui upload

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_file

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = it_vendor

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

OTHERS = 17.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Here, wehen you press F4, it will ask to select the file.

Then you can select the file.

and after that i sued the FM GUI_UPLOAD, to insert the data into Internal table from the text file.

here this parameter is Important " has_field_separator ".

If you typing the text by giving TAB space between evry filed, you need to give "X".

And one more thing, you asked to Read the text file:

This I dint understand.

Please elaborate your requirement.

Regards

Sandeep Reddy

Read only

Former Member
0 Likes
3,227

Hi Chaitra!!

For uploading text file

we use gui_upload

and for reading text

we use read_text FM.

rewrd points.

Read only

Former Member
0 Likes
3,227

Hi,

i want to know how to use upload notepad in function modules.

what r the parameters needed to import from main program to function module program of notepad upload..

Thank You.