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

function module to download data from application server

Former Member
0 Likes
1,335

what is the function module to download data from the application server in to the internal table.

7 REPLIES 7
Read only

Former Member
0 Likes
795

sorry didnt read ur question completely

Read only

Former Member
0 Likes
795

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

Read only

Former Member
0 Likes
795

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

Read only

former_member210123
Active Participant
0 Likes
795

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.

Read only

Former Member
0 Likes
795

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

Read only

Former Member
0 Likes
795

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.

Read only

Former Member
0 Likes
795

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.