sap its - exercise

9
8/18/2019 SAP ITS - Exercise http://slidepdf.com/reader/full/sap-its-exercise 1/9 ITS Exercises Compiled By: Seetharam Maddali Exercise 1 Linking URLs to SAP Web Lists To link a URL to a specific part of a line in the list generated by executing a report, use function module WWW_SET_URL in your report as follows: 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 run the report in the R/3 System, the resulting list has the same appearance as it always does. However, when you start the report 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. Example: This report generates a list with the following output line: '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 REPORT W3HKTST1. DATA QSTRING LIKE W3QUERY OCCURS 10. DATA URL(100). URL = 'http://www.sap-ag.de'. 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.

Upload: shahulhameed3681

Post on 07-Jul-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SAP ITS - Exercise

8/18/2019 SAP ITS - Exercise

http://slidepdf.com/reader/full/sap-its-exercise 1/9

ITS Exercises

Compiled By: Seetharam Maddali

Exercise 1

Linking URLs to SAP Web Lists

To link a URL to a specific part of a line in the list generated by executing a report, use

function module WWW_SET_URL in your report as follows:

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 run the report in the R/3 System, the resulting list has the same appearance asit always does. However, when you start the report 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.

Example:

This report generates a list with the following output line:

'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

REPORT W3HKTST1.

DATA QSTRING LIKE W3QUERY OCCURS 10.

DATA URL(100).

URL = 'http://www.sap-ag.de'.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.

Page 2: SAP ITS - Exercise

8/18/2019 SAP ITS - Exercise

http://slidepdf.com/reader/full/sap-its-exercise 2/9

ITS Exercises

Compiled By: Seetharam Maddali

'SAP AG'

If you start the report from the Web with the following URL:/scripts/wgate.dll?~service=XGWFC&_FUNCTION=WWW_GET_REPORT&_REPORT=W3HKTST1

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.

Exercise 2

Linking R/3 Function Calls to SAP Web Lists

You can use the technique of linking Web pages to SAP function modules to implement

interactive reporting in SAP Web reports. In the R/3 System, interactive reporting allowsyou to generate drill-down lists from basic lists

Since interactive reporting in the R/3 System is such that the system itself stacks the lists

created in a report, you may want to program interactive reporting and use the ABAP/4event concept to react to user actions. However, this is not currently possible for Web

Reporting because, the report finishes after sending a basic list to the Web, and cannotreact to further user input.

Page 3: SAP ITS - Exercise

8/18/2019 SAP ITS - Exercise

http://slidepdf.com/reader/full/sap-its-exercise 3/9

ITS Exercises

Compiled By: Seetharam Maddali

To overcome this obstacle, you can link URLs to list lines that call SAP functionmodules. Within these function modules, you can then program the task that you want the

system to perform after a particular user action on the Web list.

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 functionmodule WWW_SET_URL in your report as follows:

1.  Fill an empty internal table of structure W3QUERY with the parameters you wantto pass to the function module. Structure W3QUERY has two fields, NAME andVALUE.

2. 

Create the list line with the WRITE statement.3. 

Call WWW_SET_URL directly after the WRITE statement.

4.  Specify the offset of the desired link in the OFFSET import parameter.5.  Specify the length of the desired link in the LENGTH import parameter.6.  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 thestandardized interface. For more information, see The WebRFC Gateway

Interface.7.  Pass the internal table with the parameters to the tables parameter 

QUERY_STRING.

In contrast to standard interactive reporting in ABAP/4, you must use the internal table

QUERY_STRING instead of the hide area to store information specific to a list line thatyou want to use later during an interactive event. For more information, see The Hide

Technique.

When you start such a report 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 theFUNC parameter and a list of the parameters stored in the internal table passed in the

QUERY_STRING parameter.

NOTE:

For each URL, you can specify different function modules with different parameters.

Page 4: SAP ITS - Exercise

8/18/2019 SAP ITS - Exercise

http://slidepdf.com/reader/full/sap-its-exercise 4/9

ITS Exercises

Compiled By: Seetharam Maddali

If you want to allow users who start reports from the R/3 System to perform the same

activities as Web users who start reports from the Web, include an interactive event keyword in your report program.

Lists. 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 doesnot 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 ( functionname and parameters) as that stored with WWW_SET_URL.

After calling WWW_GET_URL, you can use the information returned to call therelevant 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 onlyone function call with a dynamic function name. To supply the standardized interface,

define two additional internal tables pointing to the ABAP/4 Dictionary structuresW3HTML and W3MIME in your program. You can leave these tables empty.

Page 5: SAP ITS - Exercise

8/18/2019 SAP ITS - Exercise

http://slidepdf.com/reader/full/sap-its-exercise 5/9

ITS Exercises

