Sie sind auf Seite 1von 21

Using BRFplus with a Third-Party Rules Engine

Applies to:
Business Rules Framework plus shipped with enhancement package 1 for SAP NetWeaver 7.0.

Summary
This document describes the implementation of a connection from BRFplus to a third-party rules engine via a JCo based connector. The document also explains the execution of BRFplus functions, implementation of the BRMS connector expression and the process involved in setting the third-party rules engine. Author: Sudhir Sangani Rao, Sreekanth Marella Reddy

Company: SAP Labs India Created on: 28 August 2008

About the Authors


Sudhir Rao is a Project Manager in the BRFplus team in SAP. He joined SAP in October 2007. Sudhir has been working in the business rules domain for the past 6 years.

Sreekanth is a Senior Software Engineer in SAP Labs India. Prior to working on BRFplus, he was involved with business rules software for ESB based SOA applications.

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 1

Using BRFplus with a Third-Party Rules Engine

Table of Contents
Introduction .........................................................................................................................................................3
Suggested Reading .....................................................................................................................................................3

Background .....................................................................................................................................................3 Setting up the Connection ..................................................................................................................................4 Defining the Function ......................................................................................................................................4 Defining the Expression ..................................................................................................................................5
Connection Type..........................................................................................................................................................5 Function Module ..........................................................................................................................................................5 Destination ...................................................................................................................................................................5 Signature......................................................................................................................................................................5 Connector Call Parameters..........................................................................................................................................6

Creating the Vocabulary .....................................................................................................................................6 BRMS Connector Execution ...............................................................................................................................7 Java Connector (JCo) Call Parameters ..........................................................................................................7 Exception Handling.............................................................................................................................................8 Implementation of the Third-party Connector .....................................................................................................8 JCo Server on NW AS Java............................................................................................................................8 Stand Alone JCo Server..................................................................................................................................9 Terminology ........................................................................................................................................................9 Appendix 1 ......................................................................................................................................................9 Appendix 2 ....................................................................................................................................................17 Appendix 3 ....................................................................................................................................................18 Appendix 4 ....................................................................................................................................................19 Related Content................................................................................................................................................20 Copyright...........................................................................................................................................................21

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 2

Using BRFplus with a Third-Party Rules Engine

Introduction
Business Rules Framework (BRFplus) is a business rules engine written entirely in ABAP. It provides an extensible framework for business rules definition and execution. From a rules modeling perspective, sometimes, it is advantageous to use a rules engine in a non-ABAP domain. The reasons for such an approach could include the following: The need to utilize specific features outside of the ABAP stack, such as stack-dependent actions or data retrieval which require tight integration with Java or non-ABAP applications. The need to use a rules engine with very specific features like a dedicated pricing engine or a product configurator or specific modeling tools.

The document will explain the implementation of the connection and the benefits of using this approach. Suggested Reading If you are not familiar with BRFplus, the following documents should give you an overview of the concepts in BRFplus. To learn about expression and action types and how to use them in the UI and API, refer to the Expression and Action Types document. BRFplus The Very Basics Expression and Action Types

Background BRFplus provides business rules definition using expressions, functions, and rulesets. The richness of the framework lies in the variety of expression types which are supported. Each expression type involves The runtime definition of the expression type The user interface associated with the expression The persistence and administration-related aspects associated with an expression type

With NetWeaver release 7.0 EHP1 and 7.1 EHP1, BRFplus provides a new expression type for connecting to third-party rules engines. The same expression type is also used for connecting to SAPs Java based business rules offering called NetWeaver Business Rules Management (NW BRM). NW BRM is a business rules platform fully integrated with NetWeaver Composition Environment (CE) and the next generation Business Process Management (BPM) offering (codename Galaxy).

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 3

Using BRFplus with a Third-Party Rules Engine

Setting up the Connection


