‎2008 May 29 10:08 AM
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???
‎2008 May 29 10:29 AM
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
‎2008 May 29 10:12 AM
use:
open dataset...
chk these 2 links:
/people/monalisa.biswal/blog/2007/06/28/download-in-background
regards,
madhu
‎2008 May 29 10:12 AM
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 ?
‎2008 May 29 10:16 AM
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.
‎2008 May 29 10:21 AM
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.
‎2008 May 29 10:24 AM
thanks for reply.
any sample code on open dataset???
i tried this one also but nothing is downloaded...not even file get created.
‎2008 May 29 10:15 AM
/people/monalisa.biswal/blog/2007/06/28/download-in-background
‎2008 May 29 10:17 AM
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.
‎2008 May 29 10:29 AM
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