Skip to Content

One of the requirements I had when tasked in developing  a dynamic webdynpro graph display page was to have a print preview function that’s triggered upon the click of a button. As my webdynpro is not in a browser setting but shelled in a SAP GUI, the user can’t use the print preview function available in the IE browser.  At the time of this writing, SAP provides a print functionality for printing as detailed here . However this does not meet my requirement as firstly it’s a direct print function, not a print preview function. And secondly, the client is running on SAP Netweaver 7.0 EHP1, as oppose to EHP2 and above which supports this functionality. As ABAP webdynpro does not support javascripting, I did a workaround by calling a BSP page (with the webdynpro display encapsulated in an iframe) and triggering a countdown timer (this creates a time buffer to allow the page to render the graphics) before the print preview popup is displayed. Steps detailing this workaround are as below: 

  • Create a new BSP Application and insert the code as below in the event handler tab. Here, we’ll create a url construct of our targeted webdynpro application and assign it an attribute.

/wp-content/uploads/2012/03/1_80586.png

  • In the layout tab, insert the code as below. As you can see, I’ve set a timeout of 2 seconds before the function PrintMe() is called. Function PrintMe() contains the code for print preview and closes the window after the user clicks print and the focus returns to the parent window.  The Iframe houses our attribute, which was assigned the constructed url of our webdynpro application earlier.

        Edit : If you want a direct print function instead of a print preview one, change the var OLECMDID to 6 instead.

/wp-content/uploads/2012/03/2_80587.png

  • In the webdynpro  view insert a print link/button and create a corresponding event method (I’ve named my method as print).

/wp-content/uploads/2012/03/3_80594.png

  • In the method, construct the BSP url and do a call to the BSP Application we’ve created earlier.

/wp-content/uploads/2012/03/4_80595.png

  • Execute the application. In my example, my webdynpro application is called from a custom program and is housed in the SAP GUI.

/wp-content/uploads/2012/03/5_80596.png

  • Click on the print icon and the print preview function should trigger.

/wp-content/uploads/2012/03/6_80597.png

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply