Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sireeshach
Explorer
0 Kudos

Abstract:

                   Printing a Webdynpro application is similar to taking the screenshot of that page. If a table is displayed in an application and if there are many records than the visible rows of the table, and if we have the print functionality, the print may only help us to check the visible records of that table.

                  The user has to print again and again by scrolling through the table which is very tedious & unreal way of printing all the records of the table. Else all the records of the table can be printed using a Smartform, Adobe Form etc., where it may not be possible/may be very difficult to reproduce all the information that is available on the web page.

                  So printing all records of the table along with the remaining features of the webpage will be of great help. i.e. if the requirement is to print not only the table records but along with the other content on the webpage i.e whatever we can see in the webpage but with all table records if there are more table records than that are visible.


                For Eg. If the webpage is designed with different tabs, and in one tab if we have a table with more records than that are visible, along with some other UI elements, after Print if we need all the tabs, UI elements present on the webpage as per the standard print option but along with all table records.

              

               Unfortunately, we don’t have an option like this provided by SAP which gave us an opportunity to find out a way to do the same. This document deals with how to print all table records in a webpage along with other content. The example screen shots provided in this document contain only the table, a button and the text view showing the number of records on the webpage and this can be extended to have any complicated design of the webpage and then to print.

1.    Printing a Web Page:

Before going to the actual topic, we will see briefly how a standard print functionality i.e. printing a web page works in webdynpro ABAP.

As you already know, printing a webpage is similar to taking the screenshot of the webpage displayed. The standard way of printing a webpage available in webdynpro ABAP is to get the Application from the API of the component controller and then use the PRINT_PAGE method of the application.

Following is the code snippet which helps us in printing the webpage.

   

               Code Snippet1: To Print the Webpage

        data:

        l_api_componentcontroller type ref to if_wd_component,

        l_appl type ref to if_wd_application.

      

        l_api_componentcontroller = wd_comp_controller->wd_get_api( ).

        l_appl = l_api_componentcontroller->get_application( ).

        l_appl->print_page( ).

The webpage and the print preview of the webpage using the above code are as follows:

Fig 1: Webpage having a Print Button

Fig 2: Print Preview of the Webpage

Fig 1 is an application that is having a table which has more number of rows than the visible rows, a text with total number of records and a PRINT button. Fig 2 is the print preview of the same webpage. The print preview displays the current content of the application in a new browser window in which all actions are deactivated.

2.    Printing a webpage with All Table Records:

2.1.       What helped to achieve this functionality:

As discussed earlier, printing all records of a table will help the user to check the entries offline.

The Idea is to display all the records before printing the application and then immediately display only the records that are displayed previously. To achieve this, the UI element ‘TIMED TRIGGER’ is used.

2.2.       Steps to be followed to print a webpage with all table records:

  1. Insert a new UI element ‘Timed Trigger’ while designing the layout of the view where the print option is required.
  2. For the ‘Timed Trigger’ UI element, bind the ‘Enabled’ property to a context attribute, give the delay time as early as possible.
  3. Bind the VisibleRowCount property of the table.
  4. In WDDOINT, while binding the table for the first time, 
    1. Set the Visible Row Count to the number of rows that are to be displayed in the web.
    2. Get the total number of records of the table using DESCRIBE TABLE … LINES …. Statement.
  5. In the Action Method of Print Button, do the following. 
    1. Before using the Code snippet1 for printing, Set the visible row count to the total number of rows of the table.
    2. Use code snippet1 for printing the table.
    3. Enable the Timer i.e. set the attribute that is bound to the ‘Enabled’ property of the ‘Timed Trigger’ to ‘X’.
  6. In the Action Method of Timer, do the following. 
    1. Set the visible row count to the previous value.
    2. Disable the Timer i.e set the attribute that is bound to the ‘Enabled’ property of the ‘Timed Trigger’ to ‘ ‘.

  Note: 

  • The Timed Trigger is an UI element which will be called repeatedly based on the time value given in the property ‘Delay’. So Enabling and Disabling the Timer is Mandatory for this functionality to work.

  • The application will be changed in such a way that all records of the table are displayed for a while and then it resumes its original shape i.e. the webpage is displayed as before.

2.3.       Testing the Functionality:

The Webpage and the print preview of the webpage are as follows:

Fig 3: Webpage having a Print Button

Fig 4: Print Preview of the Webpage

                       Fig 3 is an application that is having a table which has more number of rows than the visible rows, a text with total number of records and a PRINT button. Fig 4 is the print preview of the same webpage displaying all records of the table.

Note: I would like to thank my colleagues Senthil (Who gave the Idea of Timer) & Tara (Myself & Tara implemented this functionality and achieved the result by enabling and disabling the Timer) for their contribution towards this Development.

Best Regards,

Sireesha Ch

Labels in this area