Because some Web browsers such as Microsoft Internet Explorer (IE) are designed to minimize the security risks, offering enhanced Web print controls is often a challenge for BW teams. Here’s a way to offer your end users a handy drop-down menu to set page orientation and margins for better-looking output.
Key Concept
By customizing the standard delivered Web template 0QUERY_TEMPLATE, new print controls can be provided that allow end users to define their own print parameters. SAP supports this type of customization with the ASAP paper “How To…Enhance Web Printing.”
End users often need to modify the format of their BW Web applications to improve the layout so it looks better when printing from the Web. In your BW 3.0B SP09 or later release, you can give them enhanced print controls via a drop-down menu that opens when users move their mouse over the print preview or printer icon on the BEx toolbar.
I’ll show how to develop this drop-down menu (Figure 1). With this print functionality, users can easily change margins to accommodate tasks like printing headers and footers on each page rather than just on page one. They can also set the number of rows and columns and insert page breaks that will be displayed on each page. Settings in the menu include different page orientations and margins as well as an option to define your own parameters.

Figure 1
The drop-down menu makes it easy for end users to change page margins and the layout
These options are available for print preview as well as printing. Accessing the print service via the drop-down menu opens a second browser window. If a predefined page layout is selected, the user sees a print preview such as the screen in Figure 2, which shows one print preview view. From the drop-down menu, you can change this by choosing a different predefined page orientation or margin view or by customizing the layout using the Print Options setting. This option leads to the screen in Figure 3 on the next page and is available for users who need to define their own page layout.

Figure 2
Print preview presented after selecting a predefined page

Figure 3
Print options are available if users need to define their own page parameters
Some Assembly Required
Enhanced printing functionality is available to BW 3.0B SP09 users after implementing the steps in the ASAP document “How To…Enhance Web Printing.” It describes what you must do to enable more robust printing functionality like adding the drop-down menu controls I’ve described. You can download “How To…Enhance Web Printing” at service.sap.com/bw by following the menu path Services & Implementation>How To…Guides>Guide List BW 3.x.
Note
You’ll find other great ideas for enhancing Web printing controls along with more details concerning how they are implemented in the article “Create New BW Web Printing Controls Your Users Will Love,” in the March 2004 issue of BW Expert. Beware of an error in one of the parameters in the code in the article. Z_HELP_PRINT_SERVICE is incorrect. The proper parameter is Z_PRINT_HELP_SERVICE. This error has been corrected in the electronic archive.
In addition to implementing the procedures detailed in the ASAP document, you also need to upload the files listed in Table 1 to the MIME Repository. Before uploading, first open the Object Navigator screen via transaction SE80 and click on the MIME Repository button (Figure 4). Locate and open the SAP file in the Name column, then locate and open the BW folder within the Public folder. Right-click on the Customer file in the BW folder and select Create and Folder in the menu dialog (Figure 5). Create the new folder and name it dscript26, then right-click on the new folder and select Import MIME Objects (Figure 6).
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/
/sap/bw/Mime/Customer/dscript26/ |
b1.gif
b1on.gif
b2.gif
b2on.gif
m1b1.gif
m1b1on.gif
m1b2.gif
m1b2on.gif
m1b3.gif
m1b3on.gif
m1b4.gif
m1b4on.gif
m1b5.gif
m1b5on.gif
m1b6.gif
m1b6on.gif
m1b7.gif
m1b7on.gif
m2b1.gif
m2b1on.gif
m2b2.gif
m2b2on.gif
m2b3.gif
m2b3on.gif
m2b4.gif
m2b4on.gif
m2b5.gif
m2b5on.gif
m2b6.gif
m2b6on.gif
script.js |
|
Table 1 |
Import these files to the new folder |

Figure 4
Maintain the MIME Repository in the Object Navigator screen

Figure 5
Right-click on the Customer folder, select Create and Folder and name it dscript26

