cancel
Showing results for 
Search instead for 
Did you mean: 

Printing button

Former Member
0 Kudos

Hi everyone!

How can I create a button with a method that will print a view in a webdynpro application?

Thanks in advance!

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi everyone,

My SAP NetWeaver Developer Studio version is 7.0.16, Build id: 200805301646. When I try to use this code

WDPrintService.getPrintService().print(wdControllerAPI); with the import com.sap.tc.webdynpro.clientserver.print.api it doesn't recognize it, how can I add it ? By the way, I'm not using Portal, so I don't have Iviews...

Thanks in advance!

Former Member
0 Kudos

Hi,

As your SAP NWDS version is 7.0.16, you cannot use the code - WDPrintService.getPrintService().print(wdControllerAPI); as this code only for CE enviroenment.

For you you need to print the view in a round about method. :

1: Create a button and create a method "Print" on action of button.

2. Then in the method "onActionPrint" write the following code :


byte[] content = new byte[4028];
try {content = this.displayPrint().getBytes("UTF-8");wdContext.currentContextElement().setHtmlFile(content);
IWDWindow win = wdThis.wdGetAPI().getComponent().getWindowManage().createNonModalExternalWindow(WDWebResource.getWebResource(content, WDWebResourceType.HTML).getURL(),"Employee Details");win.setWindowSize(600,600);win.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);win.removeWindowFeature(WDWindowFeature.MENU_BAR);win.open();
} catch (Exception e) {}

3. Write another method in the view controller named "displayPrint" return type as String. YOu can go through the following blog to find how to write a text to the file :

/people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities . In the blog the the code utility findthe code in the "printTable" method.

Thanks in advance

Ritushree

Edited by: Ritushree Saha on Jun 4, 2009 11:34 AM

Former Member
0 Kudos

Hi,

The print functionality is availabel in CE not in NWDS 7.0 version.

So please go through the below link

Hope this helps you..

Regards,

Saleem

Former Member
0 Kudos

Hi Yelimar,

In NWDS 7.0, no coding is required for print button.

Just add the print UI element in the Iview.

It will work by default

Regards,

Nikhil

Former Member
0 Kudos

Hi,

Go through this blog to understand about print functionality in NWDS 7.0 and CE..

/people/community.user/blog/2007/10/01/printing-in-web-dynpro-finally

Hope this helps you...

Regards,

Saleem

Former Member
0 Kudos

Hi ,

If you are using 2004s then, you can follow the below mentioned steps :

1: Create a button and create a method "Print" on action of button.

2. Then in the method "onActionPrint" write the following code :

byte[] content = new byte[4028];content = this.displayPrint().getBytes("UTF-8");wdContext.currentContextElement().setHtmlFile(content);
IWDWindow win = wdThis.wdGetAPI().getComponent()
.getWindowManager().createNonModalExternal
(WindowWDWebResource.getWebResourcecontent,
WDWebResourceType.HTML).getURL(),"Print Claim Details");
win.setWindowSize(600,600);win.open();

3. Write another method in the view controller named "displayPrint" return type as String. YOu can go through the following blog to find how to write a text to the file :

/people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities . In the blog the the code utility findthe code in the "printTable" method.

Hope this solution helps you.

Thanks

Ritushree

Edited by: Ritushree Saha on Jun 3, 2009 10:37 AM

Edited by: Ritushree Saha on Jun 3, 2009 10:39 AM

pravesh_verma
Active Contributor
0 Kudos

Hi Yelimar,

Use this line of code in view java code, at a print action of your button:


WDPrintService.getPrintService().print(wdControllerAPI);
 

I hope this solves the issue!! Please revert back incase you need anu further information on this.

Thanks and Regards

Pravesh

Former Member
0 Kudos

Hi,

Which version of WD are you on? If you are on CE look at the WDPrintService class. If you are not then search this forum as this topic has been discussed a lot of times before.

Regards,

Satyajit