Defining the Function The usual starting point for business rules in BRFplus is a function (which you define in the context of an application). A function has inputs and outputs. In the BRFplus user interface, the outputs are termed result objects. For the inputs, the context (data objects) has to be specified in the signature section. The image below shows a function signature.

The function has to be assigned a top expression.

In the image shown above, the top expression is an expression called CALLNWBRM. We will see how this expression connects to NW BRM. This expression can also be used to connect to a different thirdparty rules engine.

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 4

Using BRFplus with a Third-Party Rules Engine

Defining the Expression A function performs its calculations by invoking the expressions with the data provided. Each expression can call other expressions to achieve the desired results. The NW BRM connector expression achieves its results by calling the external rules engine. The following image shows how this connection is specified.

The key concepts involved in defining the BRMS connector expression are as follows: Connection Type There are two types of connection available, NetWeaver BRMS Connection or External BRMS Connection. Function Module This property is preselected based on the type of connection you choose. Destination Create a Remote Function Call (RFC) destination (transaction SM59) in AS ABAP with connection type as TCP/IP Connection and configure the gateway host, gateway service name and Program ID. Signature The signature of the BRMS connector contains the context (input) and the result (output). Context The context defines the parameters that are passed to the external BRMS as input. These parameters can be of two types. Exporting Exporting parameters are input parameters to the external BRMS which are read only. Even if the parameters are changed in the external BRMS, these value changes will not be reflected in BRFplus after the processing of the expression. Changing Changing parameters are input parameters to the external BRMS whose values can be changed. The modified values are reflected in BRFplus after the processing of the expression. The input

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 5

Using BRFplus with a Third-Party Rules Engine

parameters whose values might change during the processing have to be identified and set as Changing. Result The expected result of the expression has to be set in the result parameter. The result can be a single element data object or a structure data object or a table data object. Connector Call Parameters Additional parameters can be passed to the external BRMS for processing. For example, while connecting to the NW BRM, the project name and the ruleset name have to be passed to invoke the required ruleset. The connector call parameters are the <name>/<value>, pairs where Name is the key and Value the value of the key.

Creating the Vocabulary


After assigning the context and the result to the expression, the XML schema has to be generated. To generate the XML schema, click the Generate Vocabulary Schema button. The XML schema contains the metadata associated with the expression - the context and the result data. The XML schema is relevant for execution as BRFplus sends an XML document conforming to this schema to the external rules engine. A sample XML Schema is given below in Appendix 1.

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 6

Using BRFplus with a Third-Party Rules Engine

BRMS Connector Execution


During the execution of the function, the BRMS connector expression communicates to the specific thirdparty rules engine using the connection properties. The BRMS connector expression also sends the XML document along with the context information and the expected result as a request. The external rules engine reads the context information, evaluates the result and populates the result in the response XML. The XML document is then sent back. When the request is received, corresponding mappings take place on the ABAP side. A sample request XML and response XML document is given below in Appendix 2 and Appendix 3 respectively. Java Connector (JCo) Call Parameters BRFplus provides two Remote Enabled Function Modules (RFMs), FDT_NW_BRM_EXECUTE and FDT_EXT_BRMS_EXECUTE, for making JCo calls to the Java stack. For third-party BRMS, FDT_EXT_BRMS_EXECUTE should be used. The parameters passed by BRFplus to the external BRMS are described in the table below. BRMS specific parameters (for example, ruleset name and project name for NW BRM) are passed as a table of key value pairs fdts_brms_call_param.

Type IMPORTING

Name iv_input_xml xstring

Data Type

Remarks Context XML passed to BRMS BRMS specific parameters needed for execution Date time for executing rules that were active at some point in time Modified XML returned by BRMS

IMPORTING

its_call_parameter

fdtt_brms_call_param

IMPORTING

iv_date_time_iso

/ISD/DATE_ISO

EXPORTING

ev_output_xml

xstring

IMPORTING indicates those parameters that are passed by BRFplus to the external BRMS.

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 7

