Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 30 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
30
Dung lượng
292,46 KB
Nội dung
D Appendix D: Web Reporting Contents In this chapter you will learn: The functionality behind web reporting Overview D–2 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 Web Reporting: First Things First D–3 Executing Reports D–5 Customizing Reports D–25 Where to Learn More D–29 Report Development Tools D–1 Appendix D: Web Reporting Overview Overview 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 How this material is organized This appendix is designed to introduce you to web reporting with R/3, and to help you program with RFCs and function modules To gain an understanding of web reporting, this appendix is organized by the following sections and topics: 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 D–2 Reporting Made Easy Appendix D: Web Reporting Web Reporting: First Things First Web 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 RFC WWW_GET_TREE_LIST WWW_GET_TREE_LIST WWW_DISPATCH_REQUEST _FUNCTION=WWW_GET_REPORT WWW_GET_REPORT WWW_GET_REPORT SUBMIT SUBMIT RDTEST01 RDTEST01 EXPORTING EXPORTING LIST LIST TO TO MEMORY MEMORY R/3 Report Report RDTEST01 RDTEST01 _REPORT = RDTEST01 WWW_GET_SELSCREEN WWW_GET_SELSCREEN 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 Report Development Tools D–3 Appendix D: Web Reporting Web Reporting: First Things First The 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 D–4 Reporting Made Easy Appendix D: Web Reporting Executing Reports Executing 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 Report Development Tools D–5 Appendix D: Web Reporting Executing Reports Executing 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 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 Using WWW_GET_SELSCREEN If you want to allow users to enter selection criteria on the report selection screen before executing a particular report, you must specify the function module WWW_GET_SELSCREEN in your URL Example: 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 D–6 Reporting Made Easy Appendix D: Web Reporting Executing Reports When 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=RDT EST01 Report Development Tools D–7 Appendix D: Web Reporting Executing Reports Specifying 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 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 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 selectoptions, you can predefine the values in a URL This saves unnecessary work if the values entered by most users are the same D–8 Reporting Made Easy Appendix D: Web Reporting Executing Reports 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 Report Development Tools D–9 Appendix D: Web Reporting Executing Reports This 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 ( = ) URL Syntax for Report Variants The correct syntax for report variants is: _VARIANT= URL Syntax for Select-options When specifying values for report select-options in a URL, you can pass any of the data 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 D–10 Reporting Made Easy Appendix D: Web Reporting Executing Reports The following list appears in your Web browser: By placing the cursor on SAP AG, you see that the URL specified in the program (http://www.sap-ag.de) is connected to this link If you click on this link, you will go the SAP home page Linking R/3 Function Calls to SAP Web Lists Another way of implementing interactive Web reporting is to link web pages to SAP function modules By linking URLs to list lines that call SAP function modules, you can then program the task that you want the system to perform after a particular user action on the Web list in the function modules themselves Function module WWW_SET_URL creates such URLs automatically and stores line-specific information in a hide area To implement the call to an SAP function module in the line of a Web list, use function module WWW_SET_URL in your program as follows: Fill an empty internal table of structure W3QUERY with the parameters you want to pass to the function module Structure W3QUERY has two fields, NAME and VALUE Create the list line with the WRITE statement Call WWW_SET_URL directly after the WRITE statement Specify the offset of the desired link in the OFFSET import parameter Specify the length of the desired link in the LENGTH import parameter Specify the function module that you want to call in the URL as a literal or as a variable in the FUNC import parameter Your function module must have the standardized interface Pass the internal table with the parameters to the tables parameter QUERY_STRING In contrast to standard interactive reporting in ABAP, you must use the internal table QUERY_STRING instead of the hide area to store information specific to a list line that you want to use later during an interactive event When you start execute such a program from the Web, the specified part of the list line is actually a link The URL of this link contains the call to the SAP function module passed in the FUNC parameter and a list of the parameters stored in the internal table passed in the QUERY_STRING parameter D–16 Reporting Made Easy Appendix D: Web Reporting Executing Reports Note: For each URL, you can specify different function modules with different parameters If you want to allow users who start ABAP report programs from the R/3 System to perform the same activities as Web users who start ABAP report programs from the Web, include an interactive event keyword in your program With interactive reporting on the Web, you store line-specific information with function module WWW_SET_URL and not with the HIDE statement, so the system does not retrieve this data automatically as it does for standard interactive events Furthermore, since you want to perform the same task in the R/3 system as from the Web, call the same function modules during an interactive event The R/3 System provides function module WWW_GET_URL to perform this task For each interactive list line, this function module returns the same information ( function name and parameters) as that stored with WWW_SET_URL After calling WWW_GET_URL, you can use the information returned to call the relevant function module from within the R/3 System for each interactive event Since the interface of Web-enabled function modules is standardized, you need to program only one function call with a dynamic function name To supply the standardized interface, define two additional internal tables pointing to the ABAP Dictionary structures W3HTML and W3MIME in your program You can leave these tables empty Example: The following report is connected to the logical database F1S: REPORT W3HKTST2 TABLES SPFLI DATA: QSTRING LIKE W3QUERY OCCURS 10 WITH HEADER LINE, MYHTML LIKE W3HTML OCCURS WITH HEADER LINE, MYMIME LIKE W3MIME OCCURS WITH HEADER LINE DATA FUNCT(100) START-OF-SELECTION GET SPFLI REFRESH QSTRING QSTRING-NAME = 'CARRID' QSTRING-VALUE = SPFLI-CARRID APPEND QSTRING QSTRING-NAME = 'CONNID' QSTRING-VALUE = SPFLI-CONNID APPEND QSTRING WRITE: / 'O' HOTSPOT COLOR = 5, SPFLI-CARRID , SPFLI-CONNID, SPFLI-CITYFROM, SPFLI-CITYTO CALL FUNCTION 'WWW_SET_URL' Report Development Tools D–17 Appendix D: Web Reporting Executing Reports EXPORTING OFFSET LENGTH FUNC TABLES QUERY_STRING EXCEPTIONS INVALID_TABLE OTHERS = = = 'SECONDARY_LIST' = QSTRING = = IF SY-SUBRC NE WRITE / 'Error in that line!' ENDIF END-OF-SELECTION AT LINE-SELECTION IF SY-CUCOL = CALL FUNCTION 'WWW_GET_URL' IMPORTING FUNC = FUNCT TABLES QUERY_STRING = QSTRING EXCEPTIONS OTHERS = IF SY-SUBRC NE CALL FUNCTION FUNCT TABLES QUERY_STRING HTML MIME EXCEPTIONS OTHERS = = = QSTRING MYHTML MYMIME = IF SY-SUBRC = WRITE 'Error !!' ENDIF ENDIF ENDIF This program generates a basic list from the database table SPFLI By calling function module WWW_SET_URL, the first column of each line is linked to a URL For each URL, function module SECONDARY_LIST is specified The internal table QSTRING is filled with parameter pairs and passed to WWW_SET_URL QSTRING is cleared for each new list line You execute the program from the Web with the URL: /scripts/wgate.dll/XGWFC/!?_FUNCTION=WWW_GET_SELSCREEN&_REPORT=W3HKT ST2 D–18 Reporting Made Easy Appendix D: Web Reporting Executing Reports This displays a selection screen When you enter selection criteria and execute the program, a list similar to the one shown below appears in your Web browser The URL of the fifth line looks like this: href="/scripts/wgate.dll/XGWFC/!?_FUNCTION=SECONDARY_LIST&CARRID=LH& CONNID=2402" This URL includes the name of the function module as well as the parameter pairs for the airline carrier and connection The source code of the function module SECONDARY_LIST is as follows: FUNCTION SECONDARY_LIST REFRESH HTML REFRESH MIME CONTENT_TYPE = 'text/html' TABLES SFLIGHT DATA: MY_CARRID LIKE SPFLI-CARRID, MY_CONNID LIKE SPFLI-CONNID LOOP AT QUERY_STRING IF QUERY_STRING-NAME EQ 'CARRID' MY_CARRID = QUERY_STRING-VALUE ENDIF IF QUERY_STRING-NAME EQ 'CONNID' MY_CONNID = QUERY_STRING-VALUE Report Development Tools D–19 Appendix D: Web Reporting Executing Reports ENDIF ENDLOOP WRITE: MY_CARRID, MY_CONNID ULINE SELECT * FROM SFLIGHT WHERE CARRID EQ MY_CARRID AND CONNID EQ MY_CONNID WRITE: / SFLIGHT-FLDATE, SFLIGHT-SEATSMAX, SFLIGHT-SEATSOCC ENDSELECT CALL FUNCTION 'WWW_LIST_TO_HTML' TABLES HTML = HTML ENDFUNCTION First, this function reads the imported parameters from the internal table QUERY_STRING Then, it generates an output list in a SELECT loop Finally, it sends the list to the Web If you click on a link in the Web list, the following drilldown list appears in your Web browser: D–20 Reporting Made Easy ... 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 D–2 Reporting Made Easy Appendix D: Web Reporting Web Reporting: .. .Appendix D: Web Reporting Overview Overview SAP Web Reporting is a Web- RFC application that enables World Wide Web users with proper authorization to get