remote pricing stateless api - sap crm by gert-jan stolmeijer...856863 sap nco release and support...
Post on 23-Jan-2021
4 Views
Preview:
TRANSCRIPT
AP 7.00
Stateless Pricing
Remote API
VERSION V1.00 – 25 FEBRUARY 2013 - © SAP AG 2013
Version 1.00 – 25 FEB 2013 – © SAP AG 2023 –Note 1802168
2
CHANGE LOG
Version Date Modification
1.00 25-FEB-2013 First release
© Copyright 2013 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
®, NT
®, EXCEL
®, Word
®,
PowerPoint®
and SQL Server®
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,
z/OS, AFP, Intelligent Miner, WebSphere®, Netfinity
®,
Tivoli®, Informix and Informix
® Dynamic Server
TM
are
trademarks of IBM Corporation in USA 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®, the Citrix logo, ICA
®, Program
Neighborhood®, MetaFrame
®, WinFrame
®,
VideoFrame®, MultiWin
® and other Citrix product
names referenced herein are trademarks of Citrix
Systems, Inc.
HTML, DHTML, XML, XHTML 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.
MarketSet and Enterprise Buyer are jointly owned
trademarks of SAP AG and Commerce One.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, 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.
PRICING USEREXIT MANUAL
3
PRODUCT INNOVATION LIFECYCLE
B
PRODUCT INNOVATION LIFECYCLE
A
CONTENTS
Change Log ........................................................................................................................ 2
Contents ............................................................................................................................. 3
1 Overview ......................................................................................................................... 5
1.1 Introduction ............................................................................................................................. 5
1.2 Prerequisites ........................................................................................................................... 5
1.3 Functional limitations .............................................................................................................. 5
1.4 Further Information ................................................................................................................. 5
1.5 SAP Support for Stateless Pricing API Usage ......................................................................... 5
2 Development .................................................................................................................. 6
2.1 Description of the API ............................................................................................................. 6
2.2 Example how to call Stateless Pricing API ............................................................................ 12
A FAQ/TROUBLE SHOOTING ......................................................................................... 15
STATELESS PRICING REMOTE API
PRODUCT INNOVATION LIFECYCLE
B
PRODUCT INNOVATION LIFECYCLE
A
5
1 OVERVIEW
1.1 Introduction
This document is about the new Stateless Pricing Remote API of the IPC Pricing Engine that is available from
Support Package 29 of the Software component SAP_AP.
The high level use case is to deliver price information about one or several items to a non-SAP caller using SAP
master data and customizing settings. For example this can be used within the context of a Third party web shop
catalog. The caller requesting the price(s) needs to provide the pricing context to the pricing engine, i.e. no
customizing determination is done. As the name of the API reflects, the pricing engine will not retain the state of
the pricing document once remote call has been processed. Hence, this API for performance reasons may not be
suitable for highly interactive scenarios such as a shopping basket.
The API can be easily invoked using RFC protocol (for example using SAP Java Connector from Java
environment).
1.2 Prerequisites
SAP_AP 7.0 in the system must be based on support package level 29 or above.
1.3 Functional limitations
Tax determination via the TTE (Tax Transaction Engine) is currently not supported
Pricing results are not persisted at engine side
Loading of existing pricing document and its modification is not supported
1.4 Further Information
There are several additional information available elaborating different topics more detailed.
Source Description
Note 844817 Technical Information
Note 844816 Information for Upgrade
Note 867428 Adapt buffer refresh times
SAP Help SAP Virtual Machine Container
http://help.sap.com/saphelp_nwpi711/helpdata/en/a9/26ae3c95164695accbf2483a14281e/frameset.
htm
1077727 SAP JCo 3.0 release and support strategy
1672418 Downloading the SAP JCO
636912 Frequent installation problems with SAP Java Connector
856863 SAP NCo Release and Support Strategy (.Net Connector)
1.5 SAP Support for Stateless Pricing API Usage
Support issues with the Stateless Pricing API are not covered by a normal SAP support contract. This document
only helps to implement and should not be regarded as part of the standard delivery. In case of troubles SAP
support may request you to use the (remote) consulting service.
Version 1.00 – 25 FEB 2013 – © SAP AG 2023 –Note 1802168
6
2 DEVELOPMENT
2.1 Description of the API
With Support Package SP29 of SAP_AP onwards, the new Remote Function Call (RFC)
SPE_CALCULATE_PRICE is available. This is Java Function Module that can be called via SAP Java
Connector (SAP JCo). It allows executing pricing (price determination and price calculation) with only one call.
Below you can see the signature of the Java module. The documentation of the ABAP structures and fields are
available in your backend system where the RFC SPE_CALCULATE_PRICE is located.
In the next chapter you can see an example how to call it for better understanding.
FUNCTION SPE_CALCULATE_PRICE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IS_HEADER_INPUT) TYPE PRIT_HEADER_INPUT
*" VALUE(IT_ITEM_ADDNL_INPUT) TYPE PRIT_ITEM_ADDNL_INPUT_T
*" OPTIONAL
*" EXPORTING
*" VALUE(ES_HEADER_RESULT) TYPE PRIT_HEAD_RET
*" VALUE(ET_ITEM_CALC_ADDNL_RESULT) TYPE PRIT_ITEM_ADDNL_RESULT_T
*" VALUE(ET_TRACE) TYPE PRIT_ITEM_TRACE_T
*" TABLES
*" IT_ITEM_MAIN_INPUT TYPE PRIT_ITEM_MAIN_INPUT_T
*" IT_ITEM_ATTRIB_INPUT TYPE PRIT_ITEM_ATTRIBUTE_T
*" IT_ITEM_TIMESTMP_INPUT TYPE PRIT_ITEM_TIMESTAMP_T
*" IT_MANUAL_COND_INPUT TYPE PRIT_COND_INPUT_T OPTIONAL
*" ET_ITEM_CALC_MAIN_RESLT TYPE PRIT_ITEM_MAIN_RESULT_T OPTIONAL
*" ET_MESSAGES TYPE PRIT_MESSAGE_T OPTIONAL
*"----------------------------------------------------------------------
ENDFUNCTION.
Technical input parameters are listed under IMPORTING and TABLES parameter sections. Similarly output
parameters also listed under EXPORTING and TABLES parameter sections. Below are the details of each
parameter. You will later see the individual component description too.
SPE_CALCULATE_PRICE
PARAMETER NAME PARAMETER
TYPE
MANDATORY RFC
PRAMETER
TYPE
DESCRIPTIO
N
IS_HEADER_INPUT INPUT YES IMPORTING Pricing header
input data
IT_ITEM_MAIN_INPUT INPUT YES TABLES Pricing items
input data
IT_ITEM_ADDNL_INPUT INPUT NO IMPORTING Pricing items
additional input
data
STATELESS PRICING REMOTE API
PRODUCT INNOVATION LIFECYCLE
B
PRODUCT INNOVATION LIFECYCLE
A
7
IT_ITEM_ATTRIB_INPUT INPUT YES TABLES Pricing
dynamic
attribute set
which is
required for
condition
finding and
user exit
executions. It is
based on
pricing
procedure
customization.
IT_ITEM_TIMESTMP_INP
UT
INPUT YES TABLES Pricing
timestamps
which is
required for
condition
finding
IT_MANUAL_COND_INPU
T
INPUT NO TABLES Manual
conditions to be
added
ES_HEADER_RESULT OUTPUT NO EXPORTING Pricing header
level result
(e.g. net value)
ET_ITEM_CALC_MAIN_R
ESLT
OUTPUT NO TABLES Pricing items
level main
results (e.g. net
value, net price,
gross value
etc.)
ET_ITEM_CALC_ADDNL_
RESLT
OUTPUT NO EXPORTING Pricing items
level additional
results (e.g.
subtotals,
condition
function etc.)
ET_TRACE OUTPUT NO EXPORTING Price condition
access trace in
xml format
ET_MESSAGES OUTPUT NO TABLES Messages (e.g.
error, warning
etc.) from
pricing
Below you can see their important components. Here focus is mainly on INPUT parameters. You can set them
with appropriate values as per your scenario.
Version 1.00 – 25 FEB 2013 – © SAP AG 2023 –Note 1802168
8
IS_HEADER_INPUT
IS_HEADER_INPUT is used for supplying header level input parameters those are required for price
calculation
Component Name Mandatory Purpose
DOCUMENT_ID Yes Header identifier
APPLICATION Yes Condition technique application name
which corresponds to pricing procedure set
up (e.g. CRM)
PRC_PROCEDURE_NAME Yes Pricing procedure name
DOCUMENT_CURRENCY_UNIT Yes Document currency unit
LOCAL_CURRENCY_UNIT No Local currency unit. If it is not then it will
be defaulted with document currency
SIMULATION_MODE No To do condition finding in simulation mode
where conditions are released for simulation
ATTRIBUTES No Document level dynamic attributes. It
depends on pricing procedure customization
(e.g. header fields used in relevant access
sequences)
PERFORM_TRACE No For activating price condition access trace
IT_ITEM_MAIN_INPUT
IT_ITEM_MAIN_INPUT is used for supplying item level attributes those are needed for price calculation
Component Name Mandatory Purpose
ITEM_ID Yes Item identifier
ITEM_ID_EXT No External human readable identifier
PARENT_ITEM_ID No Parent item identifier
PRODUCT_ID Yes This is mandatory if the system is based on
CRM or SRM data model. Basically product
data is present in comm_product table. If this is
used then you don’t have to fill
PRODUCT_ERP component
PRODUCT_ERP Yes This is mandatory if the system is based on
ERP data model. Basically product information
is present in MARA table. If this is filled then
you don’t have to use PRODUCT_ID
component
EXCH_RATE_TYPE No Exchange rate type used for exchange rate
determination. If it is not set then exchange rate
type ‘M’ will be used.
EXCH_RATE_DATE No Date based on which exchange rate for currency
conversion need to be determined. If it is not
set then current date will be used
EXCH_RATE_EXTERNAL No Externally supplied exchange rate
QUANTITY Yes Item quantity
QUANTITY_UNIT Yes Item quantity unit
STATELESS PRICING REMOTE API
PRODUCT INNOVATION LIFECYCLE
B
PRODUCT INNOVATION LIFECYCLE
A
9
NUMERATOR No Needed if item quantity unit is different from
base quantity unit. This is numerator factor
from item quantity unit to base quantity unit
DENOMINATOR No Needed if item quantity unit is different from
base quantity unit. This is denominator factor
from item quantity unit to base quantity unit
EXPONENT No Needed if item quantity unit is different from
base quantity unit
GROSS_WEIGHT No Required if the pricing procedure contains gross
weight based condition type. In such cases
gross weight amount corresponds to item
quantity need to be set over here
NET_WEIGHT No Required if the pricing procedure contains net
weight based condition type. In such cases net
weight amount corresponds to item quantity
need to be set over here
WEIGHT_UNIT No Weight unit. Required if the pricing procedure
contains weight based condition type
VOLUME No Required if the pricing procedure contains
volume based condition type. In such cases
volume amount corresponds to item quantity
need to be set over here
VOLUME_UNIT No Volume unit. Required if the pricing procedure
contains volume based condition type
POINTS No Required if the pricing procedure contains
points based condition type.
POINTS_UNIT No Point unit. Required if the pricing procedure
contains point based condition type
DATE_FROM_BASE No Start date for deriving time factors
(days/weeks/months/years). This is required if
pricing procedure contains time based condition
types. Basically for period based calculation. If
you want to set days per month, days per year,
holidays for influencing the period calculation
you can set it using importing parameter
IT_ITEM_ADDNL_INPUT
DATE_TO_BASE No End date for deriving time factors
(days/weeks/months/years). This is required if
pricing procedure contains time based condition
types. Basically for period based calculation
NUM_OF_DAYS_BASE No Number of days. If you are supplying
DATE_FROM_BASE and DATE_TO_BASE
you don’t have to supply this. System will
calculate number of days. If you supply it,
system will use passed value for calculation
NUM_OF_WEEKS_BASE No Number of weeks. If you are supplying
DATE_FROM_BASE and DATE_TO_BASE
you don’t have to supply this. System will
calculate number of weeks. If you supply it,
system will use passed value for calculation
NUM_OF_MONTHS_BASE No Number of months. If you are supplying
DATE_FROM_BASE and DATE_TO_BASE
Version 1.00 – 25 FEB 2013 – © SAP AG 2023 –Note 1802168
10
you don’t have to supply this. System will
calculate number of months. If you supply it,
system will use passed value for calculation
NUM_OF_YEARS_BASE No Number of years. If you are supplying
DATE_FROM_BASE and DATE_TO_BASE
you don’t have to supply this. System will
calculate number of years. If you supply it,
system will use passed value for calculation
DATE_FROM_SCALE No Start date for deriving time factors
(days/weeks/months/years) for time based scale
base calculation. This is required if pricing
procedure contains condition types with time
based scale base type. If you want to set days
per month, days per year, holidays for
influencing the period calculation you can set it
using importing parameter
IT_ITEM_ADDNL_INPUT
DATE_TO_SCALE No End date for deriving time factors
(days/weeks/months/years) for time based scale
base calculation. This is required if pricing
procedure contains condition types with time
based scale base type
NUM_OF_DAYS_SCALE No Number of days. If you are supplying
DATE_FROM_SCALE and
DATE_TO_SCALE you don’t have to supply
this. System will calculate number of days. If
you supply it, system will use passed value for
calculation
NUM_OF_WEEKS_SCALE No Number of weeks. If you are supplying
DATE_FROM_SCALE and
DATE_TO_SCALE you don’t have to supply
this. System will calculate number of weeks. If
you supply it, system will use passed value for
calculation
NUM_OF_MONTHS_SCALE No Number of months. If you are supplying
DATE_FROM_SCALE and
DATE_TO_SCALE you don’t have to supply
this. System will calculate number of months. If
you supply it, system will use passed value for
calculation
NUM_OF_YEARS_SCALE No Number of years. If you are supplying
DATE_FROM_SCALE and
DATE_TO_SCALE you don’t have to supply
this. System will calculate number of years. If
you supply it, system will use passed value for
calculation
STATELESS PRICING REMOTE API
PRODUCT INNOVATION LIFECYCLE
B
PRODUCT INNOVATION LIFECYCLE
A
11
IT_ITEM_ADDNL_INPUT
IT_ITEM_ADDNL_INPUT is used for supplying item level additional attributes those are rarely (depending on
use cases) needed for price calculation. While filling entries into this parameter table you need to make sure
that it’s indexing should be matching with an entry in IT_ITEM_MAIN_INPUT. For example your first entry
in IT_ITEM_ADDNL_INPUT should correspond to first entry in IT_ITEM_MAIN_DATA. This is because
internally indexing is used while fetching entries from this table since index based read is faster.
Component Name Mandatory Purpose
ITEM_ID Yes Item identifier
DAYS_PER_MONTH No Needed only if you want to influence time based period factor
calculation. Indicates the number of days a month should be
accounted with.
DAYS_PER_YEAR No Needed only if you want to influence time based period factor
calculation Indicates the number of days a year should be
accounted with.
HOLIDAYS No Needed only if you want to influence time based period factor
calculation. Can be filled with individual days to reduce the
calculated values
VARIANT_CONDITIONS No For calculating conditions based on variant keys and factors
IT_ITEM_ATTRIB_INPUT
IT_ITEM_ATTRIB_INPUT is used for supplying pricing dynamic attribute set which is required for condition
finding and user exit executions. It is based on pricing procedure customization. You can retrieve this
customization information using RFC SPC_GET_PRICING_PROCEDURE_INFO. While filling entries into
this parameter table you need to make sure that it’s indexing should be matching with an entry in
IT_ITEM_MAIN_INPUT. For example your first entry in IT_ITEM_ATTRIB_INPUT should correspond to
first entry in IT_ITEM_MAIN_DATA. This is because internally indexing is used while fetching entries from
this table. Because index based read is faster.
Component Name Mandatory Purpose
ITEM_ID Yes Item identifier
FIELDNAME Yes Attribute name
FIELDVALUE Yes Attribute value
Version 1.00 – 25 FEB 2013 – © SAP AG 2023 –Note 1802168
12
IT_ITEM_TIMESTMP_INPUT
IT_ITEM_TIMESTMP_INPUT is used for supplying timestamps which is required for condition finding. It is
based on pricing procedure customization. You can retrieve this customization information using RFC
SPC_GET_PRICING_PROCEDURE_INFO. While filling entries into this parameter table you need to make
sure that it’s indexing should be matching with an entry in IT_ITEM_MAIN_INPUT. For example your first
entry in IT_ITEM_TIMESTMP_INPUT should correspond to first entry in IT_ITEM_MAIN_DATA. This is
because internally indexing is used while fetching entries from this table. Because index based read is faster.
Component Name Mandatory Purpose
ITEM_ID Yes Item identifier
FIELDNAME Yes Timestamp name
TIMESTAMP Yes Timestamp value
IT_MANUAL_COND_INPUT
IT_MANUAL_COND_INPUT is used for supplying manual conditions.
Component Name Mandatory Purpose
ITEM_ID Yes Item identifier. For adding condition at header level set it with
initial GUID
COND_TYPE Yes Condition type
COND_RATE Yes Condition rate
COND_CURRENCY Yes Condition currency
COND_UNIT_VALUE No Condition pricing unit value. Mandatory for non –percentage
and non-fixed amount condition
COND_UNIT No Condition unit. Mandatory for non –percentage and non-fixed
amount condition
CALC_TYPE No Calculation type. If calculation type need to be changed while
adding the manual condition. It will be allowed if and only if
condition type customization is setting is done in that way
2.2 Example how to call Stateless Pricing API
Here is an example which shows how you can invoke stateless pricing remote API using SAP JCo (Java
Connector) client from Java environment
Example call of Pricing Stateless Pricing API
public class ExampleStatelessPricingAPI { public static void main(String[] args) { System.out.println("--- START ---"); // connect to SAP system JCO.Client client = null; try { client = JCO.createClient( "100", // SAP client "myUser", // User ID
STATELESS PRICING REMOTE API
PRODUCT INNOVATION LIFECYCLE
B
PRODUCT INNOVATION LIFECYCLE
A
13
"mypassword", // Password "EN", // Language "myhost", // Host "01"); // System client.connect(); System.out.println("Connection OK\n"); } catch (Exception ex) { System.out.println(ex); return; } // print RFC attributes System.out.println(client.getAttributes()); // create JCo repository JCO.Repository repository = new JCO.Repository("Test123", client); // Function Module SPE_CALCULATE_PRICE IFunctionTemplate ft = repository.getFunctionTemplate("SPE_CALCULATE_PRICE"); JCO.Function function = null; try { function = ft.getFunction(); } catch (Exception ex) { System.out.println(ex); return; } // header data ParameterList importParameterList = function.getImportParameterList(); Structure structureHeaderInput = importParameterList.getStructure("IS_HEADER_INPUT"); structureHeaderInput.setValue("PRT", "APPLICATION"); structureHeaderInput.setValue("0PRT01", "PRC_PROCEDURE_NAME"); structureHeaderInput.setValue("EUR", "DOCUMENT_CURRENCY_UNIT"); structureHeaderInput.setValue("EUR", "LOCAL_CURRENCY_UNIT"); importParameterList.setValue(structureHeaderInput, "IS_HEADER_INPUT"); // item data String itemGuid = "6B28CB5091CE8C33E10000000A4233D1"; ParameterList tableParameterList = function.getTableParameterList(); Table tableItems = tableParameterList.getTable("IT_ITEM_MAIN_INPUT"); tableItems.appendRows(1); tableItems.setValue(itemGuid, "ITEM_ID"); tableItems.setValue("E212CC425DFF4625E10000000A422065", "PRODUCT_ID"); tableItems.setValue("M", "EXCH_RATE_TYPE"); tableItems.setValue("3", "QUANTITY"); tableItems.setValue("PAL", "QUANTITY_UNIT"); // item attributes Table tableItemAttributes = tableParameterList.getTable("IT_ITEM_ATTRIB_INPUT"); tableItemAttributes.appendRows(4); tableItemAttributes.setValue(itemGuid, "ITEM_ID"); tableItemAttributes.setValue("PRODUCT", "FIELDNAME"); tableItemAttributes.setValue("E212CC425DFF4625E10000000A422065", "FIELDVALUE"); tableItemAttributes.nextRow(); tableItemAttributes.setValue(itemGuid, "ITEM_ID"); tableItemAttributes.setValue("PRT_PARTNER", "FIELDNAME"); tableItemAttributes.setValue("7CF0CD505FF21975E10000000A448B72", "FIELDVALUE"); tableItemAttributes.nextRow(); tableItemAttributes.setValue(itemGuid, "ITEM_ID"); tableItemAttributes.setValue("PRT_PRICINGRELEVANT", "FIELDNAME"); tableItemAttributes.setValue("X", "FIELDVALUE"); tableItemAttributes.nextRow(); tableItemAttributes.setValue(itemGuid, "ITEM_ID"); tableItemAttributes.setValue("PRT_PRODUCT_GRP", "FIELDNAME"); tableItemAttributes.setValue("03", "FIELDVALUE"); // timestamps Table tableTimestamps = tableParameterList.getTable("IT_ITEM_TIMESTMP_INPUT"); tableTimestamps.appendRows(2);
Version 1.00 – 25 FEB 2013 – © SAP AG 2023 –Note 1802168
14
tableTimestamps.setValue(itemGuid, "ITEM_ID"); tableTimestamps.setValue("PRT_DELIVERYDATE", "FIELDNAME"); tableTimestamps.setValue("20041021000000", "TIMESTAMP"); tableTimestamps.nextRow(); tableTimestamps.setValue(itemGuid, "ITEM_ID"); tableTimestamps.setValue("PRT_ORDERDATE", "FIELDNAME"); tableTimestamps.setValue("20041021000000", "TIMESTAMP"); // execute function module try { client.execute(function); } catch (Exception ex) { System.out.println(ex); return; } // check result JCO.Structure structureHeaderResult = function.getExportParameterList().getStructure("ES_HEADER_RESULT"); System.out.println("Header Net Value: " + structureHeaderResult.getValue("NET_VALUE")); // disconnect from SAP system client.disconnect(); System.out.println("--- END ---"); } }
STATELESS PRICING REMOTE API
PRODUCT INNOVATION LIFECYCLE
B
PRODUCT INNOVATION LIFECYCLE
A
15
A FAQ/TROUBLE SHOOTING
Please refer to the note 1746584 "FAQ support note for Pricing, Condition Technique and Tax" that provides many
helpful hints and refers to many further helpful notes.
top related