Professional Documents
Culture Documents
Llessap PGD en PDF
Llessap PGD en PDF
Programming Guide
LLESSAP160000-PGD-EN-2
OpenText™ Activator for SAP Solutions
Programming Guide
LLESSAP160000-PGD-EN-2
Rev.: 2017-Feb-03
This documentation has been created for software version 16.0.0.
It is also valid for subsequent software versions as long as no new document version is shipped with the product or is
published at https://knowledge.opentext.com.
Tel: +1-519-888-7111
Toll Free Canada/USA: 1-800-499-6544 International: +800-4996-5440
Fax: +1-519-888-0677
Support: https://support.opentext.com
For more information, visit https://www.opentext.com
Disclaimer
Every effort has been made to ensure the accuracy of the features and techniques presented in this publication. However,
Open Text Corporation and its affiliates accept no responsibility and offer no warranty whether expressed or implied, for the
accuracy of this publication.
Table of Contents
PRE Introduction v
i About OpenText Activator for SAP Solutions ....................................... v
1 Components ............................................................................... 7
3 Tutorials ................................................................................... 17
3.1 Using the SAP OSpace ................................................................... 17
3.2 Using the configuration API .............................................................. 21
When you install Activator, a new API becomes available which allows OScript
programs to connect to SAP systems and call RFCs and BAPI methods.
The Content Server loads a Java library (jsaprfc.jar) that contains a Java class
(JRFC) that acts as a wrapper of SAP's JCo library.
The communication between Content Server and an SAP server is done by the SAP
JCo 3.0 library.
All functions needed to call RFCs or BAPIs are included in the SAP OSpace; this SAP
OSpace wraps the Java calls needed to perform RFCs. All database access regarding
SAP system configuration data are hidden in the configuration API of the SAP
OSpace.
Custom OScript can use the configuration API to retrieve the list of configured SAP
systems and to connect to a specific SAP system. To call RFCs or BAPIs, the RFC/
BAPI API of the SAP OSpace provides the necessary functions.
Activator encapsulates the SAP JCo Java classes within an OScript API.
The API is subdivided in two parts:
RFC/BAPI API
This API creates new temp objects for RFCs or BAPI methods and provides
importing, exporting and table parameters as features of these temp objects.
Configuration API
This API provides access to the SAP systems configuration data that is
maintained by administrators in the Content Server administration pages.
Parameters
destination
Type: string
The SAP destination name; this parameter is case-sensitive.
type
Type: string
The RFC connection type. Use value A for the application server (parameter
ashost must be specified), value B for load balancing using message server
(parameters mshost and pool must be specified).
ashost
Type: string
The SAP ABAP application server hostname; mandatory for a direct
connection. Specify empty string if RFC connection type is B.
mshost
Type: string
The SAP message server hostname; mandatory for a logon balancing
connection. Specify empty string if RFC connection type is A.
sysnr
Type: string
The system number of the SAP ABAP application server; mandatory for a
direct connection.
client
Type: string
The SAP client; mandatory logon parameter. Client numbers are usually
three-digit numbers.
user
Type: string
The SAP user name used to log in to the SAP system.
pass
Type: string
The password associated with the SAP user name.
lang
Type: string
The code for the logon language; parameters are e.g. DE (German) or EN
(English).
groupname
Type: string
The group of SAP application servers; mandatory for a logon balancing
connection.
sysid
Type: string
The system ID of the SAP system; mandatory for a logon balancing
connection.
Return Value
Type: Assoc
.OK: true if call of $SAP.RFC Connect was successful, otherwise false.
.errMsg: error message (.OK is false).
.connection: JCoDestination object already connected to SAP system (.OK is
true).
.exception: Assoc with exception data if .OK is false and an exception occurred.
In $SAP.RFC New, the target SAP system gets called to retrieve the description of the
function interface of the desired RFC; the function then uses this information to
create features for each RFC parameter. In addition, an Assoc fImports is created
with all import parameters and an Assoc fExports is created with all export
parameters. Table parameters are added to the fImports and fExports.
To set values of importing or table parameters, just set the values of the features
with the name of the parameter in the newly created RFC object.
Parameters
connection
Type: dynamic
The JCoDestination instance to be used for connecting to the SAP system.
rfcName
Type: string
Name of the RFC for which the RFC object should be created.
Return Value
Type: $SAP.RFC
A new temp of a $SAP.RFC object or undefined in case of an error.
Return Value
Type: Assoc
.OK: true if execution of $SAP.RFC Call was successful, otherwise false.
.message: error message (.OK is false).
.stacktrace: Java stacktrace (.OK is false).
Parameters
rfcObject
Type: object
The $SAP.RFC temp object to be deleted.
For each method a new child object of the new temp of $SAP.BAPI is created. The
feature OSName is set with the method name. The feature fBapiMethodName is set
with the uppercase method name. Features are created for each import, export and
table parameter. In addition, an Assoc fImports is created with all import
parameters and an Assoc fExports is created with all export parameters. Table
parameters are added to the fImports and fExports, exceptions are added to the
Assoc fExceptions. To set values of importing or table parameters, just set the values
of the features with the name of the parameter in the newly created BAPI method
object.
Note: $SAP.BAPI behaves like $SAP.RFC but with the difference that for the
BAPI methods new child objects are created and the parameters are added as
features to this child object.
Parameters
connection
Type: dynamic
The JCoDestination instance to be used for connecting to the SAP system.
bapiName
Type: string
Name of the SAP business object type (BAPI).
bapiMethod
Type: string
Name of the method of the specified SAP business object type.
Return Value
Type: $SAP.BAPI
A new temp of a $SAP.BAPI object or undefined in case of an error.
Parameters
prgCtx
Type: object
Program context
destination
Type: string
Name of the logical SAP system. Must be configured in the SAP Systems
section of the Content Server Administration.
Return Value
Type: Assoc
.OK: true if call of $SAP.RFC Connect was successful, otherwise false.
.errMsg: error message (.OK is false).
.connection: JCoDestination instance (.OK is true).
Parameters
prgCtx
Type: Object
Program context
destination
Type: String
Name of the logical SAP system.
Return Value
Type: Assoc
.OK: true if call of $SAP.RFC Connect was successful, otherwise false.
.errMsg: error message (.OK is false).
.found: number of configured SAP systems with the specified logical SAP
system name.
Parameters
prgCtx
Type: object
Program context
Return Value
Type: Assoc
.OK: true if call of $SAP.RFC Connect was successful, otherwise false.
.errMsg: error message (.OK is false).
.sapsystems: Assoc with an Assoc item for each SAP system. The key in
the .sapsystems Assoc is the logical SAP system name. Each of the SAP system
items has the following elements:
• DEST: Logical SAP system name.
• ASHOST: Application server hostname.
• MSHOST: Message server hostname.
• GROUPNAME: Group of SAP application servers; mandatory for a logon
balancing connection.
2.2.4 $SAP.SapSystems
GetEnabledSapSystemsByClientAndSystemId function
(Object, String, String)
Returns an Assoc with the configuration data for a SAP system specified by client
and system ID.
Parameters
prgCtx
Type: object
Program context
client
Type: string
SAP client
sapSystemId
Type: string
SAP System ID
Return Value
Type: Assoc
.OK: true if no errors occurred in that function.
.errMsg: error message (.OK is false).
.found: 0 if no SAP system is configured and enabled with the specified
parameters. 1 if one is found.
.sapsystem: if .found is 1, Assoc with configuration data for the SAP system.
Parameters
prgCtx
Type: object
Program context
destination
Type: string
Name of the logical SAP system.
Return Value
Type: Assoc
.OK: true if call of $SAP.RFC Connect was successful, otherwise false.
.errMsg: error message (.OK is false).
.sapsystem: Assoc with configuration data for the SAP system.
For the description of the Assoc’s elements, see 2.2.3.
Parameters
prgCtx
Type: object
Program context
Return Value
Type: Assoc
.OK: true if call of $SAP.RFC Connect was successful, otherwise false.
.errMsg: error message (.OK is false).
.sapsystems: Assoc with an Assoc item for each SAP system.
For the description of the Assoc’s elements, see 2.2.3.
In the following you find tutorials for the practical usage of the different methods.
Code
Assoc result
Assoc retval
retval.ok = true
Boolean ok = true
if ok
rfcMethod = $SAP.RFC.New( connection, "RFC_READ_TABLE" )
if IsUndefined( rfcMethod )
retval.errMsg = "ERROR: can't create $SAP.Rfc object for
RFC_READ_TABLE - see thread log for more information"
retval.ok = false
ok = false
end
end
if ok
rfcMethod.QUERY_TABLE = "USR01"
result = rfcMethod.Call()
if result.ok == false
ok = false
retval.ok = false
retval.errMsg = Str.Format( "ERROR: rfcErrorGroup: %1,
rfcErrorKey: %2, rfcErrorMessage: %3, rfcErrorCode: %4.",
result.rfcErrorGroup, result.rfcErrorKey, result.rfcErrorMessage,
result.rfcRetCode )
else
// retrieve the results
records = rfcMethod.FIELDS
end
end
if ok
echo ( Str.Format( "Table %1 has %2 records.",
rfcMethod.QUERY_TABLE, Length( records ) ) )
else
echo ( retval.errMsg )
end
// 5) cleanup
if IsDefined( rfcMethod )
$SAP.RFC.Delete( rfcMethod )
end
When you run the script, you will get the following output in the debug window:
Code
Assoc result
Assoc retval
retval.ok = true
Boolean ok = true
if ok
bapiMethod = $SAP.BAPI.New( connection, "EmployeeAbstract",
"GetList" )
if IsUndefined( bapiMethod )
retval.errMsg = "ERROR: can't create $SAP.BAPI object
for BAPI Employee and method GetList - see thread log for more
information"
retval.ok = false
ok = false
end
end
if ok
bapiMethod.PersonnelNumber = "00001006"
result = bapiMethod.Call()
if result.ok == false
ok = false
retval.ok = false
retval.errMsg = Str.Format( "ERROR: rfcErrorGroup: %1,
rfcErrorKey: %2, rfcErrorMessage: %3, rfcErrorCode: %4.",
result.rfcErrorGroup, result.rfcErrorKey, result.rfcErrorMessage,
result.rfcRetCode )
else
// 4) check BAPI Return value and retrieve the results
if Length( bapiMethod.("Return").Code ) != 0
retval.ok = false
retval.errMsg = Str.Format("BAPI returned the
message: %1.", bapiMethod.("Return").MESSAGE )
ok = false
else
retval.message = Str.Format("Employee with
personnel number %1 is %2 %3.", bapiMethod.PersonnelNumber,
bapiMethod.PersonalData[ 1 ].FIRSTNAME,
bapiMethod.PersonalData[ 1 ].LAST_NAME )
end
end
end
if ok
echo ( retval.message )
else
echo ( retval.errMsg )
end
// 6) cleanup
if IsDefined( bapiMethod )
$SAP.BAPI.Delete( bapiMethod )
end
When you run the script, you will get the following output in the debug window:
Note: For successful execution of the tutorial, an SAP system with the logical
SAP system name DPX must be configured in the SAP Systems section on the
the Content Server Administration.
See below for step 1) where the logical SAP system name is used to connect to the
SAP system. The code after step 1) is the same as in the previous tutorial (Calling
RFC ‘RFC_READ_TABLE’).
Code
Assoc result
Assoc retval
retval.ok = true
Boolean ok = true
String cnctName =
$Kernel.SystemPreferences.GetPrefGeneral( 'DftConnection' )
if ok
result = $SAP.SapSystems.ConnectToDestination( prgCtx,
logSAPSystemName )
if result.OK
connection = result.connection
else
retval.ok = false
retval.errMsg = result.errMsg
ok =false
end
end
if ok
rfcMethod = $SAP.RFC.New( connection, "RFC_READ_TABLE" )
if IsUndefined( rfcMethod )
retval.errMsg = "ERROR: can't create $SAP.Rfc object for
RFC_READ_TABLE - see thread log for more information"
retval.ok = false
ok = false
end
end
if ok
rfcMethod.QUERY_TABLE = "USR01"
result = rfcMethod.Call()
if result.ok == false
ok = false
retval.ok = false
retval.errMsg = Str.Format( "ERROR: rfcErrorGroup: %1,
rfcErrorKey: %2, rfcErrorMessage: %3, rfcErrorCode: %4.",
result.rfcErrorGroup, result.rfcErrorKey, result.rfcErrorMessage,
result.rfcRetCode )
else
// 4) Retrieve the results
records = rfcMethod.FIELDS
end
end
if ok
echo ( Str.Format( "Table %1 has %2 records.",
rfcMethod.QUERY_TABLE, Length( records ) ) )
else
echo ( retval.errMsg ) end
// 6) Cleanup
if IsDefined( rfcMethod )
$SAP.RFC.Delete( rfcMethod )
End