• No results found

AP Integration with BRFplus VERSION V APRIL SAP AG

N/A
N/A
Protected

Academic year: 2021

Share "AP Integration with BRFplus VERSION V APRIL SAP AG"

Copied!
21
0
0

Loading.... (view fulltext now)

Full text

(1)

AP 7.00

Integration

with

BRFplus

(2)

2/20

Table of Contents

1. Introduction ... 3

1.1 Time based prices ... 3

1.2 Usage of BRFplus ... 3

1.3 About this document ... 3

1.4 Target group ... 3

2. Solution via external data source ... 4

2.1 Timestamps ... 4 2.2 Set up of BRFplus ... 4 2.3 Condition type ... 7 2.4 Pricing procedure ... 7 2.5 BAdI PRC_DATA_SOURCES ... 8 2.6 Result ... 10

3. Solution with passing an additional attribute ... 12

3.1 About this solution approach ... 12

3.2 Set up of the customizing and master data ... 12

3.3 Set up of BRFplus ... 15

3.4 BAdI CRM_COND_COM_BADI ... 18

(3)

3/20

1. Introduction

1.1 Time based prices

You are using the IPC Pricing Engine (for example in CRM for Sales Orders) and you want to support business cases for which time based prices are required. Examples:

 Happy Hour: The price of a product is 50 EUR, but between 14:00 and 16:00 it is only the half price (25 EUR)

 Time based rates, e.g. mobile phone tariffs: o 0:00 - 7:00: 30 cents/min

o 7:00 - 18:00: 50 cents/min o 18:00 - 0:00: 40 cents/min

Unfortunately, these scenarios are not supported within the IPC Pricing Engine. The reason is that the condition technique (which is used by the IPC) allows only selecting condition records by day, but no by time.

1.2 Usage of BRFplus

For these special business requirements, you can use SAP BRFplus as an alternative to the condition technique. The Business Rule Framework plus (BRFplus) is an ABAP based rule engine which allows to create business rules. BRFplus offers an API (application programming interface) that allows to call these business rules from external (e.g. local ABAP call or web service). So the IPC Pricing Engine can use these business rules.

For more information regarding BRFplus, please refer to the official documentation, e.g. BRFplus Knowledge Center in SAP Developer Network (SDN):

https://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/90754865-f283-2b10-6d9f-b10f3c28c3a0.

We would like to point out that BRFplus should not be a replacement for the condition technique but can be an enhancement and alternative for special business requirements as the in two examples above.

1.3 About this document

The next chapters will show you how you can realize an integration between the IPC Pricing Engine and BRFplus. These are two different solution approaches and we will use the examples of chapter 1.1 (Happy Hour and Time based rates).

1.4 Target group

(4)

4/20

2. Solution via external data source

In this first solution approach, we want to implement the Happy Hour example via external data source.

2.1 Timestamps

As the condition technique supports selecting condition records only by date, the CRM passes to the IPC the timestamps as dates.

So if you want to uses real timestamps (date with time), then you have to create them on your own. You can create these timestamps by using the CRM BAdI’s like CRM_COND_COM_BADI. Or you can create the timestamps in the BAdI PRC_DATA_SOURCES in method DETERMINE_ATTRIBUTES. Here you can use for example the current system time with sy-uzeit (HH:MM:SS).

2.2 Set up of BRFplus

1) Open the BRFplus workbench with the transaction brfplus.

2) Create an application, e.g. ZBY_APPL_HAPPY_HOUR. An application is the top-level container for all kinds of different BRFplus objects. All BRFplus objects are assigned to an application.

3) Add the required elements that are needed by the business rule. In our case it is:

Import:

 Condition type (DDIC Element: PRCT_COND_TYPE)  Product Guid (DDIC Element: COMT_PRODUCT_GUID)  Time (DDIC Element: SYUZEIT)

Export:

 Amount (BRFplus data type)

You need to define only the three import parameters. The export parameter Amount is already available as BRFplus data type.

(5)

5/20 This should look like this:

(6)

6/20

5) Now we need to define our business rules. For a certain product the price should be 50 EUR normally, but between 14:00 and 16:00 it should be only the half price (25 EUR). Here we use a decision tree to realize this business rules, e.g. ZBYA_DEC_TREE_HAPPY_HOUR (see picture below). After done this, please assign the decision tree to the function

