Previous Contents Index DocHome Next |
iPlanet Application Server Enterprise Connector for R/3 Developer's Guide |
"> Setting Up and Executing the Function Object
Chapter 3 Programming Examples
This chapter describes the procedure for acquiring UIF objects and executing function objects.The iPlanet Application Server Enterprise Connector for SAP R/3 is used to execute SAP R/3 functions on a remote SAP R/3 server. The servlet uses the SAP R/3 connector to access the SAP R/3 server.
This chapter contains the following sections:
Data Objects
Data Objects
Data objects represent data in a hierarchal fashion; circular references are not allowed. iPlanet Application Server Enterprise Connector for SAP R/3 prevents a data object being used as an attribute of itself. Indirect circular references are not checked by iPlanet Application Server for SAP R/3.
No error message is generated if an indirect circular reference is defined. Unpredictable results occur if a circular reference is used at runtime.
The data objects contain actual data and metadata.
iPlanet Application Server Enterprise Connectors for SAP R/3 allows you to access data through the data object interface. The data object interface:
presents a unified representation of backend data types
Data objects are built from primitive types. A primitive data object contains a primitive value; e.g., integer, string. Arrays and structures are complex data objects.
Primitive Objects
Primitive Objects
A primitive data-type object contains a single value of one of the following types
integer, float, double
Figure 3-1    Primitive Object
integer, float, double
Integer, float, and double-data type objects hold a value whose type corresponds to the java-data type.When a primitive data object is assigned to a list, array, or structure, the data object is unwrapped and its value is copied into the list, array or structure. The data object itself is not used. When a primitive value is obtained by using an untyped get-method, such as getField(), getElem(), getAttr(), or getCurrent(), the returned value is wrapped in a primitive data object. In this case, the value is copied, thus, modifying the returned primitive data object does not change the source object.
fixed-length string, variable-length string
Strings correspond to the java-string data type A fixed-length string has a maximum length, whereas a variable-length string has no restrictions on its length.
fixed-size byte array, variable-size byte array
A fixed-size byte array has a maximum size, whereas a variable-size byte array has no restriction on its size.When a new value replaces an old value, the old value is released. Thus, when a new value is assigned to a variable-length string or a variable-size byte array, the old value is released. When a new value is assigned to a fixed-length string or a fixed-size byte array, the new value is copied over the old one. In the case of a fixed-length string, the copied string is truncated to fit if necessary. In the case of a fixed-size byte array, a shorted array is zero filled on the right and a longer array is truncated to fit.
The maximum length of a fixed-length string and the maximum size of a fixed-size byte array are set when the string's initial value is specified; i.e. four characters in the following example;
If a five character value is used, the value is truncated to four characters by dropping the fifth character.
Structure Objects
Structure objects contain other data objects or primitive values as fields. Each object within the structure object is referred to by a string that represents the field name. Field names have a maximum length of 32 characters. A structure's fields are heterogeneous.
Figure 3-2    Structure Object
Array Objects
An array object contains data objects or primitive values as elements in the object. array objects inherit from list objects. The difference between an array object and a list object is that the array's elements must be homogeneous. Each element within the array object is referred to by an integer that specifies its position in the array object.
Figure 3-3    Array Object
Type Information Objects
Type information objects are structured objects that contain the type information of a data object; i.e. a type information object might define the fields in a structure and their corresponding data types. Instances of data objects can be created of type information objects. Each of these instances contain a reference to a type of information object. Numerous data types can share the same type information object.
API Naming Conventions
Methods in the API conform to a naming convention that specifiesIn the following example of the form <operation><target><type>:
get is the operation, Elem is the target, and String is the type.
Operation
There are many types of operations but the two most commonly used are
None (primitive)
Attr (complex DataObject such as a list, array, or structure) that uses path to address attribute.
Elem (list/array) uses index to address element
Type
The types of operations are
Attributes and Paths
In the API, methods of the IBSPDataObject interface do not distinguish between an element in an array and a field in a structure. In this case the element or field is referred to as an attribute.The path to an element is its element number, beginning from zero. The path to a field is its field name.You may combine element numbers and field names to create paths to attributes in complex data objects, such as a field of a structure that contains a list of elements. In this case, you specify the path as the individual attributes separated by periods (.); i.e. use "field1.[01]" to identify the first element of a list at field1 in the structure.
Changing Data Types
If an attribute's type is primitive, it can not change. For example, the following code causes an error because it tries to change the type of a primitive from an integer to a float:
Working with Servlet Samples
To execute a SAP R/3 transaction from a servlet, your servlet must perform the following generalized actions:
Acquire the UIF Runtime Object
Create the Service Provider Object
Setting Up and Executing the Function Object
Acquire the UIF Runtime Object
The runtime object is the entry point into UIF. It is both the object factory and the access point for creating other objects.The following is an example of how to acquire a runtime object.
Create the Service Provider Object
The service provider is the logical representation of a connection to a backend system. Typically, the service provider is not bound to a physical connection until it is absolutely necessary. A service provider must be enabled before it can be used.
Detailed Description of Service Provider
A service-provider type represents a connection to a backend SAP R/3 system. It contains configuration information such as the kinds of data required to create a connection, e.g., host, port, user name, and password.A service-provider type may also specify additional information required to manage a connection.
The following diagram shows the parts of a service provider type.
Figure 3-4    Service Provider Types
Table 3-2 Service Provider Type
Name of the specific group of application servers. For load-balancing only.
Host name of the message server. For load-balancing connection only.
The following is an example of how to create a service provider object.
Parameter
Definition
SAP
Data source name
connection
Service provider name
Create the Function Object
A function object is a group of related operations that share a common state. In iPlanet Application Server for SAP R/3, a function object needs to be set up and associated with a service provider before the function object can be executed.The following diagram shows the function object type.
Figure 3-5    Function Object Type
The following is an example of how to create a function object.
Parameter
Definition
SAP
Data source name
BAPI_EMPLOYEE_GETLIST
SAP RFC function name
Prepare the function object, set up the propertySet, and set up the input parameters in the function object's data block.
Activation
The SAP Samples consist of servlets which activate SAP R/3 programs that access SAP database.
Running the SAP Samples on Solaris
<ias directory>/ias/APPS/bin/startsapworker.sh start
Run this script before running the samples.
BAPI_CUSTOMER_GETDETAIL SAMPLE
startsapworker:sh start (on Solaris)
run the starsapworker.bat (on NT)
Note
Make sure you have started the sapworker by running the command:
Activating the BAPI_CUSTOMER_GETDETAIL Sample
Code Samples
The following are the code examples for the BAPI_CUSTOMER_GETDETAIL sample.
Previous Contents Index DocHome Next
Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.
Last Updated June 08, 2000