Using BRFplus with a Third-Party Rules Engine

EXPORTING indicates those parameters that are received by BRFplus from the external BRMS. fdtt_brms_call_param is a dictionary table type whose line type is a structure of fdts_brms_call_param. This structure has NAME and VALUE as its components.

Exception Handling
The RFMs created for JCo communication define the following exception codes: SYSTEM_FAILURE Indicates system level failures COMMUNICATION_FAILURE Indicates RFC or network communication failures INVALID_INPUT Indicates invalid parameters passed to external BRMS CONFIGURATION_ERROR Indicates invalid configuration in external BRMS PROCESSING_ERROR Indicates error while processing rules To indicate problems in the execution, the external BRMS connector implementation throws the following exception along with one of the above error codes: An AbapException in case of a standalone JCo server implementation A J2EEAbapException in case of a JCo server running on NW AS Java

BRFplus then takes appropriate action to rectify the problem.


Note: In case of an INVALID_INPUT, the actual input parameter name that causes the failure can be passed as the message parameter of AbapException or J2EEAbapException.

Implementation of the Third-party Connector


A JCo server program has to be written. The JCo server program should take the parameters passed from the BRFplus and should send back the modified values. The implementation basically involves Extracting parameters from JCo call Invoking the external BRMS passing in the parameter Returning changed values as part of return parameters to the JCo call There are two possible cases for a JCo server: A standalone JCo server A JCo server that is part of NW AS Java

JCo Server on NW AS Java JCo server must implement an EJB having a remote method JCo.Function processFunction(JCo.Function) The method should o Extract data from the input function instance Input data will be part of IMPORTING parameters as defined in the JCo parameter table o Process XML data with BRMS by calling the external rule engine o Return modified XML back to JCo through the return function instance Modified or output data should be part of EXPORTING parameters as defined in the JCo parameter table

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 8

Using BRFplus with a Third-Party Rules Engine

Note: The JNDI name of the session bean should be FDT_EXT_BRMS_CONNECTOR_PROCESS.

The call to the external rule engine could be an EJB, Web Service or an in-process call. A sample code snippet can be found below in Appendix 4. Stand Alone JCo Server JCo server must implement protected void handleRequest(JCo.Function function) method The method should o Extract data from the input function instance Input data will be part of IMPORTING parameters as defined in the JCo parameter table o Process XML data with BRMS by calling the external rule engine o Return modified XML back to JCo through the modified function instance Output data should be part of EXPORTING parameters as defined in the JCo parameter table

The call to the external rule engine itself could be an EJB, Web Service or an in-process call. A sample code snippet can be found below in Appendix 4.

Terminology
Appendix 1 Given below is a sample XML schema document (Vocabulary generated by BRFplus)
<?xml version="1.0" encoding="utf-8"?> ====================================================================== --> ===== BRFplus BRMS Connector Schema ===== --> ====================================================================== --> Scheme agency: BRFplus Scheme version: 1.0 Schema date: 11 April 2008. --> <xs:schema xmlns:FDTNS="http://sap.com/fdt/transport" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://sap.com/fdt/transport"> <!-- =================================================================== --> <!-- ===== BRFplus Type Definitions ===== --> <!-- =================================================================== --> <!-- ===== Number. Type ===== --> <!-- =================================================================== --> <xs:simpleType name="NumberType"> <xs:annotation> <xs:documentation xml:lang="en"> <FDTNS:Definition>Numeric information that is assigned or is determined by calculation, counting, or sequencing. It does not require a unit of quantity or unit of measure. </FDTNS:Definition> <FDTNS:PrimaryRepresentationTerm>Number </FDTNS:PrimaryRepresentationTerm> </xs:documentation> </xs:annotation> <xs:restriction base="xs:decimal"> <xs:totalDigits value="31"/> <xs:fractionDigits value="10"/> </xs:restriction> </xs:simpleType> <!-- =================================================================== --> <!-- ===== Boolean. Type ===== --> <!-- =================================================================== --> <xs:simpleType name="BooleanType"> <xs:annotation> <xs:documentation xml:lang="en"> <FDTNS:Definition>A list of two mutually exclusive Boolean values that express the only possible <!-<!-<!-<!--

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 9

