Application Development 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: 

How to upload file from application server to internal table

Former Member
0 Kudos
344

Hi experts,

Could you please tell me how to upload a file from application server to internal table.... Also i have to check whether it is getting uploaded into internal table or not... How can i view or take a file from application server.

Kindly solve my doubt.. Thanks in advance

Regards,

Buvana

1 ACCEPTED SOLUTION

Former Member
0 Kudos
87

hi,

check this..

&----


  • table declaration

**&----


tables: mara.

&----


*data declaration

&----


data: begin of it_lfa1 occurs 0,

vendor like lfa1-lifnr,

land1 like lfa1-land1,

name1 like lfa1-name1,

ort01 like lfa1-ort01,

end of it_lfa1.

&----


  • selection screen

**&----


selection-screen: begin of block b1 with frame.

parameters: p_file type rlgrap-filename obligatory.

selection-screen: end of block b1.

&----


  • at selection screen

**&----


at selection-screen on value-request for p_file.

&----


*& start-of-selection

&----


start-of-selection.

perform transfer_file using p_file.

perform write.

&----


*& Form transfer_file

&----


  • text

----


  • -->P_P_FILE text

----


form transfer_file using p_p_file.

data: l_message(30) type c.

***opening dataset for reading

open dataset p_p_file for input in text mode encoding default message

l_message.

if sy-subrc ne 0.

message i001(zerr2) with p_p_file.

endif.

*******transferring data from file to app server.

do.

read dataset p_p_file into it_lfa1.

if sy-subrc = 0.

append it_lfa1.

clear it_lfa1.

else.

exit.

endif.

enddo.

*******closing dataset

close dataset p_p_file.

endform. " transfer_file

&----


*& Form write

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form write .

loop at it_lfa1.

write:/ it_lfa1-vendor,

it_lfa1-land1,

it_lfa1-name1,

it_lfa1-ort01.

endloop.

endform. " write

do reward if it helps,

priya.

5 REPLIES 5

Former Member
0 Kudos
88

hi,

check this..

&----


  • table declaration

**&----


tables: mara.

&----


*data declaration

&----


data: begin of it_lfa1 occurs 0,

vendor like lfa1-lifnr,

land1 like lfa1-land1,

name1 like lfa1-name1,

ort01 like lfa1-ort01,

end of it_lfa1.

&----


  • selection screen

**&----


selection-screen: begin of block b1 with frame.

parameters: p_file type rlgrap-filename obligatory.

selection-screen: end of block b1.

&----


  • at selection screen

**&----


at selection-screen on value-request for p_file.

&----


*& start-of-selection

&----


start-of-selection.

perform transfer_file using p_file.

perform write.

&----


*& Form transfer_file

&----


  • text

----


  • -->P_P_FILE text

----


form transfer_file using p_p_file.

data: l_message(30) type c.

***opening dataset for reading

open dataset p_p_file for input in text mode encoding default message

l_message.

if sy-subrc ne 0.

message i001(zerr2) with p_p_file.

endif.

*******transferring data from file to app server.

do.

read dataset p_p_file into it_lfa1.

if sy-subrc = 0.

append it_lfa1.

clear it_lfa1.

else.

exit.

endif.

enddo.

*******closing dataset

close dataset p_p_file.

endform. " transfer_file

&----


*& Form write

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form write .

loop at it_lfa1.

write:/ it_lfa1-vendor,

it_lfa1-land1,

it_lfa1-name1,

it_lfa1-ort01.

endloop.

endform. " write

do reward if it helps,

priya.

0 Kudos
87

Hi,

Thanks for your valuable reply.... But i have a doubt now.... Can you please kindly explain me..........

The file name p_path is referred to rlgrap-filename. Should i need to get that file name using any fnmodule... since for presentation server, i am using F4_filename to get the file name....

Thanks in advance..

Regards,

Buvana

Former Member
0 Kudos
87

bhuvana,

u have to use open dataset stmt along with transfer stmt.

sample code.

data : itab like ztable occurs 0 with header line.

open dataset filename for input in text mode.

do

read dataset filepath into itab.

if sy-subrc eq 0.

append itab.

else.

exit.

endif.

enddo.

close dataset filepath.

loop at itab.

write : / itab.

endloop.

hope u understood.

Regards...

Arun.

Reward points if useful.

Former Member
0 Kudos
87

I need still more explanations..

0 Kudos
87

Please have a look at the FM F4_DXFILENAME_TOPRECURSION

Regards,

Rich Heilman