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.
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.
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.
Note:
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |