Академический Документы
Профессиональный Документы
Культура Документы
HELP.BCFESITSTRANPRO
G
Release 4.6B
™
Web Transaction Programming SAP AG
Copyright
©
Copyright 2000 SAP AG. All rights reserved.
No part of this brochure may be reproduced or transmitted in any form or for any purpose without
the express permission of SAP AG. The information contained herein may be changed without
prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software
components of other software vendors.
® ® ® ® ® ®
Microsoft , WINDOWS , NT , EXCEL , Word and SQL Server are registered trademarks of
Microsoft Corporation.
® ® ® ® ® ® ® ® ®
IBM , DB2 , OS/2 , DB2/6000 , Parallel Sysplex , MVS/ESA , RS/6000 , AIX , S/390 ,
® ® ®
AS/400 , OS/390 , and OS/400 are registered trademarks of IBM Corporation.
®
ORACLE is a registered trademark of ORACLE Corporation, California, USA.
® ® TM
INFORMIX -OnLine for SAP and Informix Dynamic Server are registered trademarks of
Informix Software Incorporated.
® ® ® ®
UNIX , X/Open , OSF/1 , and Motif are registered trademarks of The Open Group.
®
HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C , World Wide
Web Consortium, Laboratory for Computer Science NE43-358, Massachusetts Institute of
Technology, 545 Technology Square, Cambridge, MA 02139.
®
JAVA is a registered trademark of Sun Microsystems, Inc. , 901 San Antonio Road, Palo Alto,
CA 94303 USA.
®
JAVASCRIPT is a registered trademark of Sun Microsystems, Inc., used under license for
technology invented and implemented by Netscape.
2 December 1999
SAP AG Web Transaction Programming
Icons
Icon Meaning
Caution
Example
Note
Recommendation
Syntax
Tip
December 1999 3
Web Transaction Programming SAP AG
Contents
4 December 1999
SAP AG Web Transaction Programming
Web Transaction Programming
December 1999 5
Web Transaction Programming SAP AG
Web Transaction Programming
6 December 1999
SAP AG Web Transaction Programming
Web Transaction Programming
Since HTML (on the Internet side) and ABAP (on the R/3 side) offer different programming
features, some objects used in ABAP programs or on R/3 screens are not supported by
HTML, so you have to adapt the HTML code accordingly.
• User authorizations
• Use of BAPIs (Business Application Programming Interfaces) when applying precisely
defined methods to business objects.
Apart from exchanging data between the Internet and the R/3 System, and converting HTML
to R/3 screen data and vice versa, the ITS also performs system administration functions
such as user management, system resource management, and Web transaction
management.
For further information on Web transaction programming, see:
Programming the R/3 Transaction [Page 8]
Creating the ITS Service [Page 29]
Adapting the HTML Code [Page 35]
Multiple Language Support [Page 41]
Web Transaction Programming Tools [Page 47]
Web Transaction API [Ext.]
ITS Synchronization [Ext.]
ITS Naming Conventions [Page 55]
This documentation describes the Web transaction programming model. For information
about other programming models for implementing IACs, see:
WebRFC Programming [Ext.]
Web Reporting [Ext.]
December 1999 7
Web Transaction Programming SAP AG
Programming the R/3 Transaction
8 December 1999
SAP AG Web Transaction Programming
Quick Guide to ABAP Elements in HTML
December 1999 9
Web Transaction Programming SAP AG
Quick Guide to ABAP Elements in HTML
10 December 1999
SAP AG Web Transaction Programming
Implementing Menus
Implementing Menus
The Web browser has a menu that contains browser-specific functions, but there are no other
menus available in individual HTML pages, and it is not possible to merge individual menu
options into the existing menu.
For this reason, Web transactions do not support menus, so user input must come through
pushbuttons.
December 1999 11
Web Transaction Programming SAP AG
Implementing Text Areas
12 December 1999
SAP AG Web Transaction Programming
Implementing Checkboxes
Implementing Checkboxes
At present, the DIAG protocol does not allow you to activate checkboxes (or radio buttons)
directly from an ABAP program in HTML. However, you can still use checkboxes in Web
transaction by means of a workaround.
To implement checkboxes in Web transactions, you identify them in HTML templates by the
names assigned in the Screen Painter. A checkbox field is always mapped to a character field
with a length of 1. The value of this field is either blank or you assign a value like ‘X’.
The handling of checkboxes by Web browsers can cause problems:
• If a checkbox is checked, the Web browser transmits the state of the checkbox to the Web
server.
• If a checkbox is not checked, the Web browser transmits nothing to the Web server when
the form is posted, so the Internet Transaction Server (ITS) receives no value and the called
program has no knowledge of the checkbox variable.
To reset a checkbox to blank, you can use a hidden HTML field and assign the value ‘ ‘ to the
checkbox field name. Since hidden HTML fields are always sent by the Web browser, the ITS
receives the value ‘ ‘, which resets the checkbox on the R/3 screen.
Although the HTML contains the hidden HTML field, the value ‘X’ is transferred to the ITS if the
checkbox is set and if it is specified after the hidden HTML form input field, because it takes
precedence over the hidden HTML field.
To find out the current state of a checkbox on the R/3 screen, you can use the checked
attribute in HTML. If the checkbox is set on the screen, the name assigned in the Screen Painter
Business
contains ‘X’. You can use the HTML statement if to set the checked attribute of the
checkbox depending on the value of the R/3 screen field.
</FORM>
December 1999 13
Web Transaction Programming SAP AG
Implementing Radio Buttons
HTML
OPTIONS = “RB_OPTION2”
R/3 Screen
R/3 fields
RB_OPTION1
RB_OPTION2
RB_OPTION3
You should ensure that the radio button group name is not the name of a valid R/3 screen.
14 December 1999
SAP AG Web Transaction Programming
Implementing Radio Buttons
December 1999 15
Web Transaction Programming SAP AG
Implementing Step Loops
16 December 1999
SAP AG Web Transaction Programming
Implementing Table Controls
Table Data
Business
The data displayed in table control fields is made available to the HTML interpreter via the
field names used on the screen, as shown in the following graphic:
Account Number[5]
Account Description[7]
The field index starts with 1 and increments up to the maximum number of lines of the dataset
displayed in the table control.
December 1999 17
Web Transaction Programming SAP AG
Implementing Table Controls
The following example shows the different attributes of the table control TABLE:
The name of the table control assigned in the Screen Painter is TABLE.
TABLE.columnCount = 8
TABLE.firstVisible = 6
TABLE.rowCount = 20
TABLE.lastVisible = 18
Event Action
TopPage Displays first page of dataset displayed by the table control.
This sets .firstVisible to 1.
LastPage Displays last page of dataset displayed by the table control.
This sets .lastVisible to the number of records of the dataset
displayed by the table control
PrevPage Displays previous page of dataset displayed by the table control.
This decreases .firstVisible and .lastVisible by the number of
visible lines of the table control.
NextPage Displays next page of dataset displayed by the table control.
This increases .firstVisible and .lastVisible by the number of visible
lines of the table control.
18 December 1999
SAP AG Web Transaction Programming
Implementing Table Controls
Business
To raise an event on a particular control, you use the HTML command wgateUrl() and
specify the two parameters ~control and ~event, as follows:
wgateUrl(~event=”EventName” ~control=”TableName”
The following example shows how to display the table control data in an HTML page and how to
scroll through the table control using two pushbuttons:
The following example shows the same functionality using two hypertext links:
<TABLE>
<THEAD>
<TD>Account Number</TD>
<TD>Account Description</TD>
</THEAD>
`repeat with i from Table.firstVisible to Table.lastVisible`
<TR>
<TD>`ACCOUNT-NUMBER[i]`</TD>
<TD>`ACCOUNT-DESCR[i]`</TD>
</TR>
`end`
<A HREF=“wgateUrl(~Event=PrevPage, ~Control=Table)“
Previous Page“ </A>
<A HREF=“wgateUrl(~Event=NextPage, ~Control=Table)“
Next Page“ </A>
</TABLE>
December 1999 19
Web Transaction Programming SAP AG
Implementing Table Controls
Web Browser
Next Page
Screen Screen
20 December 1999
SAP AG Web Transaction Programming
Implementing Table Controls
Unfortunately, using the Web browser’s Back button may result in HTML pages being pulled out
of the browser’s page cache, so that the data displayed in the Web browser is not visible on the
R/3 transaction screen.
Web Browser
Back
wrong fields!
Screen Screen
R/3
1 110-1 Detail 1
2 110-2 Detail 2
STEP 2: 3 110-3 Detail 3
Post data 4 110-4 Detail 4
Screen Screen
STEP 1:
Reposition scroll bar
December 1999 21
Web Transaction Programming SAP AG
Implementing Table Controls
Automatic Scrolling
Although the functionality of table controls and step loops is similar, table controls do not support
the automatic scrolling possible with step loops.
22 December 1999
SAP AG Web Transaction Programming
Implementing Table Controls
December 1999 23
Web Transaction Programming SAP AG
Implementing Table Controls
</TR>
`end`
<INPUT TYPE=“SUBMIT”
NAME=”~Event=PrevPage, ~Control=Table”
VALUE=”Previous Page”>
<INPUT TYPE=“SUBMIT”
NAME=”~Event=NextPage, ~Control=Table”
VALUE=”Next Page”>
<TABLE>
</FORM>
Restrictions
Until R/3 Release 4.0A, no field names were transferred for table controls, so Release 4.0B is the
first R/3 release where table controls are fully supported. If you write a transaction that could be
downported to R/3 releases earlier than 4.0B, please do not use table controls. Use step loops
instead.
24 December 1999
SAP AG Web Transaction Programming
Implementing Dialog Boxes
Service Setting
~popups
Value Meaning
0 Dialog boxes are suppressed (default).
1 Dialog boxes are supported.
December 1999 25
Web Transaction Programming SAP AG
Implementing Input Help
Syntax
searchhelp(~fieldname=expression)
Parameter Description
~fieldname Specifies the Screen Painter name of
the screen field for which input help is
requested.
26 December 1999
SAP AG Web Transaction Programming
Implementing Input Help
To display input help values, the ITS uses a system template called searchhelp.html:
The system administrator can modify this template according to the usual rules for modifying
system templates.
December 1999 27
Web Transaction Programming SAP AG
Implementing Input Help
The ITS only supports input help for R/3 Release 4.5A or later.
For further information about input help, see Search Helps [Ext.] in the ABAP Dictionary
documentation.
28 December 1999
SAP AG Web Transaction Programming
Creating the ITS Service
December 1999 29
Web Transaction Programming SAP AG
ITS Service Description
30 December 1999
SAP AG Web Transaction Programming
Themes
Themes
An ITS service can also be sub-divided into themes, which are instances of the service that differ
only in their look and feel (that is, layout, graphics, or language). Each theme has its own set of
HTML templates and other service files, but the functionality of the service is the same for all
themes. Themes have 2-character names.
To define a theme for a service description, you create a subdirectory for the theme in the service
directory, using the SAP@Web Studio [Ext.].
You can also specify a default theme for a service by inserting a ~theme service parameter in
the service description. A service can have multiple themes, but only one ~theme parameter
should appear in the service description. You can override this parameter by supplying a different
theme value in the URL at runtime.
A default theme 99 is defined globally for all services in the global service file global.srvc. This
theme is provided by default at ITS installation, and is used when no other theme is specified for
the particular service.
December 1999 31
Web Transaction Programming SAP AG
HTML Templates
HTML Templates
HTML templates are the means by which an IAC is displayed in a Web browser. For each screen
in an R/3 transaction, the ITS generates exactly one HTML template.
Business Business
Each HTML template contains standard HTML code and HTML statements. HTML is
an SAP-specific macro language, which allows you to merge R/3 data into HTML files at runtime.
Business
HTML statements are not evaluated by Web browsers, but by the ITS, which:
• Inserts R/3 screen data and R/3 screen texts into the appropriate HTML template
• Translates non-R/3 texts into the relevant language (using language resource files)
The completed template is then passed to the Web browser.
32 December 1999
SAP AG Web Transaction Programming
HTML Templates
If you make changes to an R/3 screen, you may also need to modify the HTML
template. You can either modify the template manually or recreate it using the new
R/3 screen description. If you recreate it, remember that any manual changes you
made to the previous template will be lost, so it’s a good idea to make backups of all
HTML templates before re-generating them.
December 1999 33
Web Transaction Programming SAP AG
Language Resource Files
34 December 1999
SAP AG Web Transaction Programming
Adapting the HTML Code
December 1999 35
Web Transaction Programming SAP AG
Adapting the HTML Code
Example: array.dim
For further information, see Referring to R/3 Fields [Ext.].
Replacing Arrays
The ITS also processes arrays. On the R/3 side, the arrays are either step loops on the screen or
tables sent from the screen to the ITS via RFC. You can access individual elements in an array
by specifying an index (in angle brackets) after the field name.
Example: array[j]
This assignment is valid for step loop fields in either direction. For further information, see
Referring to R/3 Arrays [Ext.].
• for
if Statement
Depending on some condition, you may want ITS to insert varying hyperlinks, suppress empty
fields or change the arrangement of fields on the screen.
Examples of if statement syntax are:
• if (expr) statements1 else statements2 end
• if (expr1) statements1
if (expr2) statements2
elsif (expr3) statements3
end
elsif (expr4) statements4
else statements1
end
36 December 1999
SAP AG Web Transaction Programming
Adapting the HTML Code
Expression Evaluation
Business
You can code standard expressions in HTML . The ITS evaluates these expressions when
executing your if, repeat, and for statements.
For information on expression syntax, see Expressions [Ext.].
HTMLBusiness Functions
HTML templates with hardcoded URLs or path names to graphics files may not always work
Business
correctly when transferred to other systems. HTML provides functions that generate URLs
and other HTML texts dynamically. You must use these functions to ensure that your templates
are correct, regardless of Web server or ITS configuration.
• assert [Ext.]
The assert function gets error messages from R/3. If an error is triggered during an R/3
transaction, R/3 determines the field responsible and passes a standard error text to the ITS.
The ITS replaces the assert statement with this message text.
• write [Ext.] and writeENC [Ext.]
The write function writes field contents and other information to the HTML document.The
only difference between write and simple replacement is that write adds no spaces for
separating individual values.
The writeENC function works similarly, except that the output is coded according to URL
requirements, so that spaces and special characters are replaced with their hexadecimal
code. This function lets you construct URLs correctly from fields that contain spaces and
special characters.
• wgateURL [Ext.]
This wgateURL function ensures browser independence by generating URLs that
dynamically take the location of the Web server into account.
• mimeURL [Ext.] and imageURL [Ext.]
The mimeURL function specifies links to static files (for example, graphics and help files) that
are to be incorporated in the HTML template at runtime. These files are not stored in the ITS
directory but in the HTTP server directory.
The imageURL function is an older version of mimeURL.
• archiveURL [Ext.]
The archiveURL function allows you to access functions in the iXOS archive. You choose the
appropriate function using the Command, ArchiveID and DocID parameters. You can find
further information about the iXOS archive in the appropriate product documentation.
December 1999 37
Web Transaction Programming SAP AG
Quick Guide to the HTML Generator
Text areas
Checkboxes <input type=”hidden” name=”option_1”
value=” ”>
<input type=”checkbox” name=”option_1”
value=”X”
`if ( option_1 == “X” )` checked `end` >
…
38 December 1999
SAP AG Web Transaction Programming
Quick Guide to the HTML Generator
To display table control data in an HTML page and page through using
two pushbuttons:
<FORM ACTION=“~wgateUrl()“ METHOD=“POST“>
<TABLE>
<THEAD>
<TD>Account Number</TD>
<TD>Account Description</TD>
</THEAD>
`repeat with i from Table.firstVisible to
Table.lastVisible`
<TR>
<TD>`ACCOUNT-NUMBER[i]`</TD>
<TD>`ACCOUNT-DESCR[i]`</TD>
</TR>
`end`
<INPUT TYPE=“SUBMIT”
NAME=”~Event=PrevPage, ~Control=Table”
VALUE=”Previous Page”>
<INPUT TYPE=“SUBMIT”
NAME=”~Event=NextPage, ~Control=Table”
VALUE=”Next Page”>
<TABLE>
</FORM>
To specify the target frame, you must manually add a target parameter to
the wgateURL call, for example: ~target=SUBSCREEN1.
December 1999 39
Web Transaction Programming SAP AG
Quick Guide to the HTML Generator
Group boxes OK to use, but the generated HTML depends on the R/3 release:
• In releases prior to 4.0, a group box in an R/3 screen signalled a
subscreen frame. For each R/3 group box, the HTML generator
produced a frame in the base HTML template.
• From Release 4.0, a group box in an R/3 screen has no equivalent in
HTML, so no group box is generated.
Dialog boxes Not supported. To implement dialog boxes, you need to set the service
file parameter ~popups.
Field help (F1) Not supported.
Input help (F4) To implement input help for a field, modify standard HTML using the
searchhelp macro
<FORM ACTION=“~wgateUrl()“ METHOD=“POST“>
`RMMG1-MATNR.label`
<INPUT TYPE=“TEXT“ NAME=“RMMG1-MATNR“
VALUE=“`RMMG1-MATNR`“>
`searchhelp(~fieldname=“RMMG1-MATNR“)`
</FORM>
40 December 1999
SAP AG Web Transaction Programming
Multiple Language Support
December 1999 41
Web Transaction Programming SAP AG
Setting the Logon Language
• In the URL
Sometimes the ITS is unable to determine a logon language from either the global
service description or the service description for the current service. This can happen in
the following cases:
− Neither contains a value for the ~language parameter
− The global service description specifies a value for the ~language parameter, but this is
overridden by a blank value in the service description for the current service.
If this happens, the ITS tries two other sources. First, it looks in the URL for a
~language=EN specification.
42 December 1999
SAP AG Web Transaction Programming
Setting the Logon Language
Business
The language used when the ITS logs on to R/3 is the same language used for all HTML
templates belonging to a service. However, you can change this behavior if you wish.
December 1999 43
Web Transaction Programming SAP AG
Using Language-Independent Templates
The file name of a language-specific HTML template contains a language indicator for the
relevant language. For example, if the language is English, the file name would be:
sapmaww1_100e.html
Language resource files for a service always have language indicators. For example, the name
of the English language resource file for the service aww1 would be:
aww1_e.htrc
When executing a transaction, the ITS must determine how to handle the language texts for the
HTML template. To do this, it:
1. Searches for an HTML template with the relevant language extension in the file name.
If such a template exists, the ITS uses it without a language resource file.
2. Searches for a template with no language extension in the file name, and a language
resource file for the current logon language.
Here, the ITS uses language-independent HTML templates in this and all subsequent
procedures.
3. Uses HTML templates with no language extension, and no language resource file.
In this case, the ITS assumes that the HTML templates have no texts needing
translation.
For further information about ITS naming conventions, see ITS Naming Conventions [Page 55].
44 December 1999
SAP AG Web Transaction Programming
Using Language-Specific Templates
The file name of a language-independent HTML template contains no language indicator. For
example:
sapmaww1_100.html
December 1999 45
Web Transaction Programming SAP AG
Setting Placeholders in Language Resource Files
The following are valid placeholders in HTML templates for the resource keys
CustomerName, Street, 1, Name:
`#CustomerName`
`#Street`
`#1`
`#Name`
46 December 1999
SAP AG Web Transaction Programming
Web Transaction Programming Tools
SAP@Web Studio
The SAP@Web Studio is a PC tool for creating and maintaining the external components
required by the ITS to run a Web transaction. These external components include:
• Service description
• HTML templates
Business
The Studio’s HTML editor recognizes and compiles HTML code, which is the HTML
extension language provided by SAP to merge HTML templates with R/3 screen data.
• Language resource files.
Although the SAP@Web Studio runs outside the R/3 System on your PC, it is connected to both
R/3 and the Web server, so you can also use it to:
• Publish finished files to the ITS server directory
• Transfer the finished files to ITS source control in the R/3 System
For further information, see SAP@Web Studio [Ext.].
HTMLBusiness
HTML templates in Web transactions correspond to screens in R/3 transactions. These
Business
templates contain both standard HTML code and HTML code.
Business
HTML is an SAP’s own extension of standard HTML for handling data transfer between R/3
screens and HTML templates. It allows you to merge the data dynamically from an R/3 screen
with fields in the corresponding HTML template.
For further information, see HTMLBusiness Language Reference [Ext.].
ITS Debugger
The ITS debugger is a tool for analyzing errors in Web transactions. It allows you to establish a
parallel connection between a Web transaction and a normal SAPgui. This means that you can
display the transaction in the Web browser and the SAPgui simultaneously. You can thus
activate the ITS debugger in the SAPgui and use it to analyze the current Web transaction.
For further information, see ITS Debugger [Page 48].
December 1999 47
Web Transaction Programming SAP AG
ITS Debugger
ITS Debugger
When you have created or modified all the external components required by the Internet
Transaction Server (ITS) to run a Web transaction, you must test these components against the
corresponding R/3 transaction. Several errors can occur outside the R/3 System, and although a
transaction may work correctly in R/3, it may not work as a Web transaction.
To analyze errors in Web transactions, you can use the ITS debugger, which is not a separate
debugging tool, but an integration of existing R/3 debugging facilities into the ITS. This integration
is possible because Web transactions are implemented in R/3 using the ABAP Workbench, and
differ only slightly from standard R/3 transactions. For example, Web transactions do not use
some of the screen elements allowed in standard R/3 screens. Also, you must observe special
dialog control rules when programming Web transactions.
The ITS debugger allows you to establish a parallel connection between a Web transaction and
its corresponding R/3 transaction. This means that you can display the transaction
simultaneously in the Web browser and the SAPgui. Effectively, you activate the ABAP debugger
in R/3 and use it to analyze your Web transaction. This way, you can determine whether a Web
browser action has produced the desired result in the SAPgui.
When you create an ITS service, the ITS creates an HTML template for each screen in the R/3
transaction. These templates control how the contents of R/3 fields are converted to HTML and
determine how user entries are transferred from the Web browser to R/3 screen fields. The ITS
debugger allows you to monitor this transfer, both in the HTML page, and in the R/3 System.
You synchronize these two user interfaces by logging on to the ITS using the SAPgui. The ITS
then acts as a virtual application server. You can log on to ITS using SAPgui and SAPgui will
display the current screen of your web transaction (even though you started it from the web
browser).
When you execute an action in the Web browser that changes the transaction status, the ITS
immediately adapts the SAPgui transaction screen. The following graphic illustrates this process:
48 December 1999
SAP AG Web Transaction Programming
ITS Debugger
December 1999 49
Web Transaction Programming SAP AG
Setting Up the ITS Debugger
Procedure
1. Log on to the ITS Administration Tool
2. In the Main frame, choose the relevant ITS instance.
3. In the frame for the ITS instance, choose Configuration.
4. In the Configuration frame, choose Debug.
5. If the value for Debug is set to OFF, choose Debug and select ON.
This activates the debugger.
6. Choose Save.
To run the ITS debugger, see Starting an ITS Debugger Session [Page 51].
50 December 1999
SAP AG Web Transaction Programming
Starting an ITS Debugger Session
December 1999 51
Web Transaction Programming SAP AG
Starting an ITS Debugger Session
52 December 1999
SAP AG Web Transaction Programming
Leaving an ITS Debugger Session
Result
In the current ITS version, the SAPgui window closes only after you leave the ITS service in the
Web browser.
December 1999 53
Web Transaction Programming SAP AG
Troubleshooting
Troubleshooting
If you notice that the Web browser and SAPgui transaction screens are displaying different
information, you must determine whether the SAPgui is displaying the correct information:
• If the SAPgui transaction screen contains the required information, there is probably an error
in the HTML template.
• If the SAPgui transaction screen contains the wrong information, there is probably an error in
the R/3 transaction.
54 December 1999
SAP AG Web Transaction Programming
ITS Naming Conventions
When creating a service, service names must conform to the naming conventions
applicable to customer systems. From R/3 Release 3.1H, service names should start
with the letter y or z.
The following tables show the naming conventions applied to the various ITS file types:
December 1999 55