cancel
Showing results for 
Search instead for 
Did you mean: 

Download to Excel

srinivas_anchuri
Explorer
0 Kudos

Hi,

How to download data into Excel from PCUI Application?

Any help would be appreciated.

Thanks.

Srinivas.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Srinivas,

you could write your own BSP which returns the data seperated with a tab and set the content type to 'application/vnd.ms-excel'.

regards,

Thomas

srinivas_anchuri
Explorer
0 Kudos

Am going ahead with a new BSP Appl. to download excel and wish to open it from my PCUI application using preview element type.

But there is a problem with it. I have a pop-up on which user inputs some data relevant for download. Once he fills the data and clicks on download, this pop-up should get closed and the new BSP application to open excel should get called as a new window. How should I have the layout settings to satisfy the need.

Thanks.

Srinivas.

Former Member
0 Kudos

Srinivas, have a look at the following excellent weblog related to Excel download and BSP, https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/756. [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] This solution is pretty slick en self explanatory. Kind regards, Tiest.

srinivas_anchuri
Explorer
0 Kudos

I have written a new BSP to download data into Excel. Thanks for all the help.

gregorw
Active Contributor
0 Kudos

Hello Srinivas,

can you describe more details about your solution?

Regards

Gregor

Former Member
0 Kudos

Gregor, have a look at Thomas's its weblog: https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/756. [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] , it really worked for me. Let me know if you encounter issues. Tiest.

srinivas_anchuri
Explorer
0 Kudos

Gregor,

Which part of the solution are you interested in? Opening a new BSP Application from PCUI screen or using BSPs to download data in Excel?

Thanks.

Srinivas.

Former Member
0 Kudos

Srinivas, I would be intrested to see how you managed the Excel download, since I am writing a blog on it perhaps we can combine our efforts. Tiest.

srinivas_anchuri
Explorer
0 Kudos

I concatenated all data into a string..Columns separated by tab and rows separated by newline characters. I set this data in the response:

runtime->server->response->set_cdata( <result string> )

I changed the mime type to Excel:

runtime->server->response->set_header_field

( name = if_http_header_fields=>content_type

value = 'application/vnd.ms-excel' ).

This will open the data in Excel.

I believe there are already quite a few blogs about Excel download.

Srinivas.

gregorw
Active Contributor
0 Kudos

Hello Srinivas,

the difficult thing is not the creation of the Excel download. Where and how did you get the Search result data? And how did you build the result string out of it.

Regards

Gregor

Former Member
0 Kudos

Hi Gregor,

We get the data to be downloaded to the excel from the screen structure. For example, in any read method, we have a exporting variable et_screen_structure. We get the object keys from this table. Then after that loop at this table into an field-symbol of type any, and can read the data of relevant component of this field-symbol u needed into a string separated by ,(in our application we used like this). Hope this helps.

Regards,

Shailaja

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Srinivas,

We have exported the data into excel from PCUI application in CRM4.0. Let me know if u need it for this version. As it is said by George, it is not possible, but we placed the button on the view and written the event handler in another htm.

Shailaja

gregorw
Active Contributor
0 Kudos

Hello Shailaja,

I'm very interessted in this solution. Could you post the description here or send me an E-Mail to g dot wolf at siteco dot de.

Regards

Gregor

Former Member
0 Kudos

Hi Gregor,

Sorry for misspelling your name earlier. Okay the description goes like this. I would describe the explanation with an example: here it would be Accounts.

We have created a push button on the view, searchres.htm. This button would be viewed only for this application. and this is done by repairing the code for the identification of the application. Now for the event handler of the button, a JavaScript function is written in the searchres.htm on click of the button. this function forwards to another htm, where the code for the export to excel is written in OnInitialization() event.

Now coming to the code for the export to excel,we used open Dataset for output in text mode encoding utf-8 for transfering the data. This is data is got from the result of the search which would b in an internal table.

here the logic is the separation of transfered data is done using , (comma) which is recognised by the logic and places data in different columns in Excel. For this the dataset is opened for input in binary mode. After this the logic goes like this:

*******************************************************

content_length = xstrlen( file1 ).

mnavigation->set_parameter( name = 'content_length'

value = content_length ).

runtime->server->response->set_data( file1 ).

runtime->server->response->set_header_field(

name = 'Content-Disposition'

value = 'attachment; filename=Bpartners.csv' ).

runtime->server->response->set_header_field(

name = 'Content-Type'

value = 'application/cvs' ).

runtime->server->response->set_header_field(

name = 'Content-Length'

value = content_length ).

mnavigation->response_complete( ).

******************************************************

This is it. It worked. Hopefully am clear.

Thanks,

Shailaja

gregorw
Active Contributor
0 Kudos

Hello Shailaja,

thank you for the detailed description. But I have some further questions:

- have you tried to get this functionality also without a modification of the SAP standard?

- Where have you created the other BSP Page? Directly in the Application CRM_BSP_FRAME?

- How did you implement the access to the result of the search?

Hope you can help.

Regards

Gregor

Former Member
0 Kudos

Hi Gregor,

-I tried this functionality using the function modules like GUI_Dowload to export to excel. But the portal did not support this. And there was an error. so for our immediate requirement i could only see the modifications.

-An downloadexl.htm was created in the application CRM_BSP_FRAME itself under pages_with_flow_logic.

-The object keys for the result of the search is filled in an internal table in the corresponding model access class in Read method. I exported this structure (table), to memory using id sy-uname and imported the structure in the view for the correspoding application and filled the data set separated by comma.

If need any more help let me know.

Regards,

Shailaja

gregorw
Active Contributor
0 Kudos

Hello Srinivas,

in CRM 4.0 a Excel download of search results is not possible. But I've seen CRM 5.0 and SAP have implemented it there.

Regards

Gregor