Link to Content's target Space :
Created on: May'13 2010
Arun Kumar is a CRM developer working with Accenture.
Uploading of files from CRM web ui is done using thtmlb:fileUpload tag. The file content represented in xstring format can be processed using character set conversion utilities like class cl_abap_char_utilities. However this conversion however is limited to text documents, CSV files, XML files and cannot be used for Excel files. So it was not possible to upload data from Excel file to CRM system.
I have created a tableview to display the uploaded data. This is the structure of the context node,
The view layout is enhanced with the below tags,
- A file upload tag <thtmlb:fileUpload id="fileUpl" />
<thtmlb:button id = "mybutton"
text = "Submit"
onClientClick = "upload_file( );" />
- Add a text area with width, height and rows as "0". This is done in order to hide the textarea from the screen since textarea does not have separate visibility property to hide it.
- Add a tableview to display the uploaded data.The rows are rendered from context node 'CondUpload'.
- Add a bsp:htmlbEvent
Read the entered file name from fileupload tag
Create a reference to automation object Excel application and open the specific file to read the data,
Assuming the Sheet1 is populated with records, read the number of active rows.
Loop into the rows and read the data from each cell and concatenate to string "sValue" separated by horizontal tab and line feed for new rows.
Populate the data into the textarea and close the workbook.
Return the bsp:htmlbEvent fireMyEvent assiging parameter p1 = 'GetContent'.
Read data populated in the text area using method get_form_fields. Excel data available in ls_items-value is assigned to a string.
Split the data by line feed and the records into an internal table. The data is then split by horizontal tab and assigned to seperate columns of an internal tab le of structure context node.
Create value node entities of type 'CondUpload' context node and populate the uploaded records. Add the entity to the collection wrapper.
Data in excel sheet
Uploaded data displayed in tableview