ZBYA_FUNC_TREE_HAPPY_HOUR.

(7)

7/20

For testing purpose, you can test your business rule by running a simulation of the function ZBYA_FUNC_TREE_HAPPY_HOUR within the BRFplus workbench.

2.3 Condition type

Now you need to create condition type with an external data source. This external data source will call our BRFplus function.

Go to SPRO Customer Relationship Management Basic Functions Pricing Create Condition Types.

In the screenshot below, an example is shown. The condition type ZHPY (Happy Hour) is a price (condition class "B - Price").

Further, it uses the external data source "X - Customer Reserve 1". This is a filter for our BAdI

implementation that will call the BRFplus function. For more details regarding external data sources, please refer to the SAP Note 1328953.

2.4 Pricing procedure

Create a Pricing Procedure and add the condition type ZHPY.

Go to SPRO Customer Relationship Management Basic Functions Pricing Create Pricing Procedure.

(8)

8/20

2.5 BAdI PRC_DATA_SOURCES

Now you need to create a proper implementation for the BAdI PRC_DATA_SOURCES. The BAdI PRC_DATA_SOURCES is used to retrieve a condition rate from another data source than the condition technique. For more details regarding external data sources, please refer to the SAP Note 1328953. Go to transaction SE18 and create a BAdI implementation for PRC_DATA_SOURCES:

Here we create the BAdI implementation ZBRF_PRC_DATA_SOURCE. You can see that this BAdI implementation has the filter value 'X'. As the condition type ZHPY is using the external data source "X - Customer Reserve 1", it will call this BAdI implementation.

(9)

9/20

You will see that the BRFplus function ZBYA_FUNC_TREE_HAPPY_HOUR is called via an ID instead of its name. In general, a BRFplus function can be called only by its ID. You can find this ID in the "General" area of the function definition, see screenshot below.

method IF_EX_PRC_DATA_SOURCES~GET_DATA.

DATA: lo_factory TYPE REF TO IF_FDT_FACTORY, lo_function TYPE REF TO if_fdt_function, lo_context TYPE REF TO if_fdt_context, lo_result TYPE REF TO if_fdt_result, lx_fdt TYPE REF TO cx_fdt,

ls_cond_recs type prct_cond_recs,

ls_price TYPE if_fdt_types=>element_amount, ls_attr_name_value type prct_attr_name_value, ls_time type syuzeit.

FIELD-SYMBOLS: <ls_cond_list> type prct_cond_list,

<ls_message> TYPE if_fdt_types=>s_message.

* get data from name-value-table

read table is_item_wrk-item_attributes with key attr_name = 'PRODUCT'

into ls_attr_name_value. check: sy-subrc = 0.

* init BRFplus (function ZBYA_FUNC_HAPPY_HOUR has ID B7F17C4D0355592AE10000000A4286AD)

lo_factory = cl_fdt_factory=>if_fdt_factory~get_instance( ).

lo_function = lo_factory->get_function( iv_id = 'B7F17C4D0355592AE10000000A4286AD' ).

* get system time

ls_time = sy-uzeit.

loop at it_cond_list assigning <ls_cond_list>. move-corresponding <ls_cond_list> to ls_cond_recs.

TRY.

* call BRFplus function ZBYA_FUNC_HAPPY_HOUR

lo_context = lo_function->get_process_context( ).

lo_context->set_value( iv_name = 'COND_TYPE' ia_value = ls_cond_recs-kschl ). lo_context->set_value( iv_name = 'TIME' ia_value = ls_time ).

lo_context->set_value( iv_name = 'PRODUCT' ia_value = ls_attr_name_value- attr_value ).

lo_function->process( EXPORTING io_context = lo_context IMPORTING eo_result = lo_result ). lo_result->get_value( IMPORTING ea_value = ls_price ). CATCH cx_fdt INTO lx_fdt.

LOOP AT lx_fdt->mt_message ASSIGNING <ls_message>. WRITE / <ls_message>-text.

(10)

10/20 ENDTRY.

* assign returned price and currency to condition record structure

ls_cond_recs-kbetr = ls_price-number. ls_cond_recs-konwa = ls_price-currency. …

