2007 Mar 22 11:37 AM
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
2007 Mar 22 11:41 AM
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.
2007 Mar 22 11:41 AM
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.
2007 Mar 22 12:29 PM
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
2007 Mar 22 11:55 AM
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.
2007 Mar 22 12:48 PM
2007 Mar 22 12:59 PM