Using BRFplus with a Third-Party Rules Engine

states of a Property </FDTNS:Definition> <FDTNS:PrimaryRepresentationTerm>Boolean </FDTNS:PrimaryRepresentationTerm> </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:maxLength value="1"/> <xs:enumeration value="X"/> <xs:enumeration value=""/> </xs:restriction> </xs:simpleType> <!-- =================================================================== --> <!-- ===== Text. Type ===== --> <!-- =================================================================== --> <xs:simpleType name="TextType"> <xs:annotation> <xs:documentation xml:lang="en"> <FDTNS:Definition>A character string (i.e. a finite set of characters) generally in the form of words of a language </FDTNS:Definition> <FDTNS:PrimaryRepresentationTerm>Text </FDTNS:PrimaryRepresentationTerm> </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:maxLength value="255"/> </xs:restriction> </xs:simpleType> <!-- =================================================================== --> <!-- ===== Amount. Type ===== --> <!-- =================================================================== --> <xs:complexType name="AmountType"> <xs:simpleContent> <xs:extension base="FDTNS:NumberType"> <xs:annotation> <xs:documentation xml:lang="en"> <FDTNS:Definition>A number of monetary units specified in a currency where the unit of the currency is explicit or implied. </FDTNS:Definition> <FDTNS:PrimaryRepresentationTerm>Amount </FDTNS:PrimaryRepresentationTerm> </xs:documentation> </xs:annotation> <xs:attribute name="Currency"> <xs:annotation> <xs:documentation xml:lang="en"> <FDTNS:Name>Amount. Currency. Identifier </FDTNS:Name> <FDTNS:Definition>The currency of the amount. </FDTNS:Definition> </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="5"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:extension> </xs:simpleContent> </xs:complexType> <!-- =================================================================== --> <!-- ===== Quantity. Type ===== --> <!-- =================================================================== -->

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 10

Using BRFplus with a Third-Party Rules Engine

<xs:complexType name="QuantityType"> <xs:simpleContent> <xs:extension base="FDTNS:NumberType"> <xs:annotation> <xs:documentation xml:lang="en"> <FDTNS:Definition>A counted number of non-monetary units possibly including fractions. </FDTNS:Definition> <FDTNS:PrimaryRepresentationTerm>Quantity </FDTNS:PrimaryRepresentationTerm> </xs:documentation> </xs:annotation> <xs:attribute name="Unit"> <xs:annotation> <xs:documentation xml:lang="en"> <FDTNS:Name>Quantity. Unit. Identifier </FDTNS:Name> <FDTNS:Definition>The unit of the quantity. </FDTNS:Definition> </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="3"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:extension> </xs:simpleContent> </xs:complexType> <!-- =================================================================== --> <!-- ===== Timepoint. Type ===== --> <!-- =================================================================== --> <xs:simpleType name="TimepointType"> <xs:annotation> <xs:documentation xml:lang="en"> <FDTNS:Definition>A particular point in the progression of time together with the relevant supplementary information </FDTNS:Definition> <FDTNS:PrimaryRepresentationTerm>Timepoint </FDTNS:PrimaryRepresentationTerm> </xs:documentation> </xs:annotation> <xs:restriction base="xs:dateTime"/> </xs:simpleType> <!-- =================================================================== --> <!-- ===== Begin of BRFplus BRMS Connector Runtime XML Schema Content = --> <!-- =================================================================== --> <xs:element name="FDT"> <xs:complexType> <xs:annotation> <xs:appinfo>FDT BRMS call elements </xs:appinfo> </xs:annotation> <xs:sequence> <xs:element name="INPUT"> <xs:complexType> <xs:annotation> <xs:appinfo>Input Elements </xs:appinfo> </xs:annotation> <xs:sequence> <xs:element name="HOURMAX" type="FDTNS:AmountType"> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo>

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 11

