Bsp download to excel in unicode format sap blogs oil futures market history


There have been recent discussion in the BSP forum on BSP and Excel . I would like to take this one step further and discuss how to do this same download, but with the data in Unicode.

The example code in this thread works great until you hit one situation cnn world market futures. If you have a Unicode or MDMP SAP system and you are downloading data from more than one code page or from a different code page than the default codepage of the OS that the client is running, you will have a problem. The data stream that is sent to Excel will be encoded with the default codepage for the logged on language and it will then corrupt any characters from another code page.

To give you a concrete example I will tell you about our system. We have English and Polish both installed in our system (using MDMP we have two code pages Latin-1 for English and Latin-2 for Polish).

My Windows XP client is Unicode capable as is Microsoft Office binary explained. However your pc also has to work in a single non-Unicode code page when dealing with non-Unicode data. This is normally set by the country version of the OS you are running (In Windows XP you can switch this value in the Region Settings). My PC for instance is US based and therefore runs English (Latin-1) as its default codepage. I then run a BSP page logged on to the WebAS in Polish exchange rate usd to malawi kwacha. I need to download a report with Material Descriptions that are in Polish. However the download from SAP by default will be in Polish (latin-2) and my PC and Excel won’t understand it since they are expecting English (Latin-1). As you can see from this screen shot, what I end up with is quite a mess exchange rate usd to cad history. The BSP output is on the top and is formatted correctly. However the Excel display on the bottom has many incorrect and corrupted characters:

I would like to give you some code samples that will expand on those in the given Forum posting 1 usd to inr today. I want to stress that these samples will work even in a non-Unicode SAP system. I have tested them on WebAS 620. The first thing we have to understand is what kind of Unicode file does MS Excel want us exchange rate to canadian dollar. After doing a little research, I found out that Excel expects a UTF-16 encoded file (evidently all the Microsoft Office tools use UTF-16 when saving files in their primary format) with a byte order mark of Little Endian. If UTF-16 and Byte Order Mark (BOM) are unfamiliar, I suggest some light reading on the Unicode Home Page.

I wanted to verify this information I had found on the web. I opened Excel and typed in some Polish national characters usd rmb exchange rate history. I then saved my spreadsheet as Unicode Text. This creates a tab-delimited text file in Unicode format. I then opened the file in a Hex Editor. Sure enough, there was my UTF-16le (Little Endian) Byte Order Mark – FF FE – right at the beginning of the of the file.

I have a BSP page with a button that I called “Download to Excel” future stock market. When I press the button, the event is captured by the OnInputProcessing of the Event Handler and the code for downloading an Excel file is executed in the right way. A window call “File Download” will open with 3 choises: OPEN – SAVE – CANCEL.

And now the problem: whatever choise I do, in the Status Bar of the starting page (the page with the button) remains in “Waiting for server response…” what is the binary system. The problem is that I can’t use any other buttons in the page, nor the same “Download to Excel” button!

Another little thing: I put the code in the OnInputProcessing and when I tried to activate the page, an error occurred: I had to change the word “response” with “_m_response”

and “navigation” with “_m_navigation”. I don’t know what exactly they mean, but only in this way the page can be activated. These words were suggested me by the compiler.

In the part, where I convert the header to xml, add the BOM and then add the code to the response, it is not the XML String, that is added, but the Character String. So basically the BOM is missing. I changed this and voila, Excel shows me bulgarian letters. Only now, Excel no longer recognizes the semicolon, that I used to separate cells as a separater and instead writes the whole line in one cell funny quotes and sayings for facebook. Do you know if there is some issue with the BOM, that confuses CSV? How can I tell Excel to recognize the semicolon as a separator?