CRM Export or download excel file word any file in CRM Web UI.pdf

Post on 29-Jan-2016

250 views 3 download

Transcript of CRM Export or download excel file word any file in CRM Web UI.pdf

Generated by Jive on 2014-08-22+02:001

How to: Export / Download Microsoft Excel,Word, PowerPoint, Generic approach for anyfile from CRM Web UI

This document explains how to:• Download Excel from CRM Web UI on page 1• Download Word from CRM Web UI on page 2• Download PowerPoint from CRM Web UI on page 4• Generic Approach: Download a file from CRM Web UI on page 6

Download Excel from CRM Web UI

1. Create a BSP Controller "downloadExcel" for Excel.2. Create a Controller class "ZCL_CRM_DOWNLOAD_EXCEL" with superclass

CL_BSP_CONTROLLER2. Redefine the DO_REQUEST method with the below code.

METHOD do_request. DATA:lv_xls TYPE xstring.

lv_len TYPE i. * Get the excel file here. For more details, you can refer the definition of the followingmethod in How to - Add Custom XML Parts to Microsoft Excel using ABAPget_xls_download(

IMPORTING

ev_xml_xstring_xls = lv_xls

EXCEPTIONS

error_occurred = 1

).

lv_len = xstrlen( lv_xls ).* Export response data

CALL METHOD response->if_http_entity~append_data

EXPORTING

data = lv_xls

length = lv_len.* Set response content-type as Excel

CALL METHOD response->if_http_entity~set_header_field

EXPORTING

name = 'content-type' "#EC NOTEXT"content-type for XLSX

value = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'. "Content types"Excel(*.xlsx) - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'"Excel (*.xlsm) -'application/vnd.ms-excel.sheet.macroenabled.12'

How to: Export / Download Microsoft Excel, Word, PowerPoint, Generic approach for any file from CRM WebUI

Generated by Jive on 2014-08-22+02:002

ENDMETHOD. 3. Set the contoller class to the BSP Controller. Now you can use this controller to download

the file.

Download Word from CRM Web UI

1. Create a BSP Controller "downloadWordDoc" for Word.2. Create a Controller class "ZCL_CRM_DOWNLOAD_WORDDOC" with superclass

CL_BSP_CONTROLLER2. Redefine the DO_REQUEST method with the below code.

METHOD do_request.DATA:lv_doc TYPE xstring.

lv_len TYPE i. * Get the word file here. For more details, you can refer the definition of the followingmethod in How to - Add Custom XML Parts to Microsoft Word using ABAPget_doc_download(

IMPORTING

ev_xml_xstring_doc = lv_doc

How to: Export / Download Microsoft Excel, Word, PowerPoint, Generic approach for any file from CRM WebUI

Generated by Jive on 2014-08-22+02:003

EXCEPTIONS

error_occurred = 1

).

lv_len = xstrlen( lv_doc ).* Export response data

CALL METHOD response->if_http_entity~append_data

EXPORTING

data = lv_doc

length = lv_len.* Set response content-type as Word

CALL METHOD response->if_http_entity~set_header_field

EXPORTING

name = 'content-type' "#EC NOTEXT"content-type for DOCX

value = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'."Contenttypes"Word (*.docx) - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document"Word (*.docm) - 'application/vnd.ms-word.document.macroenabled.12'

How to: Export / Download Microsoft Excel, Word, PowerPoint, Generic approach for any file from CRM WebUI

Generated by Jive on 2014-08-22+02:004

ENDMETHOD. 3. Set the contoller class to the BSP Controller. Now you can use this controller to download

the file.

Download PowerPoint from CRM Web UI

1. Create a BSP Controller "downloadPowerPoint" for PowerPoint.2. Create a Controller class "ZCL_CRM_DOWNLOAD_POWERPOINT" with superclass

CL_BSP_CONTROLLER2. Redefine the DO_REQUEST method with the below code.

METHOD do_request.DATA:lv_ppt TYPE xstring.

lv_len TYPE i. * Get the powerpoint file here. For more details, you can refer the definition of thefollowing method in How to - Add Custom XML Parts to Microsoft PowerPoint using ABAP get_ppt_download(

IMPORTING

ev_xml_xstring_ppt = lv_ppt

EXCEPTIONS

error_occurred = 1

).

How to: Export / Download Microsoft Excel, Word, PowerPoint, Generic approach for any file from CRM WebUI

Generated by Jive on 2014-08-22+02:005

lv_len = xstrlen( lv_ppt ).* Export response data

CALL METHOD response->if_http_entity~append_data

EXPORTING

data = lv_ppt

length = lv_len.* Set response content-type as PowerPoint

CALL METHOD response->if_http_entity~set_header_field

EXPORTING

name = 'content-type' "#EC NOTEXT"content-type for PPTX

value = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'."Contenttypes"PowerPoint (*.pptx) - 'application/vnd.openxmlformats-officedocument.presentationml.presentation'"PowerPoint (*.pptm) - 'application/vnd.ms-powerpoint.presentation.macroenabled.12'

ENDMETHOD. 3. Set the contoller class to the BSP Controller. Now you can use this controller to download

the file.

How to: Export / Download Microsoft Excel, Word, PowerPoint, Generic approach for any file from CRM WebUI

Generated by Jive on 2014-08-22+02:006

Generic Approach: Download a file from CRMWeb UI

1. Create a BSP Controller "downloadFile".2. Create a Controller class "ZCL_CRM_DOWNLOAD_FILE" with superclass CL_BSP_CONTROLLER2.

Redefine the DO_REQUEST method with the below code.

METHOD do_request.DATA:lv_ppt TYPE xstring.

lv_len TYPE i. * Get the file here. get_file_download(

IMPORTING

ev_xml_xstring_file = lv_file

EXCEPTIONS

error_occurred = 1

).

lv_len = xstrlen( lv_file ).* Export response data

CALL METHOD response->if_http_entity~append_data

EXPORTING

data = lv_file

length = lv_len.* Set response content-type for the file. Get the content-type using API Class method'cl_mime_repository_api->get( )' while reading the file from the Mime repository

CALL METHOD response->if_http_entity~set_header_field

EXPORTING

name = 'content-type' "#EC NOTEXT"content-type for file

value = 'set the content-type here read using the above mentioned API method'.

How to: Export / Download Microsoft Excel, Word, PowerPoint, Generic approach for any file from CRM WebUI

Generated by Jive on 2014-08-22+02:007

ENDMETHOD. 3. Set the contoller class to the BSP Controller. Now you can use this controller to download

the file.