2.6 Result

Now we can test our BRFplus integration. For this purpose, we create a pricing document (e.g. CRM Sales Order) which is using our pricing procedure. Then we add the product for which we created the BRFplus business rule for the happy hour price.

In the screenshot below, you can see the debugger and that the passed time is 9:42. In that case the normal price 50 EUR is returned by BRFplus.

(11)

11/20 In that case the happy hour price is returned: 25 EUR.

(12)

12/20

3. Solution with passing an additional attribute

3.1 About this solution approach

This chapter wants to show you another solution approach as in the previous chapter. The main idea here is that BRFplus pass an attribute value to the IPC depending on the time. This attribute value is then used for the condition determination by the condition technique.

For this solution approach, we want to focus on the other example regarding mobile phone tariffs:

Time Costs Tariff

0:00 - 7:00 30 cents/min Tariff-1

7:00 - 18:00 50 cents/min Tariff-2

18:00 - 0:00 40 cents/min Tariff-3

The idea is here that BRFplus is returning the attribute TARIFF with the value 1, 2 or 3 (depending on the time). This attribute TARIFF with its value is passed to the condition technique.

The corresponding conditions records could look like this:

KSCHL SALES ORG TARIFF KBETR

ZTAR SORG1 … 1 30 ..

ZTAR SORG1 … 2 50 …

ZTAR SORG1 … 3 40 …

For the integration between BRFplus and the calling application (e.g. CRM Order) you can use a BAdI, e.g. CRM_COND_COM_BADI.

3.2 Set up of the customizing and master data

(13)

13/20

2) Add a new field "TARIFF" to the field catalogue with the data type TARIFF:

Go to the field catalog: SPRO Customer Relationship Management Basic Functions Pricing Maintain Field Catalog.

3) Create a new condition table with the standard key fields (e.g. sales organization) and add the field TARIFF:

Go to SPRO Customer Relationship Management Basic Functions Pricing Create Condition Tables.

4) Create an Access Sequence (e.g. 1MOT) with an Access using this condition table:

(14)

14/20

5) Create a condition type (e.g. 1MOT) and assign the Access Sequence to it:

Go to SPRO  Customer Relationship Management Basic Functions  Pricing Create Condition Types.

6) Create a Pricing Procedure (e.g. ZMOBT) and add the condition type to it:

Go to SPRO  Customer Relationship Management Basic Functions  Pricing  Create Pricing Procedure.

7) Before adding the condition records, we need to create a BAdI implementation for the new data element TARIFF. Here we need an implementation for the BAdI /SAPCND/ROLLNAME. This is BAdI for Field Checks, Default Values, Input Help, etc:

Go to SPRO  Customer Relationship Management  Master DataConditions and Condition TechniqueCondition Technique: BasicsBAdI for Field Checks, Default Values, Input Help, and so on.

Create an BAdI implementation for the data element TARIFF. Further add to methods FIELD_CHECK, DEFAULT_VALUE_SUGGESTION and ATTRIBUTE_CONVERSION this minimum implementation:

* by default everything was ok

(15)

15/20

8) Now we can add the condition records. Call transaction /SAPCND/GCM and add three condition records for our condition type with

 Tariff 1: 30 cents /min

 Tariff 2: 50 cents /min

 Tariff 3: 40 cents /min

3.3 Set up of BRFplus

1) Open the BRFplus workbench with the transaction brfplus.

2) Create an application, e.g. ZAPPL_MOBILE_TARIFF. An application is the top-level container for all kinds of different BRFplus objects. All BRFplus objects are assigned to an application

3) Add the required elements needed by the business rule. In our case it is:

TIME (DDIC Element: SYUZEIT )

TARIFF (DDIC Element: TARIFF)

4) Create the function ZBYA_FUNC_MOBILE_TARIFF:

 Mode: Functional Mode

 Import parameter: Element TIME

(16)

16/20

5) Create the decision table ZBYA_DEC_TAB_MOBILE_TARIFF and add the rules as shown below.

(17)

17/20 At the end, you should have this setup in BRFplus:

For testing purpose, you can test your business rule by running a simulation of the function ZBYA_FUNC_MOBILE_TARIFF within the BRFplus workbench.

