Creating a BSP Extension for Downloading a Table
Updated on July 18, 2005. New functionality for this solution to apply an iterator to the download content was added via another weblog: BSP Extension for Downloading a Table: Applying an Iterator (BSP Extension for Downloading a Table: Applying an Iterator)
The purpose of this web log is really two fold. First I wanted to share the code from a BSP extension element that we wrote that allows for the easy download of a table to Excel, XML, or HTML. This seems to be one of those features that users who are used to the SAPGui and ALV Grids always expect from BSP pages. The also seems to be a lot of interest in the BSP forums for this kind of functionality.
The second reason for this web log is to provide a detailed walk-through of a BSP extension element. There also seems to be a high interest in people creating their own elements and hopefully this weblog will add to the other documentation that already exists on SCN.
I have to say that I also struggled with the best way to share the source code. I thought about upload the Transport files to SCN. However I didn’t think that people would want to import this directly into their systems (security concerns, naming conventions, etc). I also though about including the source code in a file that can be downloaded. But there are so many separate pieces to the element that ultimately I thought this might be difficult to use. Finally I decided to include the code inline in textboxes.
That way users can decided what code they want and cut and paste it out of the blog post. If there is demand I can upload the code as file as well and add it to the blog post later.
What we are going to build
Before I start breaking down each piece of code, lets first look at what we are going to build. As far as what the user will see – we will have an Icon and Label that trigger a popup menu (based upon the PHTMLB popup Menu object). This popup menu will contain our different download options. The following is what the finished product will look like in action:
We will start off with the element definition. I named my element downloadTableExcel . When I started the project I was only going to offer Excel as a download option. It was only later that I decided to enhance the element to include XML and HTML. For the Element content I selected BSP Elements and Static HTML . For Further options I only selected “PAGE DONE” is not returned at the end of BSP element .
The following are some screen shots of how my Extension, Element, and the underlying class definitions look. Some people were having some problems with the inheritance from CL_HTMLB_ELEMENT, so I though adding these screen shots might help.