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: 

Download file to Application Server(Unix)

Former Member
0 Kudos
111

Hi all!

Does SAP provide a function to save the content in an internal table to a file on Application Server?

Thank you very much!!!

1 ACCEPTED SOLUTION

Former Member
0 Kudos
73

Hi,

Use the code below,

data : begin of ifile occurs 0,

text(1023) type c,

end of ifile.

form add_header .

concatenate 'Lotid' ','

'PTC in' ','

'PTC in qty' ','

'PTC out' ','

'PTC out qty' ','

'Invoice#' ','

'Invoice date' ','

'Invoice qty' ','

into ifile-text.

append ifile. clear ifile.

endform. " add_header

form add_details .

loop at aud_details.

move aud_details-fkimg to aud_details-fkimg1.

concatenate

aud_details-lotid ','

aud_details-stagestarttime ','

aud_details-stagestartqty ','

aud_details-stageendtime ','

aud_details-totalnetshipmentsmain ','

aud_details-vbeln ','

aud_details-fkdat ','

aud_details-fkimg1 ','

into ifile-text.

append ifile. clear ifile.

endloop.

endform. " add_details

open dataset outpath for output in text mode encoding default.

if sy-subrc = 0.

loop at ifile.

transfer ifile to outpath.

endloop.

endif.

close dataset outpath.

Note : move qty fields to char fields and concatenate.

Regards

Rajesh.

4 REPLIES 4

Former Member
0 Kudos
73

Hi yun,

1. We can use the syntax

OPEN DATASET, TRANSFER, CLOSE DATASET

for downloading file from internal table,

to application server.

regards,

amit m.

anversha_s
Active Contributor
0 Kudos
73

hi,

chk this sample.

parameters: p_file like rlgrap-filename obligatory

default '/usr/sap/upload.xls'.

types: begin of t_data,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

matnr like vbap-matnr,

werks like vbap-werks,

megne like vbap-zmeng,

end of t_data.

data: it_data type standard table of t_data,

wa_data type t_data.

open dataset p_file for output in text mode encoding default.

if sy-subrc ne 0.

write:/ 'Unable to open file:', p_file.

else.

do.

read dataset p_file into wa_data.

if sy-subrc ne 0.

exit.

else.

append wa_data to it_data.

endif.

enddo.

close dataset p_file.

endif.

rgds

anver

if hlped pls mark points

Former Member
0 Kudos
74

Hi,

Use the code below,

data : begin of ifile occurs 0,

text(1023) type c,

end of ifile.

form add_header .

concatenate 'Lotid' ','

'PTC in' ','

'PTC in qty' ','

'PTC out' ','

'PTC out qty' ','

'Invoice#' ','

'Invoice date' ','

'Invoice qty' ','

into ifile-text.

append ifile. clear ifile.

endform. " add_header

form add_details .

loop at aud_details.

move aud_details-fkimg to aud_details-fkimg1.

concatenate

aud_details-lotid ','

aud_details-stagestarttime ','

aud_details-stagestartqty ','

aud_details-stageendtime ','

aud_details-totalnetshipmentsmain ','

aud_details-vbeln ','

aud_details-fkdat ','

aud_details-fkimg1 ','

into ifile-text.

append ifile. clear ifile.

endloop.

endform. " add_details

open dataset outpath for output in text mode encoding default.

if sy-subrc = 0.

loop at ifile.

transfer ifile to outpath.

endloop.

endif.

close dataset outpath.

Note : move qty fields to char fields and concatenate.

Regards

Rajesh.

Former Member
0 Kudos
73

Thank you all very much!!!