Web Reporting: First Things First < Web reporting environment < Web RFC function modules for web reporting Executing Reports < Executing reports without a selection screen < Executing re
Trang 1Appendix D: Web Reporting
In this chapter you will learn:
The functionality behind web reporting
The remote function calls necessary for web reporting interaction with the R/3 System
The function modules you can incorporate into your ABAP programs to enable web-based reporting
Trang 2Overview
SAP Web Reporting is a Web-RFC application that enables World Wide Web users with proper authorization to get immediate access to information in the R/3 System Remote Function Call (RFC) is the name for a link into the R/3 programming structure
By placing URLs in web pages, you can:
< Offer reports to be started dynamically
< Make pre-generated lists that are stored in report trees available for display
< Allow users to browse report trees in the Web Reporting Browser Interactive reporting is also supported You can process standard interactive events initiated
by the user to get more detailed information on subsequent screens, and also set links to other web pages or function modules It is important to note that complex reports are not good candidates for web reporting
Web Reporting: First Things First
< Web reporting environment
< Web RFC function modules for web reporting Executing Reports
< Executing reports without a selection screen
< Executing reports with a selection screen
< Using WWW_GET_SELSCREEN
< Executing reports with WWW_GET_REPORT
< Interactive web reporting Web Reporting Browser
< Starting the web reporting browser Customizing
< Enabling report trees
< Standard templates for web reporting
< Placeholders in web reporting templates
< Customizing web reporting templates You will also find program code in this chapter as examples of integrating the function modules
Trang 3Web Reporting: First Things First
The Web Reporting Environment
In the SAP web reporting environment, the connection between the HTTP server and an R/3 System is provided by the SAP Internet Transaction Server (ITS) If you set up web pages with URLs that link to the R/3 System, and a user selects one of these links, the request is forwarded to the ITS Then ITS communicates with the R/3 System by Remote Function Call (RFC) On the R/3 side, a dispatcher program—function module
WWW_DISPATCH_REQUEST—receives the requests and executes them when they arrive The following graphic illustrates the process:
Internet Transaction
Server
URL parameter:
_FUNCTION = WWW_GET_REPORT _REPORT = RDTEST01
WWW_DISPATCH_REQUEST
_FUNCTION=WWW_GET_REPORT _REPORT = RDTEST01
WWW_GET_TREE_LIST
WWW_GET_SELSCREEN
WWW_GET_REPORT
SUBMIT RDTEST01 EXPORTING LIST TO MEMORY
WWW_GET_REPORT
SUBMIT RDTEST01 EXPORTING LIST TO MEMORY
Report RDTEST01
Report RDTEST01
RFC
R/3
Execute Report and Generate HTML Output
WebRFC Function Modules for Web Reporting
To enable Web users to execute reports, display pregenerated lists, or access report trees in the Web Reporting Browser, you simply place the appropriate URL in your web page
Trang 4The URL must contain a call to one of the following WebRFC function modules provided by SAP for Web Reporting:
WWW_GET_REPORT
This function module gets and executes a report immediately and displays the results For
more information, see Executing Reports Without a Selection Screen and Executing Reports with
WWW_GET_REPORT
WWW_GET_SELSCREEN
This function module is used with reports that have a selection screen It generates the
selection screen for the report specified in the URL For more information, see Executing
Reports with a Selection Screen and Using WWW_GET_SELSCREEN on page D–6
WWW_GET_TREE_LIST
This function module links to the standard Web Reporting Browser, which contains one or
more report trees For more information, see Starting the Web Reporting Browser on page D–
23
WWW_GET_TREE_NODE
This function module links to a node in a report tree and displays the contents For more
information, see Starting the Web Reporting Browser on page D–23
WWW_GET_NODE_LIST
This function module links to a pre-generated list stored in a report tree For more
information, see Starting the Web Reporting Browser on page D–23
Example:
/scripts/wgate.dll/XGWFC/!?&_FUNCTION=WWW_GET_REPORT&_REPORT=RDTES T01
This URL specifies the standard service XGWFC and instructs function module WWW_GET_REPORT to get and execute report RDTEST01 The parameter-value pairs
are separated by &
If you want to pass further criteria, you simply pack them into the URL as additional
parameters and separate each by &
Note: Never use single or double quotation marks in a URL string If parameter values
contain spaces, replace each space with a + character If parameter values contain &, replace the symbol with a % character and its ASCII equivalent 26 (hexadecimal), that is
%26
Trang 5Executing Reports
Executing Reports Without a Selection Screen
When specifying a URL that links to a report without a selection screen, call the standard function module WWW_GET_REPORT, which gets and executes a report immediately and displays the results
To enable users to execute a report that displays a list of flights at once (without further specification, specify this function module in your URL)
Example:
/scripts/wgate.dll/XGWFC/!?&_FUNCTION=WWW_GET_REPORT&_REPORT=RDTE ST01
If a web user selects this URL by clicking on it, the result is immediate generation of a list similar to the one at right No selection screen is displayed
The layout of this page is based on a standard HTML template, specifically designed by
SAP For more information, see Standard Templates for Web Reporting on page D–25
Trang 6Executing Reports with a Selection Screen
When specifying a URL that links to a report with a selection screen, you can call the standard function module WWW_GET_SELSCREEN, which gets the specified report and generates the selection screen The user enters selection criteria, executes the report, and the results are displayed by the web browser
Alternatively, you can use WWW_GET_REPORT to execute the report directly In this case, you have to supply the necessary parameters in the URL
It is more convenient to use WWW_GET_SELSCREEN than WWW_GET_REPORT, because you do not have to know whether a selection screen exists or not However,
WWW_GET_REPORT is more flexible and faster, because you can pack parameter values into your URL and the user gets immediate output
If you call WWW_GET_REPORT in URLs that link to reports with a selection screen, you can also specify the parameters that the user would normally enter on the selection screen These parameters include values for report variants, select-options, report parameters, checkboxes, and radio buttons
A report that displays a list of flights depending on what the user enters on the report
selection screen would require a URL similar to the following:
/scripts/wgate.dll/=XGWFC/!?_FUNCTION=WWW_GET_SELSCREEN&_REPORT=RD TEST03
If a web user selects this URL,
the selection screen appears
The layout of this page is based
on a standard HTML template
specifically designed for the
purpose by SAP For more
information, see Standard
Templates for Web Reporting
If you want to modify this
template or even create your
own template for use with
function module calls, see
Customizing Web Reporting
Templates on page D–28
Trang 7When the user enters selection
criteria on this screen and
submits the report, the
parameter values trigger a call
to function module
WWW_GET_REPORT, which
executes and displays the
report
The selection criteria above
would result in the following
list shown at right
The web browser takes user input from the HTML form and appends it to the URL for calling WWW_GET_REPORT
If a URL contains function module WWW_GET_SELSCREEN, but the specified report has
no selection screen, the procedure is as for WWW_GET_REPORT—the report is executed at once and the results are displayed
Example:
If a web user clicks on the following URL, report RDTEST01 is executed at once, because the report has no selection screen
/scripts/wgate.dll/XGWFC/!?_FUNCTION=WWW_GET_SELSCREEN&_REPORT=RDTEST01
Trang 8Specifying Report Variants in URLs
If you know that users often enter the same selection criteria for a report, or you want to restrict the amount of information displayed, you can offer a variant of the report rather than the report itself You can specify any existing variant in a URL as a parameter
Example:
/scripts/wgate.dll/XGWFC/!?_FUNCTION=WWW_GET_REPORT&_REPORT=RDTEST 02&_VARIANT=TST2VAR1
This link instructs function module WWW_GET_REPORT to execute variant TST2VAR1
of report RDTEST02 This variant generates a list that displays only those airline carriers with a carrier ID between AA and DL
You can make further restrictions by specifying further values
Executing Reports with WWW_GET_REPORT
When offering reports with a selection screen to web users, you can specify a URL that contains a call to WWW_GET_SELSCREEN This is a convenient solution, because you do not have to know whether a selection screen exists or not With WWW_GET_REPORT, however, you have additional flexibility, because you can pack parameters into your URL
In addition, the user gets immediate output
If you call WWW_GET_REPORT in a URL, you can also specify the values that the user normally enters on the report selection screen When the user clicks on your URL, there is then no need for a selection screen to execute a report because the values have already been specified This is particularly useful if most users enter the same selection criteria for a report
Note: If you use WWW_GET_REPORT to execute a report that has a selection screen, but you do not specify any parameters in the URL, the output corresponds to any default values defined for the report
Therefore, when you skip the selection screen in this way, try to ensure that you have specified all the values you need in the URL beforehand Otherwise, the system’s output will be different from that expected
You can specify parameter values for select-options, report parameters, checkboxes, and
radio buttons in URLs For more information, see Specifying Select-Options, Specifying Report
Parameters, Specifying Checkboxes, and Specifying Radio Buttons For information about syntax,
see Report Parameter Syntax in URLs
Specifying Select-Options
Instead of offering a report that displays a selection screen for the user to enter options, you can predefine the values in a URL This saves unnecessary work if the values entered by most users are the same
Trang 9select-Example:
/scripts/wgate.dll/XGWFC/!?_FUNCTION=WWW_GET_REPORT&_REPORT=RDTEST 02&SELC_NAME-LOW=AA&SELC_NAME-HIGH=DL
This link instructs function module WWW_GET_REPORT to execute report RDTEST02 This
generates a list that displays only airline carriers with a carrier ID between AA and DL The
resulting list would look similar to the one shown on the following page
Specifying Report Parameters
Instead of offering a report that displays a selection screen for the user to enter parameters, you can predefine the values in a URL If the values entered by most users are the same, this saves unnecessary work
Example:
/scripts/wgate.dll/XGWFC/!?_FUNCTION=WWW_GET_REPORT&_REPORT=RFDTST 03&PARC_CARRID1=DL&PARC_CARRID2=UA
This link instructs function module WWW_GET_REPORT to execute report RDTEST03 This generates a list that displays only airline carriers with carrier ID DL or UA
Specifying Checkboxes
If you offer a report where the user can select any number of checkboxes to get further information, you can predefine which checkboxes are selected by specifying them in a URL
Trang 10This makes sense if the checkboxes selected by most users are the same It also dispenses with the need to display a selection screen
Example:
/scripts/wgate.dll/XGWFC/!?_FUNCTION=WWW_GET_REPORT&_REPORT=RFDTST 06&CBOC_AA=X&CBOC_LH=X
This link instructs function module WWW_GET_REPORT to execute report RDTEST06 This generates a list that displays flight information only for those airline carriers with a carrier ID corresponding to checkboxes that would normally be selected on the selection screen (in this example, AA and LH)
Specifying Radio Buttons
If you offer a report where the user can select one radio button from a group of radio buttons to get further information, you can predefine which radio button is selected by specifying it in a URL This makes sense if most user’s select the same radio button It also dispenses with the need to display a selection screen
Example:
/scripts/wgate.dll/XGWFC/!?_FUNCTION=WWW_GET_REPORT&_REPORT=RFDTST 07&RADC_RAD1=R2
Report Parameter Syntax in URLs
When using the function module WWW_GET_REPORT to get and execute a report, you have to supply the in the URL using the prescribed report parameter syntax
This topic summarizes the report parameter syntax used in URLs Separate each parameter
by & and follow the standard conventions for URL parameters ( <parameter name> =
types C, D, F, I, P, and T For most data types, you have to specify -LOW and -HIGH values to
define a range The correct syntax for each data type is shown in the table on the following page
Trang 11Data Type Description Syntax
C Character (text) SELC_<name>-LOW=<value>
Data Type Description Syntax
C Character (text) PARC_<name>-LOW=<value>
Trang 12URL Syntax for Checkboxes When specifying values for checkboxes in a URL, the only valid data type is C, and the only
valid values are X or ' '
The correct syntax is:
CBOC_<name>=<value>
URL Syntax for Radio Buttons When specifying values for radio buttons in a URL, the only valid data type is C, and the values are names of radio buttons The correct syntax is:
RADC_<radio button group>=<radio button name>
Interactive Web Reporting
In the R/3 System, you can create ABAP report programs that generate basic lists where users can select lines, or trigger commands with menu options, function keys, or
pushbuttons, to display further information in one or more secondary lists You can also submit other ABAP report programs, call transactions, and call screens This creates the dialog capability known as interactive reporting
With certain restrictions, Web Reporting also has an interactive capability You can:
< Process standard interactive events in response to user actions
At present, Web Reporting does not allow you to:
< Submit ABAP report programs (with SUBMIT)
< Call transactions (with CALL TRANSACTION)
< Call screens (with CALL SCREEN)
< Send a message (with MESSAGE)
For information about how to generate secondary lists from basic lists, see Processing
Interactive Events
< Another way of implementing interactive reporting is through URLs You can:
Link URLs to lists that an SAP report sends to the Web
Link a specific part of a line in a list to any URL (including URLs that call R/3 function modules)
For more information, see Linking URLs to SAP Web Lists, and Linking R/3 Function Calls to
SAP Web Lists
Processing Interactive Events
A list generated by running an ABAP report program is interactive if the user interface allows users actions that trigger events This means that the program must contain the appropriate event keyword to introduce the processing block that deals with the user actions All output statements executed during such an interactive list event write data to a
Trang 13secondary list, which carries an index value stored in SY-LSIND Each time an interactive list event occurs, SY-LSIND is incremented by 1
The system displays the secondary list after executing the processing block introduced by the event keyword (or after leaving the block as a result of an EXIT or CHECK statement) The secondary list completely overlays the basic list
Each interactive list event creates a new secondary list With one ABAP report program, you can maintain one basic list and up to 20 secondary lists If a user action triggers a list on the next level (that is, SY-LSIND is incremented by 1), the system stores the previous list and displays the new one Only one list is active at any time
To allow users to react to the information displayed in basic lists generated by starting ABAP report programs on the Web, you use the event keywords:
AT LINE-SELECTION This event is triggered when the user double-clicks on a line in the basic list
AT PF<nn>
This event is triggered when the user selects the relevant function
AT USER-COMMAND This event occurs when the user chooses a specific function by placing the cursor on a particular field
If you define a processing block for one of these events in your program, the program can react to user actions Thus, if the user executes one of the defined actions in the basic list, the system triggers the relevant event and writes the output from all output statements
programmed in the processing blocks of that event to a secondary list
If interactive actions are possible in a report, this is apparent to the user, because the functions defined for the GUI status are displayed in the application toolbar
Example: You could write an ABAP report program that produces basic flight information for airline carriers, and then allow the user to select a line to get details about fares in a secondary list
Using AT LINE-SELECTION, you can allow the user to double-click on a line to get more detailed information
Using AT USER-COMMAND, you can allow the user to trigger functions offered in the application toolbar
Trang 14When a user double-clicks on one
of the lines in the list (or clicks on
the line once and selects Choose),
the system displays detailed
information related to that line
In this case, the selected line is for
connection ID 0134 of the airline
carrier AA
When the user selects this line,
fare details for the connection are
displayed in the secondary list
(shown at right)
In this case, the secondary list contains one possible user action in the application toolbar The user can sort the list by fare
Trang 15Linking URLs to SAP Web Lists
To link a URL to a specific part of a line in the list generated by an ABAP report program, use function module WWW_SET_URL in the program Take the following steps:
1 Generate the list line with the WRITE statement
2 Call WWW_SET_URL directly after the WRITE statement
3 Specify the offset of the desired link in the OFFSET import parameter
4 Specify the length of the desired link in the LENGTH import parameter
5 Specify the URL you want to link to as a literal or as a variable in the FUNC import parameter
6 Pass an empty internal table with structure W3QUERY to the tables parameter QUERY_STRING
When you execute the program in the R/3 System, the resulting list has the same appearance as it always does However, when you execute the program from a web page, the specified part of the list line is presented as a link If you click on this link, you access the URL address
WRITE: 'Web Reporting is brought to you by SAP AG '
CALL FUNCTION 'WWW_SET_URL' EXPORTING
OFFSET = 35 LENGTH = 6 FUNC = URL TABLES
QUERY_STRING = QSTRING EXCEPTIONS
INVALID_TABLE = 1 OTHERS = 2
This program generates a list with the following output: 'Web Reporting is brought to you by SAP AG '
By calling function module WWW_SET_URL, you link the URL http://www.sap-ag.de to
the part of the output line that reads SAP AG
If you execute the program from the Web with the following URL:
/scripts/wgate.dll/XGWFC/!?_FUNCTION=WWW_GET_REPORT&_REPORT=W3HKTS T1