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

How to upload data from application server

Former Member
0 Likes
520

Hi,

please help me out in uploading the data from application server which is a tab delemited file into an internal table.

Thanks

kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
498

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.

3 REPLIES 3
Read only

Former Member
0 Likes
498

Hi,

Please check this link for sample code.

http://www.sapdevelopment.co.uk/file/file_uptabsap.htm

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
499

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.

Read only

Former Member
0 Likes
498

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).