‎2007 May 14 9:44 PM
Hi,
please help me out in uploading the data from application server which is a tab delemited file into an internal table.
Thanks
kumar
‎2007 May 14 9:59 PM
hi,
Use this sample code as an example.
&----
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
Thanks
Aneesh.
‎2007 May 14 9:48 PM
Hi,
Please check this link for sample code.
http://www.sapdevelopment.co.uk/file/file_uptabsap.htm
Regards,
Ferry Lianto
‎2007 May 14 9:59 PM
hi,
Use this sample code as an example.
&----
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
Thanks
Aneesh.
‎2007 May 16 3:43 PM
try this.
Open dataset (file name) for input appending in (text/binary) mode encoding default.
do.
read dataset (file name) into (wrk area).
if sy-subrc<>0
exit.
endif.
enddo.
close dataset (file name).