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 data onto presentation server

Former Member
0 Kudos

Hello experts,

I am trying to download data onto presentation server(shared folder) from internal table. Also this report need to be run in background mode. so download should be done in background.

i tried to download using function module. but it didnt work.

is there any way to download internal table data in background mode onto shared folder???

any sample code???

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Check out the sample code.

MOVE : 'Sr. No.' TO IT_EXCEL_LAYOUT-SLNO ,

'Veh Regn No.' TO IT_EXCEL_LAYOUT-HERST ,

'Notfn No.' TO IT_EXCEL_LAYOUT-QMNUM ,

'Notfn Dt' TO IT_EXCEL_LAYOUT-QERDAT ,

'Serv Ord No.' TO IT_EXCEL_LAYOUT-AUFNR ,

APPEND IT_EXCEL_LAYOUT.

**********<Records to be transported>

LOOP AT ifinal.

MOVE: ifinal-SLNO TO IT_EXCEL_LAYOUT-SLNO ,

ifinal-HERST TO IT_EXCEL_LAYOUT-HERST ,

ifinal-QMNUM TO IT_EXCEL_LAYOUT-QMNUM ,

ifinal-QERDAT TO IT_EXCEL_LAYOUT-QERDAT ,

ifinal-AUFNR TO IT_EXCEL_LAYOUT-AUFNR ,

APPEND IT_EXCEL_LAYOUT.

ENDLOOP.

*******

DATA:BEGIN OF IT_EXCEL OCCURS 0,

FLD(1023),

END OF IT_EXCEL.

LOOP AT IT_EXCEL_LAYOUT.

CONCATENATE: IT_EXCEL_LAYOUT-SLNO ','

IT_EXCEL_LAYOUT-HERST ','

IT_EXCEL_LAYOUT-QMNUM ','

IT_EXCEL_LAYOUT-QERDAT ','

IT_EXCEL_LAYOUT-AUFNR ','

INTO IT_EXCEL-FLD.

APPEND IT_EXCEL.

ENDLOOP.

DATA:w_filename LIKE CFFILE-FILENAME.

CONCATENATE '<filename> '.csv' INTO w_filename.

OPEN DATASET w_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC = 0.

LOOP AT IT_EXCEL.

TRANSFER IT_EXCEL TO w_filename.

ENDLOOP.

ENDIF.

CLOSE DATASET w_filename.

Regards,

swarup

8 REPLIES 8

Former Member
0 Kudos

use:

open dataset...

chk these 2 links:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c64efb...

/people/monalisa.biswal/blog/2007/06/28/download-in-background

regards,

madhu

Former Member
0 Kudos

Hi !

What are you trying to do ?

Fill an internal table from a file, or use an internal table to create a file on the server ?

0 Kudos

the data populated in the internal table.

i am trying to download the internal table data into the file on shared folder.

i think file will be created dynamically.

0 Kudos

You can loop on the internal table and execute for each line of it a write dataset statement (see the help for "open dataset" and "write dataset").

Regards,

Eric.

0 Kudos

thanks for reply.

any sample code on open dataset???

i tried this one also but nothing is downloaded...not even file get created.

vinod_vemuru2
Active Contributor
0 Kudos

Hi Saurab,

Best way is to download the data to application server using OPEN DATASET, TRANSFER and CLOSE DATASET commands and then use CG3Y transaction to download to local PC.

Function modules will not work in back ground mode.

There is one way sugested in SDN by some one in foreground mode also. But this needs setting to be done in SAP and Local PC.

Thanks,

Vinod.

Former Member
0 Kudos

Check out the sample code.

MOVE : 'Sr. No.' TO IT_EXCEL_LAYOUT-SLNO ,

'Veh Regn No.' TO IT_EXCEL_LAYOUT-HERST ,

'Notfn No.' TO IT_EXCEL_LAYOUT-QMNUM ,

'Notfn Dt' TO IT_EXCEL_LAYOUT-QERDAT ,

'Serv Ord No.' TO IT_EXCEL_LAYOUT-AUFNR ,

APPEND IT_EXCEL_LAYOUT.

**********<Records to be transported>

LOOP AT ifinal.

MOVE: ifinal-SLNO TO IT_EXCEL_LAYOUT-SLNO ,

ifinal-HERST TO IT_EXCEL_LAYOUT-HERST ,

ifinal-QMNUM TO IT_EXCEL_LAYOUT-QMNUM ,

ifinal-QERDAT TO IT_EXCEL_LAYOUT-QERDAT ,

ifinal-AUFNR TO IT_EXCEL_LAYOUT-AUFNR ,

APPEND IT_EXCEL_LAYOUT.

ENDLOOP.

*******

DATA:BEGIN OF IT_EXCEL OCCURS 0,

FLD(1023),

END OF IT_EXCEL.

LOOP AT IT_EXCEL_LAYOUT.

CONCATENATE: IT_EXCEL_LAYOUT-SLNO ','

IT_EXCEL_LAYOUT-HERST ','

IT_EXCEL_LAYOUT-QMNUM ','

IT_EXCEL_LAYOUT-QERDAT ','

IT_EXCEL_LAYOUT-AUFNR ','

INTO IT_EXCEL-FLD.

APPEND IT_EXCEL.

ENDLOOP.

DATA:w_filename LIKE CFFILE-FILENAME.

CONCATENATE '<filename> '.csv' INTO w_filename.

OPEN DATASET w_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC = 0.

LOOP AT IT_EXCEL.

TRANSFER IT_EXCEL TO w_filename.

ENDLOOP.

ENDIF.

CLOSE DATASET w_filename.

Regards,

swarup