Figure 6
Right-click on the new folder and select Import MIME Objects
Update 0QUERY_TEMPLATE
After maintaining the MIME Repository, update the standard delivered template 0QUERY_TEMPLATE as described in the ASAP paper on Web printing. Copy the template via transaction SE38 and execute program RS_TEMPLATE_MAINTAIN to modify the copy.
After you have copied the 0QUERY_TEMPLATE and renamed it appropriately, switch the change mode by clicking in the change icon to edit the HTML code. You need to make sure you set the help service for your data provider by adding the lines of code in Figure 7.
<!-- Set the data provider ---> <object> <param name="OWNER" value="SAP_BW"/> <param name="CMD" value="SET_DATA_PROVIDER"/> <param name="NAME" value="DP"/> <param name="DATA_PROVIDER_ID" value=""/> <param name='HELP_SERVICE' value='ZPRINTING'/> <param name='HELP_SERVICE_CLASS' value='Z_PRINT_HELP_SERVICE'/> DATA_PROVIDER: DP </object>
|
Figure 7 |
Code to set the help service for your data provider |
Next add the code in Figure 8 under the Template Properties. You must also include a short JavaScript routine to allow printing via the context menu. This code, shown in Figure 9, is inserted after the title and before the end of the header. The title section is shown with comments that specify the title in the header of the HTML page before the section with code begins.
<param name="SUPPRESS_SYSTEM_MESSAGES" value="X"/> <param name="SUPPRESS_WARNINGS" value="X"/> <param name="CMENU_LABEL" value="Print Preview"/> <param name="CMENU_FUNCTION" value="callPrintHelpService"/> <param name="CMENU_LABEL_2" value="Print"/> <param name="CMENU_FUNCTION_2" value="javascript:window.print"/>
|
Figure 8 |
Add this code under Template Properties |
<!-- Javascript Enhancement of Printing via Context Menu---> <script language=javascript> function callPrintHelpService(parameter, cell_type, filter, parameter1, parameter2, item, dataprovider, x, y) { var url = SAP_BW_URL_Get(); url = url + "&CMD=PROCESS_HELP_WINDOW&HELP_SERVICE=ZPRINTING&DATA_PROVIDER="+dataprovider; window.open(url, "Print", "width=800, height=600, menubar=yes, toolbar=no, scrollbars=yes, resizable=yes"); } </script>
|
Figure 9 |
Code to allow printing via the context menu |
After adding this JavaScript, two significantly longer JavaScript routines are required to provide print preview processing and to print directly to IE Print Service. Both files are available at the BW Expert Web site. Copy the contents of each file and insert them as follows:
- JavaScript routine for allowing print preview processing — paste routine immediately after the code in Figure 9 (JavaScript enhancement of printing via context menu).
- JavaScript routine to allow printing directly to IE Print Service — paste the CallPrintIE function (available for download via this link) directly after the code from Step 1.
One final routine is required to specify which images are used in the toolbar and to handle the drop-down menu’s mouseover capabilities. It goes directly after the JavaScript to print from the IE print service (Figure 10).
<style> <!-- #m1 { height: 27px; left: 10px; position: absolute; top: 48px; visibility: hidden; width: 155px; z-index: 10 } #m2 { height: 27px; left: 36px; position: absolute; top: 48px; visibility: hidden; width: 125px; z-index: 10 } --> </style> <SCRIPT language=JavaScript src="/sap/bw/Mime/Customer/dscript26/script.js"></SCRIPT> <SCRIPT language=JavaScript> if(document.images){ for (i=1; i<=7; i++) { eval("b"+i+" = new Image()");eval("b"+i+".src = '/sap/bw/Mime/Customer/dscript26/b"+i+".gif'"); eval("b"+i+"on = new Image()");eval("b"+i+"on.src = '/sap/bw/Mime/Customer/dscript26/b"+i+"on.gif'"); eval("m1b"+i+" = new Image()");eval("m1b"+i+".src = '/sap/bw/Mime/Customer/dscript26/m1b"+i+".gif'"); eval("m1b"+i+"on = new Image()");eval("m1b"+i+"on.src = '/sap/bw/Mime/Customer/dscript26/m1b"+i+"on.gif'"); } for (i=1; i<=6; i++) { eval("m2b"+i+" = new Image()");eval("m2b"+i+".src = '/sap/bw/Mime/Customer/dscript26/m2b"+i+".gif'"); eval("m2b"+i+"on = new Image()");eval("m2b"+i+"on.src = '/sap/bw/Mime/Customer/dscript26/m2b"+i+"on.gif'"); } } </SCRIPT>
|
Figure 10 |
Code that indicates which images to use in the toolbar and enables the drop-down menu mouseover capabilities |
HTML Coding
Within the body of the HTML document, embed the HTML code at the BW Expert Web site labeled Menu Start. The terms 490px and 50px determine where on the page the print preview drop-down menu appears. The numbers specify in pixels the absolute position of the menu on the page. The menu for print is placed at 510 pixels and 50 pixels. At 510 pixels, the second menu is 20 pixels farther to the right than the first menu, which starts at position 490.
You can change the pixel settings to allow both drop-down menus to appear directly under their respective toolbar icons. If you are adding the enhanced printing feature to the default template 0QUERY_TEMPLATE, the values I’ve used should work fine. The drop-down menus, however, can be defined for any position of the screen, either under a button on the toolbar, or any other location you feel is best.
Also, at the end of the toolbar, insert the code in Figure 11 to add two icons for print and print preview.
<!-- Display Print Preview--->
<td class="SAPBEXNavLine"><A onmouseover="imgOn('1');Show('m1')" onmouseout="imgOff('1')"><IMG src="/sap/bw/Mime/Customer/dscript26/b1.gif" border=0 name=b1></A></td>
<!-- Display Print IE--->
<td class="SAPBEXNavLine"><A onmouseover="imgOn('2');Show('m2')" onmouseout="imgOff('2')"><IMG src="/sap/bw/Mime/Customer/dscript26/b2.gif" border=0 name=b2></A></td>
|

|

|
Figure 11 |
Code to add icons for print and print preview |
Save the template and make sure the menu lines up with the toolbar button. Adjust the pixel settings as necessary to specify a new position so the drop-down menus match their respective icons on the toolbar.
Prakash Darji
Prakash Darji is an experienced professional with more than 10 years of end-to-end experience in enterprise software. He has a broad depth of experience including corporate strategy, sales, product management, architecture, and development. He has experience in product launch activities, including positioning, packaging, and pricing. He has delivered numerous product releases in a variety of capacities through his career. He thrives on building high-performing, scalable teams to achieve strategic deliverables, whether they close strategic sales deals, roll in product features, or roll out new releases. He is a recurring author for several publications and a speaker at SAP conferences around the world. Prakash is on LinkedIn at https://www.linkedin.com/in/prakashdarji.
You may contact the author at editor@BIexpertOnline.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.