cancel
Showing results for 
Search instead for 
Did you mean: 

printing in web dynpro via javascript

Former Member
0 Kudos

Hi all

I'm having difficulties adding the functionality to print a report (a table) in web dynpro

What I've done so far:

  • I've created a view with a 'print' button

  • I've linked the print button to a action called 'onActionPrint'

  • I've created a controller context value called 'urlToPrintPage' and linked it to my view's context. The variable is of type string

  • I've created a html page with the following code (printing.html):

<html>

<head></head>

<body>

<button onclick="window.parent.print()">Print</button>

</body>

</html>

  • I've copied the printing.html file to MyProject/src/mimes/Components/MyComponent/printing.html (locally and not onto the server since I would think that the printing.html would be deployed as well)

  • Within the 'onActionPrint' method I've placed the following code:

wdContext.currentContextElement().setUrlToPrintPage("/path/to/where/this/file/is/located/printing.html");

  • From a previous thread which is answered (message id: 3314996) the contributor used the url:

wdContext.currentPrintElement().setAtrURL("/irj/go/km/docs/documents/print/print.html");

  • I assume that the currentPrintElement would be the same as using the currentContextElement and that setAtrURL would be the same as setUrlToPrintPage in my case?

The file gets deployed to:

C:\usr\sap\J2E\JC01\j2ee\cluster\server0\temp\webdynpro\web\local\MyProject\Components\com.lonmin.bns.view.webdynpro.MyApplication\printing.html

I tried to access the file with an absolute url, but no joy (anyways the url looks like a temporary one...)

Could anyone please help to clear my understanding of this printing sollution?

Regards

Anton

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Try this:

<b>wdContext.currentContextElement().setUrlToPrintPage("printing.html");</b>

Warm Regards,

Murtuza

Former Member
0 Kudos

this is unanswered