Using BRFplus with a Third-Party Rules Engine

<FDTNS:TechnicalName>HOURMAX </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>4858BEC7E2800D1BE10000000A4217B7 </FDTNS:ID> <FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>FALSE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Max Wage Per Hour </xs:documentation> </xs:annotation> </xs:element> <xs:element name="MATERNITY_WAGE_HOUR" type="FDTNS:AmountType"> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo> <FDTNS:TechnicalName>MATERNITY_WAGE_HOUR </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>4858BED9E2800D1BE10000000A4217B7 </FDTNS:ID> <FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>FALSE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Maternity Wage PerHr </xs:documentation> </xs:annotation> </xs:element> <xs:element name="NORMAL_WAGE_HOUR" type="FDTNS:AmountType"> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo> <FDTNS:TechnicalName>NORMAL_WAGE_HOUR </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>4858BEBBE2800D1BE10000000A4217B7 </FDTNS:ID> <FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>FALSE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Normal Wage Per Hour </xs:documentation> </xs:annotation> </xs:element> <xs:element name="WEEKMAX" type="FDTNS:AmountType"> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo> <FDTNS:TechnicalName>WEEKMAX </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>4858BECDE2800D1BE10000000A4217B7 </FDTNS:ID>

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 12

Using BRFplus with a Third-Party Rules Engine

<FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>FALSE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Week Max Wage </xs:documentation> </xs:annotation> </xs:element> <xs:element name="WORKMINUTES_DAY"> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo> <FDTNS:TechnicalName>WORKMINUTES_DAY </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>4858BE8AE2800D1BE10000000A4217B7 </FDTNS:ID> <FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>FALSE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Working Minutes per Day </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="FDTNS:NumberType"> <xs:fractionDigits value="10 "/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="ABSENCEMINUTES_DAY"> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo> <FDTNS:TechnicalName>ABSENCEMINUTES_DAY </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>4858BED3E2800D1BE10000000A4217B7 </FDTNS:ID> <FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>FALSE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Absence minutes per day </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="FDTNS:NumberType"> <xs:fractionDigits value="10 "/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="WORKMINUTES_WEEK"> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo>

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 13

Using BRFplus with a Third-Party Rules Engine

<FDTNS:TechnicalName>WORKMINUTES_WEEK </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>4860547F8ABB0D11E10000000A4217B7 </FDTNS:ID> <FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>FALSE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Working Minutes per Week </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="FDTNS:NumberType"> <xs:fractionDigits value="10 "/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="MINUTE_HOUR"> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo> <FDTNS:TechnicalName>MINUTE_HOUR </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>4860F20193660D18E10000000A4217B7 </FDTNS:ID> <FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>FALSE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Working Minutes per Hour </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="FDTNS:NumberType"> <xs:fractionDigits value="10 "/> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="OUTPUT"> <xs:complexType> <xs:annotation> <xs:appinfo>Output Elements </xs:appinfo> </xs:annotation> <xs:sequence> <xs:element name="SPLITS"> <xs:complexType> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo> <FDTNS:TechnicalName>SPLITS </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>485F30435FD20D15E10000000A4217B7

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 14

Using BRFplus with a Third-Party Rules Engine

employee

