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 from itab to excel in background (POINTS WILL BE REWARDED )

Former Member
0 Kudos

Hi Guys...

Is it possible to transfer data from an internal table to excel through a report which runs in background...???

thnx in advance...

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Poonam,

Use OPEN DATASET....inseted of WS_DOWNLOAD and the normal logic to download the data to EXCEL file.

Try this and get back with the code if any problem.

Reward if helpful.

Regards.

Chandra K

10 REPLIES 10

Former Member
0 Kudos

downloading data into excel in background is not possible.

You would be using method GUI_DOWNLOAD which rtequires GUI interactuion which is not possible in background.

the only way out is you have download the file to application server.

Former Member
0 Kudos

Hi,

Yes!! If u store the XLS file in Application server then its possible.

If u wanna XLS file to be stored on Prsentation server, then its not possbile.

Revrt back if any issues,

regards,

Naveen

Former Member
0 Kudos

Hi,

GUI_DOWNLOAD is not possible in background , So u may not be able to download internal table data into excel file.

Regards.

Former Member
0 Kudos

Hi Poonam,

Use OPEN DATASET....inseted of WS_DOWNLOAD and the normal logic to download the data to EXCEL file.

Try this and get back with the code if any problem.

Reward if helpful.

Regards.

Chandra K

0 Kudos

hi..

i am using the following code...but this give a runtime error....

" Only character-type data objects are supported at the argument

position "f" for the statement

"TRANSFER f TO ...". "

Two questions..using the following code the file is saved on the application server or the presentation server?? and will this save the file as excel ????

data lv_name type string value 'C:\usr\cust123.XLS'.

open dataset lv_name for output in text mode encoding default.

loop at i_final_cust.

transfer i_final_cust to lv_name.

endloop.

close dataset lv_name.

0 Kudos

The file will be saved on Application server , Either u hv to get it from basis people , or shoot a mail on ur sap mail box.

Former Member
0 Kudos

Please refer following code.

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 ','

IT_EXCEL_LAYOUT-ERDAT ','

IT_EXCEL_LAYOUT-EBELN ','

IT_EXCEL_LAYOUT-AEDAT ','

IT_EXCEL_LAYOUT-BELNR_M ','

IT_EXCEL_LAYOUT-BSART ','

IT_EXCEL_LAYOUT-MATNR ','

IT_EXCEL_LAYOUT-TXZ01 ','

IT_EXCEL_LAYOUT-MTART ','

IT_EXCEL_LAYOUT-MENGE ','

IT_EXCEL_LAYOUT-CBAMT ','

IT_EXCEL_LAYOUT-MMCRAMT ','

IT_EXCEL_LAYOUT-CRN_NO ','

IT_EXCEL_LAYOUT-MMDBAMT ','

IT_EXCEL_LAYOUT-DBN_NO ','

IT_EXCEL_LAYOUT-REJAMOUNT ','

IT_EXCEL_LAYOUT-DBN_REJ_CODE_TEXT','

IT_EXCEL_LAYOUT-STAMT ','

IT_EXCEL_LAYOUT-STXCAMT ','

IT_EXCEL_LAYOUT-CRNNO ','

IT_EXCEL_LAYOUT-LRNO ','

IT_EXCEL_LAYOUT-LRDATE ','

IT_EXCEL_LAYOUT-TRANSPORTERNAME

INTO IT_EXCEL-FLD.

APPEND IT_EXCEL.

ENDLOOP.

DATA:w_filename LIKE CFFILE-FILENAME.

CONCATENATE '/usr/sap/EC2/SYS/global/backup/'SY-UNAME '.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.

It will help u to download data on to application server in csv format

Regards,

Swarup

vinod_vemuru2
Active Contributor
0 Kudos

Hi Poonam,

Yes. It is possible with little risk. Check below link(Document) for full details.

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

I sugest u to go ahead with above logic only if this program is being run on only one machine. If it is on multile machines then it is very difficult to do settings in all machines.

The best method is ss sugested by other guys first download to application server through batch job. Then use transaction CG3Y to download the data from application to presentation server.

Hope it is helpful.

Thanks,

Vinod.

Former Member
0 Kudos

Hi,

In my view you can download the data in excel file .

If you hardcode the destination of file in the program.

0 Kudos

thnx for the help guys......using open dataset helped !!!