‎2008 Jul 28 1:21 PM
Hi all ,
i am upload a file using methods.
but the file is not completly upload.
some fields are missing.
Thanks in advance
venkat
‎2008 Jul 28 1:22 PM
‎2008 Jul 28 1:31 PM
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
‎2008 Jul 28 1:36 PM
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
‎2008 Jul 28 1:22 PM
‎2008 Jul 28 1:40 PM
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.
‎2008 Jul 28 1:41 PM
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
‎2008 Jul 28 1:50 PM
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