‎2008 Mar 24 8:37 AM
what is the function module to download data from the application server in to the internal table.
‎2008 Mar 24 8:39 AM
‎2008 Mar 24 8:40 AM
Hi,
I think there is no function module for down load the data from application server to itab.
we can use the open data set and close data set.
use the like this code.
data : filename(250) type c value '/usr/sap/tmp/ASHOKTEST11.TXT'.
start-of-selection.
open dataset filename for input in text mode encoding default.
do.
if sy-subrc <> 0.
exit.
endif.
read dataset filename into itab.
append itab.
enddo.
loop at itab.
write: itab-lifnr.
endloop.close dataset filename.
Regards,
S.Nehru.
Edited by: Nehru on Mar 24, 2008 9:40 AM
Edited by: Nehru on Mar 24, 2008 9:43 AM
‎2008 Mar 24 8:42 AM
Hi,
UseTransaction code CG3Y
or
data : filename(250) type c value '/usr/sap/tmp/test1.TXT'.
start-of-selection.
open dataset filename for input in text mode encoding default.
do.
if sy-subrc 0.
exit.
endif.
read dataset filename into itab.
append itab.
enddo.
loop at itab.
write: itab-lifnr.
endloop.
Reward if helpful.
Regards,
Kumar
‎2008 Mar 24 8:43 AM
Usually the files are not read using Function Module.It is read using the commands.
OPEN DATASET server_file FOR access IN mode [position]
[os_addition]
[error_handling].
then READ DATASET server_file INTO wa_input_rec.
‎2008 Mar 24 8:44 AM
Hi,
By using the following code,we can get the data from flat file,
which is in application server to internal table.
Later split and modify the databse table.
DATA: fname(25) VALUE 'd:\abap eve\file1.txt'.
DATA: str(255).
OPEN DATASET fname FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc <> 0.
WRITE:/ 'sorry'.
ELSE.
DO.
READ DATASET fname INTO str.
IF sy-subrc = 0.
WRITE:/ str.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
close dataset fname.
Reward,if it is useful.
Thanks,
Chandu
‎2008 Mar 24 8:51 AM
Hi,
To transfer data from application server file to internal table, create an internal table with same field names and and same length and in same order.
open the file using
open dataset <filename> for input.
do.
read dataset into itab.
if sy-subrc = 0.
append itab.
else.
exit.
endif.
enddo.
Reward.
‎2008 Mar 24 9:08 AM
if the file is in the application server , better u can use the dataset concept.
Eg :
wrk_filename = '/usr/sap/work/atnd.dat' . "Filename
OPEN DATASET filename FOR INPUT
IN TEXT MODE ENCODING DEFAULT .
DO.
Read file line by line, line no stored in cnt_line
READ DATASET filename INTO wrk_rec.
cnt_line = cnt_line + 1.
IF sy-subrc <> 0.
EXIT.
ELSE.
Check whether any blank line is there
IF strlen( wrk_rec ) > 10.
wa_uploadtable-firstno = wrk_rec(8).
wa_uploadtable-firstno1 = wrk_rec(8).
wa_uploadtable-firstno2 = wrk_rec(8).
Append <wa> to ><it>.
ENDIF.
ENDDO.
CLOSE DATASET filename.