Compiled By: Seetharam Maddali

  Report Source Code ( 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 0 WITH HEADER LINE,

  MYMIME LIKE W3MIME OCCURS 0 WITH HEADER LINE.DATA FUNCT(100).

START-OF-SELECTION.

GET SPFLI.

* Data is retreived using Key fields.

REFRESH QSTRING.

  QSTRING-NAME = 'CARRID'. QSTRING-VALUE = SPFLI-CARRID.

  APPEND QSTRING.

  QSTRING-NAME = 'CONNID'. QSTRING-VALUE = SPFLI-CONNID.

  APPEND QSTRING.

WRITE: / sym_right_hand as symbol HOTSPOT COLOR = 5,

  SPFLI-CARRID ,

  SPFLI-CONNID,

  SPFLI-CITYFROM,

  SPFLI-CITYTO.

CALL FUNCTION 'WWW_SET_URL'

  EXPORTING

  OFFSET = 0

  LENGTH = 1

  FUNC = 'Z_SECONDARY_LIST'

  TABLES

  QUERY_STRING = QSTRING

  EXCEPTIONS

  INVALID_TABLE = 1

  OTHERS = 2.

  IF SY-SUBRC NE 0.

  WRITE / 'Error in that line!'.  ENDIF.

END-OF-SELECTION.

AT LINE-SELECTION.

  IF SY-CUCOL = 2.

  CALL FUNCTION 'WWW_GET_URL'

  IMPORTING

  FUNC = FUNCT

  TABLES  QUERY_STRING = QSTRING

  EXCEPTIONS

  OTHERS = 1.

  IF SY-SUBRC NE 1.

  CALL FUNCTION FUNCT  TABLES

  QUERY_STRING = QSTRING

  HTML = MYHTML

  MIME = MYMIME

  EXCEPTIONS

  OTHERS = 1.

  IF SY-SUBRC = 1.  WRITE 'Error !!'.

  ENDIF.

  ENDIF.

  ENDIF.

Page 6: SAP ITS - Exercise

8/18/2019 SAP ITS - Exercise

http://slidepdf.com/reader/full/sap-its-exercise 6/9

ITS Exercises

Compiled By: Seetharam Maddali

This report 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 eachURL, function module Z_SECONDARY_LIST is specified. The internal table

QSTRING is filled with parameter pairs and passed to WWW_SET_URL. QSTRING iscleared for each new list line.

You start the report from the Web with the URL:

/scripts/wgate.dll?_~service=xgwfc&_FUNCTION=WWW_GET_SELSCREEN&_REPORT=W3HKTST2

This displays the report selection screen. When you enter selection criteria and run thereport, a list similar to the following appears in your Web browser:

The URL of the fifth line looks like this:

href="/scripts/wgate.dll?_~service=xgwfc&_FUNCTION=SECONDARY_LIST&CARRID=LH&CONNID=2402"

This URL includes the name of the function module as well as the parameter pairs for theairline carrier and connection.

Page 7: SAP ITS - Exercise

8/18/2019 SAP ITS - Exercise

http://slidepdf.com/reader/full/sap-its-exercise 7/9

ITS Exercises

Compiled By: Seetharam Maddali

  The source code of the function module SECONDARY_LIST is as follows:

First, this function reads the imported parameters from the internal tableQUERY_STRING. Then, it generates an output list in a SELECT loop. Finally, it sendsthe list to the Web.

FUNCTION Z_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.

  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.

Page 8: SAP ITS - Exercise

8/18/2019 SAP ITS - Exercise

http://slidepdf.com/reader/full/sap-its-exercise 8/9

ITS Exercises

Compiled By: Seetharam Maddali

If you click on a link in the Web list, the following drill-down list appears in your Web browser:

Exercise 3

Starting the Reporting Browser

Instead of calling specific reports (with or without selection screens) in URLs, you can

enable Web users to browse report trees. Report trees are hierarchical structures thatcontain SAP reports or your own reports. There can be any number of report trees in an

R/3 System and the nodes of each report tree can offer executable reports or pre-generated lists.

To allow Web users to access the SAP Reporting Browser, which is the standardhierarchy of reports supplied by SAP, specify a URL that calls the standard function

module WWW_GET_TREE_LIST in your Web page.

You specify the following URL in your HTML:

/scripts/wgate.dll?~service=XGWFC&_FUNCTION=WWW_GET_TREE_LIST

Page 9: SAP ITS - Exercise

8/18/2019 SAP ITS - Exercise

http://slidepdf.com/reader/full/sap-its-exercise 9/9

ITS Exercises

Compiled By: Seetharam Maddali

Web users who click on this URL get a list of all report trees currently in the R/3 System.

Clicking on one of the report tree names displays the structure for that report tree. Youcan click on the sub-trees to see subsequent levels and access reports at the lowest level.

This produces a page similar to that displayed below. Here, clicking on the node Flightreports produces a list of executable reports (which may or may not have selection

screens).