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: 

Convert Internal table to Excel and upload to application server

himanshu_gupta2
Participant
0 Kudos

Hello,

I want to convert the internal table to Excel and then upload this file to the application server.

One way is first convert and save to presentaion server and then upload from presentation to application..I dont want this.

do anyone knows any direct method to upload to application without being in between the presentation server.

8 REPLIES 8

Former Member
0 Kudos

Hi,

You can upload data to application server from your program through internal table.

Eg:

open dataset <datasetname> in text mode for output.

loop at itab into wa.

transfer wa to <datasetname>.

endloop.

close <datasetname>.

Regards,

Sunny

0 Kudos

I have to upload the Excel sheet not the internal table.

former_member184119
Active Contributor
0 Kudos

yes ...

For manual uploading

USE TCODE CG3Z

if you want by code..Use Bdc for CG3Z and you can pass the files.

Sas

0 Kudos

I cant use this transaction , as to retrieve data it takes more than 10 hrs and so i have to code so that it automatically upload to server

Former Member
0 Kudos

How is Excel going to retrieve the file from the app server? Convert your internal table to tab-delimited, open dataset....transfer...close dataset.

In a follow-on step that can be executed online, read the file back into SAP internal table., and call GUI_DOWNLOAD to store the file on presentation server. Open with Windows Explorer and Excel will import the file if you have named it with .xls or .xlsx extension.

Alternatively, store your output in a custom table, then in a separate on-line step, read the table, convert to Excel and download with GUI_DOWNLOAD.

If it takes 10 hours to extract, are you sure the results can:

1. be stored in memory without exceeding the max size of the user context; and

2. be small enough for Windows/SAP GUI to process as a download; and

3. fit into an Excel spreadsheet?

0 Kudos

Data it will fetch take 10hrs as it goes into background job .

Can you explain mein about your steps of gui_download

0 Kudos

GUI_DOWNLOAD is a function module....call it instead of CG3, as the ancient CG3 transactions support only 256-character widths. GUI_DOWNLOAD will transfer rows up to 1024 characters wide from SAP to Presentation server (PC/Desktop target).

Essentially, I'm suggesting that your either store the file file on the apps server, or store in a table created in the customer name space (a Z table). Then, after background job is completed, use another small program to open....read....close from Apps server back into an internal table, or read the Z table where you stored the data back into an internal table. Convert that internal table into an Excel file and download to desktop target with GUI_DOWNLOAD.

However, you should note that there is some arbitrary limit to the max size of the dataset that can be downloaded this way; SAP will abend if your internal table is beyond some arbitrary size.

NOte: generally, when we say upload we mean transfer INTO SAP, download to transfer OUT OF SAP....

What I do in these cases is store the file in compressed ( with CONDENSE keyword) tab-delimited format on server. Then I have a small piece of code that grabs that data with open...do...read...enddo....close into an internal table described with a single field (line(1024) TYPE C). I download that with SAP's GUI_DOWNLOAD FM and advise my users to open with Windows Explorer to invoke Excel's automatic import wizard.

0 Kudos

Hi himanshugupta2103,

no excel in background.

There is an interesting project on SCN for creation of MHTML (excel-compatible) "[Exporting data to Excel - XML to the rescue|http://wiki.sdn.sap.com/wiki/display/ABAP/ExportingdatatoExcel-XMLtotherescue]"

Check this.

Regards,

Clemens