‎2007 Aug 13 7:46 PM
Hi gurus,
I am trying to upload a file from the application server
the location of the file is C:\Documents and Settings\rajeevgupta\My Document and the file is in the following format :
A | 100 | 00 | 12 | 08/01/2007
Can you please help me out how to upload this file.
Thanks
Rajeev Gupta
‎2007 Aug 13 7:51 PM
HI,
----
Internal Table Types *
----
data : BEGIN OF i_FILE occurs 0 ,
LINE(1000) TYPE C,
END OF i_FILE.
data : BEGIN OF itab,
VCODE(2) TYPE C,
CURR(10) TYPE C,
ODLEVEL(10) TYPE C,
DLEVEL(20) TYPE C,
EDATE(11) TYPE C,
end of itab.
DATA : LV_DATE TYPE D.
MOVE: P_FN_IMP TO V_FILENAME.
*-- Read the File From PC
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = V_FILENAME
TABLES
DATA_TAB = I_FILE
EXCEPTIONS
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.
ELSE.
LOOP AT I_FILE INTO X_FILE.
split x_file at '|' into itab- VCODE,
itab-CURR
ODLEVEL
DLEVEL
EDATE.
append itab.
endloop.
Thanks,
Mahesh
‎2007 Aug 13 7:51 PM
You mean from your PC to your program internal table?
report zrich_0001.
types: begin of ttab,
rec(1000) type c,
end of ttab.
types: begin of tdat,
fld1(10) type c,
fld2(10) type c,
fld3(10) type c,
fld4(10) type c,
fld5(10) type c,
end of tdat.
data: itab type table of ttab with header line.
data: idat type table of tdat with header line.
data: file_str type string.
parameters: p_file type localfile.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
file_str = p_file.
call function 'GUI_UPLOAD'
exporting
filename = file_str
tables
data_tab = itab
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.
loop at itab.
clear idat.
split itab-rec at '|' into idat-fld1
idat-fld2
idat-fld3
idat-fld4
idat-fld5.
append idat.
endloop.
loop at idat.
write:/ idat-fld1, idat-fld2, idat-fld3, idat-fld4, idat-fld5.
endloop.
Regards,
RIch Heilman
‎2007 Aug 13 7:51 PM
HI,
----
Internal Table Types *
----
data : BEGIN OF i_FILE occurs 0 ,
LINE(1000) TYPE C,
END OF i_FILE.
data : BEGIN OF itab,
VCODE(2) TYPE C,
CURR(10) TYPE C,
ODLEVEL(10) TYPE C,
DLEVEL(20) TYPE C,
EDATE(11) TYPE C,
end of itab.
DATA : LV_DATE TYPE D.
MOVE: P_FN_IMP TO V_FILENAME.
*-- Read the File From PC
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = V_FILENAME
TABLES
DATA_TAB = I_FILE
EXCEPTIONS
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.
ELSE.
LOOP AT I_FILE INTO X_FILE.
split x_file at '|' into itab- VCODE,
itab-CURR
ODLEVEL
DLEVEL
EDATE.
append itab.
endloop.
Thanks,
Mahesh