Skip to Content

Better late than never…

… Is what I can say when I see the support for printing introduced in Web Dynpro CE.  A quick search tells me that there are 150 odd threads on printing issues alone. Web Dynpro on NW 7.0 had no native support for printing and the community came up with pretty good workarounds (converting to PDF, Java Scripting et. al).

But things are about to change in CE and how!! Today I’ll demonstrate the newly introduced printing support in CE. Ok, enough blah…let’s code 🙂

 

WDPrintService…

… Is a new class introduced in the “com.sap.tc.webdynpro.clientserver.print.api” package and as the name suggests, it provides a factory for client side printing services.

 

Demo…

… Will be based on the following scenario: In our view we have a table and we simply want to print it.  I’ll not go through the steps to build the table, we all know it. Here’s a screenshot of what this table looks like:

Basic table

The table has a toolbar and it has a single button labeled “Print”. No prizes for guessing that on click of this button we will invoke the print service and thereby print this table view. I have created an action Print and in the onActionPrint event handler method I wrote the following code:

 

//the print method takes a IWDViewController instance as parameter

WDPrintService.getPrintService().print(wdControllerAPI);

 

Once the application is run and the “Print” button on the table is clicked, you can see the framework generated print preview page which in this case looks like

Print Preview

By clicking on the “Print” button on the top of the print preview page, we get to see the good old Windows print dialog.

 

Dialog

 

Let me end…

… By saying that this newly introduced API will make it easier for us, the application developers, to obtain a very basic thing like printing. We no longer have to fight with workarounds. But looking at the API, we cannot print only a selected area of the view. Looking forward to the later SPs.

To report this post you need to login first.

13 Comments

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

      1. Now it’s fine.
        I lime very much about this WebDynpro funcionality.

        Congratulations by post

        (0) 
      2. Now it’s fine.
        I like very much about this WebDynpro funcionality.

        Congratulations by post

        (0) 
        1. Community User Post author
          Hi Satyajit,
              I am using EP 7.01 SP5. can i used the print option you have suggested in this version? Please suggest what needs to be done for that?

          Thanks,
          Sujata

          (0) 
  1. Sidharth Deshpande
    Hi Satyajit,

    Thanks for an informative blog. However if i look at the preview frame to me it appears as if it will print only the visible part of the table which is the first 5-6 rows. Is this how it works or does it print the complete table contents.

    Does it also print the scroolbars. Why i ask this is because i want to understand whether it is a ALT+PRINTSCREEN kind of functionality or it is the actual print functionality.

    Regards
    Sidharth

    (0) 
  2. Nagarajan Kumarappan
    Hi Satyajit,

    A Very good blog finally for the Printing Functionality in Webdynpro.

    Which Version of CE are you using? I have downlaoded the trial version in SDN and couldn’t find a Class WdPrintservice.

    – Nagarajan.

    (0) 
  3. Jagan Mohan
    Hi…

    this seems to be interesting.

    am not a technical guy. am looking for the similar kind of feature in ABAP.

    not sure whether the sample is for ABAP or JAVA.

    Please enlighten me about this.

    if this sample is Java. can any one suggest how to do this print feature in ABAP.

    Thanks a lot in advance.

    Jagan

    (0) 

Leave a Reply