08-27-2008 11:58 AM
Hey all,
I have tested (tcode SE37) the FM with following parameters (in the DATA_TAB is one record, only text):
Import-Parameter
FILENAME /usr/sap/tmp/TEST.TXT
FILETYPE ASC
HAS_FIELD_SEPARATOR
HEADER_LENGTH 0
READ_BY_LINE X
DAT_MODE
CODEPAGE
IGNORE_CERR X
REPLACEMENT #
CHECK_BOM
VIRUS_SCAN_PROFILE
NO_AUTH_CHECK
DATA_TAB (in the DATA_TAB is one record, only text)
When I test the FM I'll get the error-code = 1 (file_open_error).
I don't know why the FM could'nt open the file ( i guess it's not a problem of authorization)
What problem can it be?
Thanks,
Lutz
08-27-2008 12:00 PM
GUI_UPLOAD is from workstation to application server!
Your path is on the app server!
Try open dataset....
cheerz
08-27-2008 12:03 PM
Here all information on open dataset http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3c99358411d1829f0000e829fbfe/content.htm
Example for read access
DATA FNAME(60) VALUE 'myfile'.
OPEN DATASET FNAME FOR INPUT.
IF SY-SUBRC = 0.
WRITE / 'File opened'.
.....
ELSE.
WRITE / 'File not found'.
ENDIF.
This example opens the file "myfile" for reading.
Once file is open read it like this
READ DATASET <dsn> INTO <f> [LENGTH <len>].
Edited by: Stephan Kaminski on Aug 27, 2008 1:04 PM
08-27-2008 12:06 PM
Hi,
GUI_UPLOAD works for presentation server only for application server u have to use DATASET
refer below code
*--Local Variables
DATA : l_file TYPE string,
l_line(1000) TYPE c.
*--Clear
CLEAR : l_file.
l_file = p_aifile.
*--Read the data from application server file.
OPEN DATASET l_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE c_ok.
MESSAGE e001.
ENDIF.
*--Get all the records from the specified location.
DO.
READ DATASET l_file INTO l_line.
IF sy-subrc NE c_ok.
EXIT.
ELSE.
SPLIT l_line AT cl_abap_char_utilities=>horizontal_tab
INTO st_ipfile-anlkl
st_ipfile-txt50
st_ipfile-txa50
st_ipfile-anlhtx
st_ipfile-sernr
st_ipfile-invnr
st_ipfile-aktiv
st_ipfile-invzu
st_ipfile-kostl
st_ipfile-raumn
st_ipfile-ord41
st_ipfile-gdlgrp
st_ipfile-herst
st_ipfile-typbz
st_ipfile-afabe
st_ipfile-afasl
st_ipfile-ndjar
st_ipfile-ndper
st_ipfile-tafabe
st_ipfile-tafasl
st_ipfile-tndjar
st_ipfile-tndper
st_ipfile-anbtr01
st_ipfile-anbtr02
st_ipfile-anbtr03
st_ipfile-anbtr04.
APPEND st_ipfile TO it_ipfile.
ENDIF.
ENDDO.
*--Close dataset
CLOSE DATASET l_file.
Regards,
Prashant
08-27-2008 12:06 PM
I think u r trying to upload data from application server rather than presentation server.
FILENAME /usr/sap/tmp/TEST.TXT
This FM only uploads data from presentation server not from application server. To read or write data to application server use open dataset statement.
08-27-2008 12:06 PM
Hi,
I think your input file is there in application server
Use like this
p_file = /usr/sap/tmp/TEST.TXT
open dataset p_file for input in text mode encoding default.
if sy-subrc = 0.
do.
read dataset p_file into ls_input-wa_string.
if sy-subrc eq 0.
append ls_input to lt_input.
else.
exit.
endif.
enddo.
endif.
close dataset p_file.
if you want to read from presentaion server use GUI_UPLOAD function module
08-27-2008 2:19 PM
I'm a little confused....
I want to upload a file from PC to a directory of an application server (tcode AL11).
The description of the FM GUI_UPLOAD is following:
The module loads a file from the PC to the server. Data can be transferred binarily or as text. Numbers and date fields can be interpreted according to the user settings.
Is there a misunderstanding in the description?
Thanks,
Lutz