</FDTNS:ID> <FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>TRUE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Payment Splits </xs:documentation> </xs:annotation> <xs:sequence> <xs:element name="FRB_DAY" type="FDTNS:AmountType"> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo> <FDTNS:TechnicalName>FRB_DAY </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>485F2F945FD20D15E10000000A4217B7 </FDTNS:ID> <FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>TRUE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Reduced maternity wage paid out to the </xs:documentation> </xs:annotation> </xs:element> <xs:element name="FRN_DAY" type="FDTNS:AmountType"> <xs:annotation> <xs:appinfo> <FDTNS:objectInfo> <FDTNS:TechnicalName>FRN_DAY </FDTNS:TechnicalName> <FDTNS:Key> <FDTNS:ID>485F301B5FD20D15E10000000A4217B7 </FDTNS:ID> <FDTNS:VersionID>000001 </FDTNS:VersionID> </FDTNS:Key> <FDTNS:isChangeable>TRUE </FDTNS:isChangeable> </FDTNS:objectInfo> </xs:appinfo> <xs:documentation xml:lang="EN">Split Reduced Normal wage paid out to the

employer

</xs:documentation> </xs:annotation> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="BRMSConnectorVersion" type="xs:string" fixed="1.00"/> </xs:complexType> <!-- =================================================================== --> <!-- ===== End of BRFplus BRMS Connector Runtime XML Schema Content = -->

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 15

Using BRFplus with a Third-Party Rules Engine

<!-- =================================================================== --> </xs:element> </xs:schema>

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 16

Using BRFplus with a Third-Party Rules Engine

Appendix 2 Given below is a sample request XML document.


<?xml version="1.0" encoding="utf-8"?> <FDTNS:FDT BRMSConnectorVersion="1.00" xmlns:FDTNS="http://sap.com/fdt/transport"> <FDTNS:INPUT> <FDTNS:HOURMAX Currency="EUR">9230.0 </FDTNS:HOURMAX> <FDTNS:MATERNITY_WAGE_HOUR Currency="EUR">1519.0 </FDTNS:MATERNITY_WAGE_HOUR> <FDTNS:NORMAL_WAGE_HOUR Currency="EUR">1899.0 </FDTNS:NORMAL_WAGE_HOUR> <FDTNS:WEEKMAX Currency="EUR">341500.0 </FDTNS:WEEKMAX> <FDTNS:WORKMINUTES_DAY>480.0 </FDTNS:WORKMINUTES_DAY> <FDTNS:ABSENCEMINUTES_DAY>480.0 </FDTNS:ABSENCEMINUTES_DAY> <FDTNS:WORKMINUTES_WEEK>480.0 </FDTNS:WORKMINUTES_WEEK> <FDTNS:MINUTE_HOUR>60.0 </FDTNS:MINUTE_HOUR> </FDTNS:INPUT> <FDTNS:OUTPUT> <FDTNS:SPLITS> <FDTNS:FRB_DAY Currency="">0.0 </FDTNS:FRB_DAY> <FDTNS:FRN_DAY Currency="">0.0 </FDTNS:FRN_DAY> </FDTNS:SPLITS> </FDTNS:OUTPUT> </FDTNS:FDT>

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 17

Using BRFplus with a Third-Party Rules Engine

Appendix 3 Given below is a sample response XML document.


<?xml version="1.0" encoding="UTF-8"?> <FDTNS:FDT xmlns:FDTNS="http://sap.com/fdt/transport" BRMSConnectorVersion="1.00"> <FDTNS:INPUT> <FDTNS:HOURMAX Currency="EUR">9230.0 </FDTNS:HOURMAX> <FDTNS:MATERNITY_WAGE_HOUR Currency="EUR">1519.0 </FDTNS:MATERNITY_WAGE_HOUR> <FDTNS:NORMAL_WAGE_HOUR Currency="EUR">1899.0 </FDTNS:NORMAL_WAGE_HOUR> <FDTNS:WEEKMAX Currency="EUR">341500.0 </FDTNS:WEEKMAX> <FDTNS:WORKMINUTES_DAY>480.0 </FDTNS:WORKMINUTES_DAY> <FDTNS:ABSENCEMINUTES_DAY>480.0 </FDTNS:ABSENCEMINUTES_DAY> <FDTNS:WORKMINUTES_WEEK>480.0 </FDTNS:WORKMINUTES_WEEK> <FDTNS:MINUTE_HOUR>60.0 </FDTNS:MINUTE_HOUR> </FDTNS:INPUT> <FDTNS:OUTPUT> <FDTNS:SPLITS> <FDTNS:FRB_DAY Currency="EUR">12152.0 </FDTNS:FRB_DAY> <FDTNS:FRN_DAY Currency="EUR">3040.0 </FDTNS:FRN_DAY> </FDTNS:SPLITS> </FDTNS:OUTPUT> </FDTNS:FDT>

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 18

Using BRFplus with a Third-Party Rules Engine

Appendix 4 Given below is a sample code for extracting relevant JCo parameters. The following code snippets illustrate how to retrieve the relevant JCo parameters passed from BRFplus.
private void extractJCoParameters(Function function) { ParameterList importParams = function.getImportParameterList(); // Fill up execution properties Map<String, String> executionProperties = new HashMap<String, String>(); Table paramsMap = importParams.getTable("ITS_CALL_PARAM"); if (paramsMap == null) { throw new J2EEAbapException(INVALID_INPUT, "Execeution params"); } else { Structure paramEntry = null; paramsMap.firstRow(); for (int i = 0; i < paramsMap.getNumRows(); i++) { String paramKey = paramsMap.getString("NAME"); String paramValue = paramsMap.getString("VALUE"); // Store key and value tcLogger.logT(Severity.ALL, paramKey + " = " + paramValue); paramsMap.nextRow(); } } byte[] xmlBytes = importParams.getByteArray("IV_INPUT_XML"); if (xmlBytes != null) { Document doc = null; try { doc = getDocumentBuilder().parse( new InputSource(new ByteArrayInputStream(xmlBytes))); } catch (SAXException e) { //handle exception } catch (IOException e) { //handle exception } } else { throw new J2EEAbapException(INVALID_INPUT, "Context XML"); }

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 19

Using BRFplus with a Third-Party Rules Engine

Related Content
BRFplus The Very Basics Formula Functions Carsten Ziegler, About Business Rules: https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/9713 Carsten Ziegler, BRFplus a Business Rule Engine written in ABAP, https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/8889 Carsten Ziegler, Important Information for Using BRFplus https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/11632 Rajagopalan Narayanan, Business Rules and Software Requirements, https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40aae118-42c2-2a10-fcaffdd9d30bcb1a Rajagopalan Narayanan, Seven Tips for Your First Business Rules Project, https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/201a9e3d-3ec2-2a10-85b2ce56d276dd7a Rajagopalan Narayanan, Real World Return of Investment Scenarios with Business Rules Management, https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b050905e-3cc22a10-979a-81a57a787f56 Rajagopalan Narayanan, Five Reasons to Build Agile Systems Using Business Rules Management Functionality, https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/504486eb-43c2-2a10-f5a7e84ef3fd45be Rajagopalan Narayanan, How Business Rules Management Functionality Helps Tariff Plans Management in Transportation and Shipping, https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40a9cf69-40c2-2a10-8a8b969fb311dd31 Rajagopalan Narayanan, Getting Started with Business Rules Management, https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70c669d8-3ac2-2a10-0e96c7c3786168f0

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 20

Using BRFplus with a Third-Party Rules Engine

Copyright
2008 SAP AG. All rights reserved. No part of this publication 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, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, System i, System i5, System p, System p5, System x, System z, System z9, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, POWER5+, OpenPower and PowerPC are trademarks or registered trademarks of IBM Corporation. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third-party web pages nor provide any warranty whatsoever relating third-party web pages. Any software coding and/or code lines/strings (Code) included in this documentation are only examples and are not intended to be used in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.

SAP DEVELOPER NETWORK | sdn.sap.com 2008 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com 21

Das könnte Ihnen auch gefallen