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 problem

Former Member
0 Likes
1,097

Hi all ,

i am upload a file using methods.

but the file is not completly upload.

some fields are missing.

Thanks in advance

venkat

7 REPLIES 7
Read only

Former Member
0 Likes
1,077

Hi,

can i know the code which you wrote for uploading.

Read only

0 Likes
1,077

Hi,

i am using the method cl_gui_frontend_services--> gui_upload.

in that file

1000// / // / / //

// /00220201// // /

after upload i will get only the first line.

Thabks in advance

Venkata

Read only

0 Likes
1,077

Use following code:

OPEN DATASET gv_pathfile IN TEXT MODE FOR INPUT ENCODING DEFAULT.

do.

*Reading data from the file

read dataset gv_pathfile into gv_string.

if sy-subrc = 0.

.....................

...............

else.

exit.

endif.

enddo.

close dataset gv_pathfile.

Please reward if useful

Read only

matt
Active Contributor
0 Likes
1,077

A bit more detail please.

Read only

karol_seman
Active Participant
0 Likes
1,077

U need to define internal table into which you load data.

U can use following code:


DATA: i_file like rlgrap-filename value 'D:\ceeG01.csv'.
DATA: begin of it_datatab occurs 0,
  row(500) type c,
 end of it_datatab.

  CALL FUNCTION 'GUI_UPLOAD'
       EXPORTING
            filename        = 'D:\ceeG01.csv'
            filetype        = 'ASC'
       TABLES
            data_tab        = it_datatab 
       EXCEPTIONS
            file_open_error = 1
            OTHERS          = 2.

Read only

Former Member
0 Likes
1,077

Hi,

Use Function Modules instead of Methods for upload , It will be easy for u to upload file.

Let me see your coding first, then only we can say some thing about it.

Regards,

Nagarjun Devavarapu

Read only

Former Member
0 Likes
1,077

Hi Venkat,

i am sending some sample code check it once.Its work for any type of file u upload..

SAMPLE CODE:

----


  • Internal Table

----


DATA: BEGIN OF gt_data OCCURS 0,

matnr(20), "Material Number

mbrsh(20), "Account Group

mtart(20), "Material Type

meins(20), "Base Unit Of Measure

maktx(20), "Material Description

END OF gt_data.

----


  • Selection-screen

----


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

PARAMETERS: p_file LIKE rlgrap-filename.

SELECTION-SCREEN : END OF BLOCK b1.

----


  • Select the File

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

PERFORM fetch_file.

START-OF-SELECTION.

----


  • Fetch Data From XLS File

----


PERFORM fetch_data.

&----


*& Form fetch_file

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fetch_file .

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

  • FIELD_NAME = ' '

IMPORTING

file_name = p_file.

gv_infile = p_file.

ENDFORM. " fetch_file

&----


*& Form fetch_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fetch_data .

refresh : gt_data. "Clear Body Of the Internal Table

clear : gt_data. "Clear Header Line

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gv_infile

filetype = 'ASC'

has_field_separator = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = gt_data

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.

ENDFORM. " fetch_data

Reward Points if helpful.

Kiran Kumar G.A