(18)

18/20

3.4 BAdI CRM_COND_COM_BADI

Until now we set up the pricing customizing as well as the condition records. Further we created in BRFplus our business rule regarding the mobile tariff.

To bring this together we will create a implementation for BAdI CRM_COND_COM_BADI. This BAdI implementation will call our BRFplus function which will return tariff with value "1", "2" or "3" dependent on the time. This value will be added to the item attribute TARIFF that is passed to the IPC Pricing Engine.

Add the following implementation to the method ITEM_NAME_VALUE:

method IF_EX_CRM_COND_COM_BADI~ITEM_NAME_VALUE. DATA: ls_iten_name_value TYPE PRCT_ATTR_NAME_VALUE, ls_iten_name_value_new TYPE PRCT_ATTR_NAME_VALUE, ls_time type syuzeit,

lo_factory TYPE REF TO IF_FDT_FACTORY, lo_function TYPE REF TO if_fdt_function, lo_context TYPE REF TO if_fdt_context, lo_result TYPE REF TO if_fdt_result, lx_fdt TYPE REF TO cx_fdt,

ls_tariff TYPE TARIFF.

FIELD-SYMBOLS: <ls_message> TYPE if_fdt_types=>s_message.

* Get item attribute TARIFF

READ TABLE CT_ITEM_NAME_VALUE INTO ls_iten_name_value WITH KEY ATTR_NAME = 'TARIF F'.

check: sy-subrc = 0.

ls_iten_name_value_new-ATTR_NAME = 'TARIFF'.

ls_iten_name_value_new-SEQ_NUMBER = ls_iten_name_value-SEQ_NUMBER.

* get system time

(19)

19/20

* Call BRFplus (function ZBYA_FUNC_MOBILE_TARIFF has ID 815BB24D7BE07167E10000000A4 286AF)

lo_factory = cl_fdt_factory=>if_fdt_factory~get_instance( ). lo_function =

lo_factory->get_function( iv_id = '815BB24D7BE07167E10000000A4286AF' ). TRY.

lo_context = lo_function->get_process_context( ).

lo_context->set_value( iv_name = 'TIME' ia_value = ls_time ). lo_function->process( EXPORTING io_context = lo_context IMPORTING eo_result = lo_result ). lo_result->get_value( IMPORTING ea_value = ls_tariff ). CATCH cx_fdt INTO lx_fdt.

LOOP AT lx_fdt->mt_message ASSIGNING <ls_message>. WRITE / <ls_message>-text.

ENDLOOP. ENDTRY.

* Delete old attribute TARIFF and add new one with value from BRFplus

DELETE TABLE ct_item_name_value FROM ls_iten_name_value. ls_iten_name_value_new-ATTR_VALUE = ls_tariff.

INSERT ls_iten_name_value_new INTO TABLE ct_item_name_value.

endmethod.

(20)

20/20

3.5 Result

(21)

Enter Title Here: Do not exceed space provided - Title automatically appears in page header

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2011 SAP AG

Copyright

© Copyright 2011 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, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.

Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

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.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, 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 other countries.

Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.

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.

References

Related documents

GIS officer may require the political subdivision to follow the state GIS data standards and the statewide data integration plan when the political subdivision makes use of the GIS

A basic valve symbol is e symbol is compo composed of sed of one or one or more more envelopes with lines inside the envelope to represent flow envelopes with

If a team wins and accepts a state berth at a qualifier, the players are frozen to their roster and may not be picked up by another team playing for a state tournament berth.. If

After analyzing the findings, the study recommend the consistency trainings/capacity building so that to help managers/enterprise owners to understand the necessity

TO: Long Term Care Facilities with Real Estate Tax Rates RE: 2001 REAL ESTATE TAX COST DOCUMENTATION In order to set the real estate tax portion of the capital rate, it

Though a saline soil can form as the result of excessive irrigation in agricultural areas, and runoff from a saline surface can increase the salt supply to the river

F6150 Internal Options Ethernet or USB Communication Logic Inputs Voltage &amp; Current Relay F6ControlPanel Communications Relay Sources Logic Outputs (Optional) under Test..

LawAccess NSW is a free government service that provides legal information, advice and referrals for people who have a legal problem in NSW. You can also get plain language