|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.fc.Function
com.ibm.di.fc.sapr3rfc.SapR3RfcFC
public final class SapR3RfcFC
ITDI Function Component for SAP R/3 RFC Invocations.
This function component provides the ability to invoke an arbitrary ABAP RFC that is exposed by SAP R/3. It supports SAP R/3 4.6C.
This FC establishes connections and invokes RFCs using SAPs middleware JCo. To use this function component the correct version of JCo (currently 2.1.3) must be installed on your system. See http://service.sap.com/connectors for details on how to download and install SAP JCo.
Configuration is accomplished by setting logon parameters for client connections to R/3. The parameters are very similar to the logon parameters for the traditional SAP GUI. See initialize for more details on how to initialize.
initialize(java.lang.Object)
must be the first operation called in this class.
perform(java.lang.Object)
can then be called one or more times.
terminate()
must be called to allow connection cleanup before the class is destroyed.
A typical connection to SAP requires setting the following SAP client configuration parameters. These should be set prior to calling initialize.
Additional parameters are also available. See the table of PARAM_CONFIG_* values for a brief explanation.
Using the FC
It can be placed in an assembly line or invoked directly from script. It is the
callers' responsibility to check the returned Entry object for any errors that may
have resulted from invoking the RFC.
The FC can be invoked directly from script. As an example the following code can
be used to invoke an RFC from JavaScript using the XML string style:
var fc = system.getFunction("ibmdi.SapR3RfcFC");
var docResponse = null;
var response;
fc.setParam(fc.PARAM_CONFIG_CLIENT, "200");
fc.setParam(fc.PARAM_CONFIG_USER, "SMITH");
fc.setParam(fc.PARAM_CONFIG_PASSWORD, "PASSWORD");
fc.setParam(fc.PARAM_CONFIG_SYSNUMBER, "11");
fc.setParam(fc.PARAM_CONFIG_APPLICATION_SERVER, "servername");
fc.initialize(null);
var rfc = new java.lang.String("<BAPI_COMPANYCODE_GETLIST/>");
var myentry = system.newEntry();
myentry.setAttribute(fc.PARAM_INPUT, rfc);
Attribute reqType = new Attribute();
reqType.addValue(SapR3RfcFC.PARAM_VAL_STRING);
entry.setAttribute(SapR3RfcFC.PARAM_INPUT_TYPE, reqType);
myentry = fc.perform(myentry);
var output = myentry.getAttribute(fc.PARAM_OUTPUT);
response = output.getValue(0);
fc.terminate();
Note that configuration parameters must be set before initialize() is called, and terminate() should be called to cleanup.
Here is another example invoking the RFC FC using the multi valued attributes style:
var rfc = system.newAttribute("BAPI_SALESORDER_GETLIST");
var attr1 = system.newAttribute("CUSTOMER_NUMBER");
attr1.addValue("0000000016");
var attr2 = system.newAttribute("SALES_ORGANIZATION");
attr2.addValue("AU01");
rfc.addValue(attr1);
rfc.addValue(attr2);
var entry = system.newEntry();
entry.setAttribute("requestType", "multiValuedAttributes");
var reqAttr = entry.newAttribute("request");
reqAttr.addValue(rfc);
var result = fc.perform(entry);
Field Summary | |
---|---|
static String[] |
EXT_PARAM_JCO_CLIENT_OPTIONS
|
static String |
PARAM_CONFIG_ABAP_DEBUG
Enable ABAP debugging 0 or 1 (jco.client.abap_debug). |
static String |
PARAM_CONFIG_ALIAS_USER
Alias user name (jco.client.alias_user). |
static String |
PARAM_CONFIG_APPLICATION_SERVER
SAP application server (jco.client.ashost). |
static String |
PARAM_CONFIG_CLIENT
SAP client (jco.client.client). |
static String |
PARAM_CONFIG_CODEPAGE
Initial codepage in SAP notation (jco.client.codepage). |
static String |
PARAM_CONFIG_DSR
Enable (1) or Disable (0) dsr support (jco.client.dsr). |
static String |
PARAM_CONFIG_EXTERNAL_AUTHENTICATION_DATA
Data for external authentication (PAS) (jco.client.extiddata). |
static String |
PARAM_CONFIG_EXTERNAL_ID_TYPE
Type of external authentication (PAS) (jco.client.extidtype). |
static String |
PARAM_CONFIG_GATEWAY_HOST
Gateway host (jco.client.gwhost). |
static String |
PARAM_CONFIG_GATEWAY_SERVICE
Gateway service (jco.client.gwserv). |
static String |
PARAM_CONFIG_GETSSO2
Get/Don't get a SSO ticket after logon (1 or 0) (jco.client.getsso2). |
static String |
PARAM_CONFIG_GROUP
Group of SAP application servers (jco.client.group). |
static String |
PARAM_CONFIG_IDLE_TIMEOUT
Idle timeout (in seconds) for the connection after which it will be closed by R/3. |
static String |
PARAM_CONFIG_LANGUAGE
Logon language (jco.client.lang). |
static String |
PARAM_CONFIG_LOGON_CHECK
Enable/Disable logon check at open time, 1 (enable) or 0 (disable) (jco.client.lcheck). |
static String |
PARAM_CONFIG_MESSAGE_SERVER
SAP message server (jco.client.mshost). |
static String |
PARAM_CONFIG_MYSAPSS02
Use the specified SAP Cookie Version 2 as logon ticket (jco.client.mysapsso2). |
static String |
PARAM_CONFIG_PASSWORD
Logon password (jco.client.passwd). |
static String |
PARAM_CONFIG_R3NAME
SAP R/3 name (jco.client.r3name). |
static String |
PARAM_CONFIG_SAPLOGON_ID
String defined for SAPLOGON on 32-bit Windows (jco.client.saplogon_id). |
static String |
PARAM_CONFIG_SNC_LIB
Path to library which provides SNC service (jco.client.snc_lib). |
static String |
PARAM_CONFIG_SNC_MODE
Secure network connection (SNC) mode, 0 (off) or 1 (on) (jco.client.snc_mode). |
static String |
PARAM_CONFIG_SNC_MYNAME
SNC name. |
static String |
PARAM_CONFIG_SNC_PARTNERNAME
SNC partner, e.g. |
static String |
PARAM_CONFIG_SNC_QOP
SNC level of security, 1 to 9 (jco.client.snc_qop). |
static String |
PARAM_CONFIG_SYSNUMBER
SAP system number (jco.client.sysnr). |
static String |
PARAM_CONFIG_TPHOST
Host of external server program (jco.client.tphost). |
static String |
PARAM_CONFIG_TPNAME
Program ID of external server program (jco.client.tpname). |
static String |
PARAM_CONFIG_TRACE
1 (Enable) or 0 (disable) RFC trace (jco.client.trace). |
static String |
PARAM_CONFIG_TYPE
Type of remote host 2 = R/2, 3 = R/3, E = External (jco.client.type). |
static String |
PARAM_CONFIG_USE_SAPGUI
Use remote SAP graphical user interface (0/1/2) (jco.client.use_sapgui). |
static String |
PARAM_CONFIG_USER
Logon user (jco.client.user). |
static String |
PARAM_CONFIG_X509_CERTFICATE
Use the specified X509 certificate as logon ticket (jco.client.x509cert). |
static String |
PARAM_INPUT
Attribute name of the RFC request. |
static String |
PARAM_INPUT_TYPE
Attribute named requestType set on Entry input. |
static String |
PARAM_JCO_CLIENT_OPTIONS_PREFIX
|
static String |
PARAM_OUTPUT
Attribute name of the RFC response. |
static String |
PARAM_OUTPUT_TYPE
Name of attribute on output with string value indicating response type. |
static String |
PARAM_VAL_DOM_DOCUMENT
Used to indicate response/request of type DOM document. |
static String |
PARAM_VAL_MVA
Used to identify response/request of type Attribute. |
static String |
PARAM_VAL_STRING
Used to indicate response/request of type XML string. |
Fields inherited from class com.ibm.di.fc.Function |
---|
logger |
Constructor Summary | |
---|---|
SapR3RfcFC()
Constructor. |
Method Summary | |
---|---|
Log |
getLog()
Returns the logger object i use by this FC |
String |
getVersion()
Returns the version of this FC. |
void |
initialize(Object o)
This function is called once after the connector configuration file has been provided by the caller. |
void |
logError(String msg)
|
void |
logmsg(String arg0)
Logs the msg string value to the currently used log |
Object |
perform(Object obj)
Execute the RFC. |
void |
setLog(Log arg0)
Sets the logger object to use in this FC |
void |
setParam(String param,
Object value)
Sets the param attribute of the FunctionInterface object |
void |
terminate()
This function is called when the connector is no longer needed by the user. |
Methods inherited from class com.ibm.di.fc.Function |
---|
debug, getConfiguration, getContext, getParam, getUI, initialize, setConfiguration, setContext, updateSchema, verifyInitialized |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PARAM_JCO_CLIENT_OPTIONS_PREFIX
public static final String PARAM_CONFIG_CLIENT
public static final String PARAM_CONFIG_USER
public static final String PARAM_CONFIG_ALIAS_USER
public static final String PARAM_CONFIG_PASSWORD
public static final String PARAM_CONFIG_SYSNUMBER
public static final String PARAM_CONFIG_APPLICATION_SERVER
public static final String PARAM_CONFIG_MESSAGE_SERVER
public static final String PARAM_CONFIG_GATEWAY_HOST
public static final String PARAM_CONFIG_GATEWAY_SERVICE
public static final String PARAM_CONFIG_LANGUAGE
public static final String PARAM_CONFIG_TRACE
public static final String PARAM_CONFIG_CODEPAGE
public static final String PARAM_CONFIG_SNC_MODE
public static final String PARAM_CONFIG_SNC_PARTNERNAME
public static final String PARAM_CONFIG_SNC_QOP
public static final String PARAM_CONFIG_SNC_MYNAME
public static final String PARAM_CONFIG_SNC_LIB
public static final String PARAM_CONFIG_R3NAME
public static final String PARAM_CONFIG_GROUP
public static final String PARAM_CONFIG_TPNAME
public static final String PARAM_CONFIG_TPHOST
public static final String PARAM_CONFIG_TYPE
public static final String PARAM_CONFIG_ABAP_DEBUG
public static final String PARAM_CONFIG_USE_SAPGUI
public static final String PARAM_CONFIG_GETSSO2
public static final String PARAM_CONFIG_MYSAPSS02
public static final String PARAM_CONFIG_X509_CERTFICATE
public static final String PARAM_CONFIG_LOGON_CHECK
public static final String PARAM_CONFIG_SAPLOGON_ID
public static final String PARAM_CONFIG_EXTERNAL_AUTHENTICATION_DATA
public static final String PARAM_CONFIG_EXTERNAL_ID_TYPE
public static final String PARAM_CONFIG_IDLE_TIMEOUT
public static final String PARAM_CONFIG_DSR
public static final String[] EXT_PARAM_JCO_CLIENT_OPTIONS
public static final String PARAM_INPUT_TYPE
public static final String PARAM_OUTPUT_TYPE
public static final String PARAM_VAL_DOM_DOCUMENT
public static final String PARAM_VAL_STRING
public static final String PARAM_VAL_MVA
public static final String PARAM_INPUT
public static final String PARAM_OUTPUT
Constructor Detail |
---|
public SapR3RfcFC()
Method Detail |
---|
public void setParam(String param, Object value)
Function
setParam
in interface FunctionInterface
setParam
in class Function
param
- The new param valuevalue
- The new param valuepublic void terminate() throws SapR3RfcFCException, Exception
terminate
in interface FunctionInterface
terminate
in class Function
Exception
- If super class terminate fails.
SapR3RfcFCException
- If internal SAP connection closure fails.public void initialize(Object o) throws Exception
initialize
in interface FunctionInterface
initialize
in class Function
o
- The configuration object from ITDI.
Exception
- If super class initialize fails.public String getVersion()
public Object perform(Object obj) throws SapR3RfcFCException, SapR3FCParameterException
Execute the RFC. Must be called prior to calling this method.
The perform() method accepts an Entry object. If anything else is passed an Exception is thrown.
The Entry object contains two attributes: request
and requestType
. It
supports three styles of invocation.
The value of requestType
can be one of xmlDomDocument, xmlString, multiValuesAttributes.
It indicates the type of the value associated with request
.
The value of attribute request
is a type of java.lang.String, org.w3c.dom.Document or
com.ibm.di.entry.Attribute which contains the request as either a XML String, DOM Document,
or multi-valued Attribute. Any other value will result in an Exception being thrown.
If request
is of type org.w3c.dom.Document, then its associated value must
be an org.w3c.dom.Document containing an XSchema which conforms to the specification
for ABAP RFC XML serialization (see http://ifr.sap.com).
If request
is of type java.lang.String, then its associated value must be
an XML string. The string value will be parsed by a DOM parser. Its XSchema must also
conform to the specification for Serialization of ABAP Data in XML (see http://ifr.sap.com).
If request
is a multi-valued attribute the first value of attribute
request
must
be of type java.lang.String containing the name of the RFC, while the second value
of the attribute request
must be com.ibm.di.entry.Attribute whose values contain
additional attributes for the SAP RFC parameters as a series of nested and multi-valued
attributes representing the names of the import and table parameters of the RFC.
The names of the parameters must be encoded according to the rules for Serialization
of ABAP Data in XML (i.e. names will not have characters that could result in badly
formed XML).
For example Java code for BAPI_USER_GET_DETAIL where USERNAME = SAP* would be:
Attribute inputAttrib = new Attribute();
Attribute username = new Attribute();
Attribute user = new Attribute();
Entry entry = new Entry();
inputAttrib.addValue("BAPI_USER_GET_DETAIL");
inputAttrib.addValue(username);
username.addValue(user);
user.setName("USERNAME");
user.addValue("SAP*");
entry.setAttribute(SapR3RfcFC.PARAM_INPUT, inputAttrib);
Attribute reqType = new Attribute();
reqType.addValue(SapR3RfcFC.PARAM_VAL_MVA);
entry.setAttribute(SapR3RfcFC.PARAM_INPUT_TYPE, reqType);
On response the Entry will contain the attributes responseType
and
response
. Attribute responseType
will have a java.lang.String
value corresponding to the input request type.
If the Entry contains an attribute responseType
with value xmlDomResponse
.
The value of Attribute response
is an org.w3c.dom.Document containing the RFC response.
If the Entry contains an attribute responseType
with value xmlString
.
The value of Attribute response
is a XML java.lang.String containing the RFC response.
If the Entry contains an attribute responseType
with value
multiValuedAttributes
. The value of Attribute response
is a nested
and multi-valued Attribute where the first value is a java.lang.String which has
the name of the RFC that was invoked, the second value contains
the results of the RFC as a series of nested multi-valued attributes.
obj
- Must be an Entry object.
SapR3RfcFCException
- thrown when errors occur invoking RFC
SapR3FCParameterException
- thrown when format of Entry on input is incorrectinitialize(java.lang.Object)
public void logError(String msg)
public Log getLog()
Function
getLog
in interface FunctionInterface
getLog
in class Function
public void logmsg(String arg0)
Function
logmsg
in interface FunctionInterface
logmsg
in class Function
arg0
- The message appearing in the logpublic void setLog(Log arg0)
Function
setLog
in interface FunctionInterface
setLog
in class Function
arg0
- The log object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |