sapdev logo background
sapdev logo sapdev logo
Comments

Call URL from SAP Webdynpro for ABAP ACTION




One way to print a wdp table is to provide a link that displays the same data within simple HTML table within SAP BSP web page. So you basically call the bsp passing the appropriate parameters and re-retrieve the data from the appropriate SAP tables. Alternatively you could store the already retrieved data in your own Ztable with a unique ID as its key, you could then pass this ID to the BSP and get the data that way. However you decided to do it here are a few helpful bits of HTML, BSP and ABAP code to help perform some of the functionality you will need.

Create BSP page with links to .css files

sytle.css is used for displaying the data on screen, print.css is used for printing the data, so for example you can set some fields to be hidden when printed out

<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<html>
<head>
<link rel="StyleSheet" href="style.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="Print.css" media="print">
</head>

Print HTML/BSP page as soon as it is displayed
 <script type="text/javascript">
   <!--
   window.print();
    //-->
 </script>

Display print button on web page for user to press

If you look at the example .css files style.css and print.css below you will see that the class associated with this link has two different properties so that the button is not displayed when the user printes the page

  <body>
    <a class="printLink" href="#"
onClick="if (window.print) window.print();
return false">Print This Page</a>

Example code for style.css
<%@page language="abap"%>

table {
 border-collapse: collapse;
}

P {
//  FONT-SIZE: 8px; FONT-FAMILY: 'Arial', Verdana, Tahoma, Helvetica, sans-serif
  font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: #666;
}

.printLink {
  font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: #666;
}



Example code for style.css
<%@page language="abap"%>>

table {
 border-collapse: collapse;
}

P {
//  FONT-SIZE: 8px; FONT-FAMILY: 'Arial', Verdana, Tahoma, Helvetica, sans-serif
  font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: #666;
}


.printLink {
display:none;
}



Call URL of SAP BSP from web dynpro fro ABAP ACTION
data:  lo_window_manager type ref to if_wd_window_manager.
data:  lo_api_component  type ref to if_wd_component.
data:  lo_window         type ref to if_wd_window.
data:  ld_url type string.

lo_api_component  = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
ld_url = 'http://www.sapdev.co.uk/sap/bc/bsp/sap/zbsp_helloworld/print.htm?dataid=12345'.

CALL METHOD lo_window_manager->CREATE_EXTERNAL_WINDOW
  EXPORTING
    URL            = ld_url   "'http://www.sapdev.co.uk'
  RECEIVING
    WINDOW         = lo_window.

lo_window->open( ).



comments powered by Disqus