SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning...

12
CUSTOMER Document Version: 3.0.3.1 – 2016-05-10 SAP Sales and Operations Planning 3.0 SP03 API Guide

Transcript of SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning...

Page 1: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

CUSTOMER

Document Version: 3.0.3.1 – 2016-05-10

SAP Sales and Operations Planning 3.0 SP03 API Guide

Page 2: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

Content

1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1 Business case. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 API Reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83.1 Using time period IDs instead of date and time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.2 Specifying a scenario for obtaining key figure data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.3 Specifying output in CSV format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2C U S T O M E R© 2016 SAP SE or an SAP affiliate company. All rights reserved.

SAP Sales and Operations Planning 3.0 SP03 API GuideContent

Page 3: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

1 Overview

The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated S&OP 2.0 data export API.

The target audience of this guide is IT specialists who do ETL (extract, transform, load) on databases. This guide shows how to extract key figure data from an S&OP system primarily to transform and the data to another target system.

1.1 Business case

SAP Sales and Operations Planning (S&OP) increases the visibility of data to support decisions around controlling costs, improving customer service, and much more. It works with data from operational systems such as SAP Enterprise Resource Planning (SAP ERP) and SAP Advanced Planning Optimization (SAP APO). S&OP collects and then returns data to the operational systems.

This API enables the tool to export key figure data from the application so that the data can be consumed by ETL tools (such as Data Services), integration applications (such as SAP NetWeaver Process Integration) or directly from operational systems."

1.2 Architecture

The diagram here shows how the export key figure service works:

1. The consumer calls the service API (getDataExport).2. The service queries the SAP Sales and Operations HANA database.3. The service returns the results to the consumer.

SAP Sales and Operations Planning 3.0 SP03 API GuideOverview

C U S T O M E R© 2016 SAP SE or an SAP affiliate company. All rights reserved. 3

Page 4: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

Figure 1: S&OP key figure export architecture

4C U S T O M E R© 2016 SAP SE or an SAP affiliate company. All rights reserved.

SAP Sales and Operations Planning 3.0 SP03 API GuideOverview

Page 5: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

2 API Reference

The API uses a RESTful web service. Requests are formatted as JSON, and responses can be formatted as JSON or CSV. This guide explains the parameters for exporting key figure data.

Prerequisites

● The source planning area should be available.● To authenticate and invoke this RESTful service, you must have the View All visibility filter for the source

planning area.● Basic authentication is required.

Resource URI

POST <http or https>://<server URI>/sap/sop/sopfnd/services/analytics/sopa.xsjs

For example: https://mydomain.com/sap/sop/services/analytics/sopa.xsjs

NoteThere is only a POST because GET functionality is included in the POST request.

Sample request syntax

{ "ACTION":"getDataExport", "plarea":"<planning_area_id>", "select":"<attributes>,<key_figures>", "filter":"IN(<time_attribute>,'<start_time>','<end_time>')" "contenttype":<output_format>}

Sample request

In this example, a user obtains key figure data for Sales Forecast Quantity and Marketing Forecast Quantity between July 1st, 2013 and September 30th, 2013. The user wants to obtain the customer ID, product ID, period

SAP Sales and Operations Planning 3.0 SP03 API GuideAPI Reference

C U S T O M E R© 2016 SAP SE or an SAP affiliate company. All rights reserved. 5

Page 6: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

ID, sales forecast quantity, and marketing forecast quantity for all entries in the x Phone product family in the SAPMODEL1 planning area.

{ "ACTION":"getDataExport", "plarea":"SAPMODEL1", "select":"SM1CUSTID,SM1PRDID,PERIODID0,SALESFORECASTQTY,MARKETINGFORECASTQTY", "orderby":"SM1CUSTID,SM1PRDID,PERIODID0", "filter":"IN(SM1PRDFAMILY,'x Phone')ANDBT(PERIODID0,'2013-07-01 00:00:00.0','2013-09-30 23:59:59.999')"}

Parameters for getDataExport

Table 1:

Parameter Description

action This will always be set to getDataExport. Required.

plarea The Planning Area ID, for example, SAPMODEL1. Required.

select You can put attributes here, such as customer name, product ID, and so on.Required: In this section, you must add key figures such as sales forecast quantity and marketing forecast quan­tity. Otherwise you will get an empty response.

filter You can add filters. Optionally, you can obtain key figure data from a non-default scenario. See Specifying a scenario for ob­taining key figure data [page 9] for an example. Required: A time attribute with start and end times must be specified in one of the following ways:

● YYYY-MM-DD hh:mm:ss[.nnn], for example, 2013-07-01 00:00:00.0.

● Use a time_profile_id, for example, 1234. See Using time period IDs instead of date and time [page 8] for an ex­ample.

● The time stamp has to match the definition of the cus­tomer time profile. If the time profile does not have milli­seconds, the syntax should be YYYY-MM-DD 23:59:59.0.

contenttype JSON is the default response format. You can specify output in CSV format by adding the following code: "contenttype":"csv. See Specifying output in CSV for­mat [page 10] for an example

6C U S T O M E R© 2016 SAP SE or an SAP affiliate company. All rights reserved.

SAP Sales and Operations Planning 3.0 SP03 API GuideAPI Reference

Page 7: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

Sample response

This is a portion of the full response:

[{"SM1CUSTID":"101","SM1PRDID":"x107 Phone","PERIODID0":"1055","PERIOD_FROM":"2013-07-01 00:00:00.0000000","PERIOD_TO":"2013-07-31 23:59:59.9990000","SALESFORECASTQTY":"1234.136843","MARKETINGFORECASTQTY":"1221"} {"SM1CUSTID":"101","SM1PRDID":"x107 Phone","PERIODID0":"1056","PERIOD_FROM":"2013-08-01 00:00:00.0000000","PERIOD_TO":"2013-08-31 23:59:59.9990000","SALESFORECASTQTY":"1219.5","MARKETINGFORECASTQTY":"1219.5"}{"SM1CUSTID":"101","SM1PRDID":"x107 Phone","PERIODID0":"1057","PERIOD_FROM":"2013-09-01 00:00:00.0000000","PERIOD_TO":"2013-09-30 23:59:59.9990000","SALESFORECASTQTY":"1279.643158","MARKETINGFORECASTQTY":"1279.63"} {"SM1CUSTID":"102","SM1PRDID":"x102 Phone","PERIODID0":"1055","PERIOD_FROM":"2013-07-01 00:00:00.0000000","PERIOD_TO":"2013-07-31 23:59:59.9990000","SALESFORECASTQTY":"1234.136842","MARKETINGFORECASTQTY":"1221"}]

If an empty response is received, it will look like this:

[]

If the request contains a syntax error, the response will contain an informative error message for troubleshooting the error.

SAP Sales and Operations Planning 3.0 SP03 API GuideAPI Reference

C U S T O M E R© 2016 SAP SE or an SAP affiliate company. All rights reserved. 7

Page 8: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

3 Examples

The following examples show different ways of using the API.

Accepted content types: application/json, text/javascript, */*; q=0.01.

3.1 Using time period IDs instead of date and time

You can use time period IDs for filtering instead of datetime entries.

In the filter line, the datetime entries are replaced with period IDs (1057, 1058).

Sample request

Notice that only the filter has changed.

{ "ACTION":"getDataExport", "plarea":"SAPMODEL1", "select":"SM1CUSTID,SM1PRDID,PERIODID0,SALESFORECASTQTY,MARKETINGFORECASTQTY", "orderby":"SM1CUSTID,SM1PRDID,PERIODID0", "filter":"IN(SM1PRDFAMILY,'x Phone')ANDIN(PERIODID0,'1057','1058')"}

Sample response

This is a portion of the full response.

[{"SM1CUSTID":"101","SM1PRDID":"x107 Phone","PERIODID0":"1057","PERIOD_FROM":"2013-09-01 00:00:00.0000000","PERIOD_TO":"2013-09-30 23:59:59.9990000","SALESFORECASTQTY":"1279.643158","MARKETINGFORECASTQTY":"1279.63"} {"SM1CUSTID":"101","SM1PRDID":"x107 Phone","PERIODID0":"1058","PERIOD_FROM":"2013-10-01 00:00:00.0000000","PERIOD_TO":"2013-10-31 23:59:59.9990000","SALESFORECASTQTY":"1219.5","MARKETINGFORECASTQTY":"1219.5"} {"SM1CUSTID":"102","SM1PRDID":"x102 Phone","PERIODID0":"1057","PERIOD_FROM":"2013-09-01 00:00:00.0000000","PERIOD_TO":"2013-09-30 23:59:59.9990000","SALESFORECASTQTY":"1279.643158","MARKETINGFORECASTQTY":"1279.63"}]

8C U S T O M E R© 2016 SAP SE or an SAP affiliate company. All rights reserved.

SAP Sales and Operations Planning 3.0 SP03 API GuideExamples

Page 9: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

3.2 Specifying a scenario for obtaining key figure data

You can specify which scenario you want in the filter.

If a scenario is not specified, the default one will be chosen. If you want to specify a scenario, add the following code to your filter.

ANDIN(<scenario_attribute>, '<scenario_id>')

In the following example, the DOWNSIDE scenario is specified:

ANDIN(SCNID,'DOWNSIDE')

Sample request

The key figure has been changed to one that exists in this scenario (ACTUALSQTY).

{ "ACTION":"getDataExport", "plarea":"SAPMODEL1", "select":"SM1CUSTID,SM1PRDID,PERIODID0,ACTUALSQTY", "orderby":"SM1CUSTID,SM1PRDID,PERIODID0", "filter":"IN(SM1PRDFAMILY,'x Phone')ANDBT(PERIODID0,'2013-07-01 00:00:00.0','2013-09-30 23:59:59.999')ANDIN(SCNID,'DOWNSIDE')"}

Sample response

This is a portion of the full response.

[{"SM1CUSTID":"101","SM1PRDID":"x107 Phone","PERIODID0":"1055","PERIOD_FROM":"2013-07-01 00:00:00.0000000","PERIOD_TO":"2013-07-31 23:59:59.9990000","ACTUALSQTY":"0"} {"SM1CUSTID":"101","SM1PRDID":"x107 Phone","PERIODID0":"1056","PERIOD_FROM":"2013-08-01 00:00:00.0000000","PERIOD_TO":"2013-08-31 23:59:59.9990000","ACTUALSQTY":"0"} {"SM1CUSTID":"101","SM1PRDID":"x107 Phone","PERIODID0":"1057","PERIOD_FROM":"2013-09-01 00:00:00.0000000","PERIOD_TO":"2013-09-30 23:59:59.9990000","ACTUALSQTY":"0"}]

SAP Sales and Operations Planning 3.0 SP03 API GuideExamples

C U S T O M E R© 2016 SAP SE or an SAP affiliate company. All rights reserved. 9

Page 10: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

3.3 Specifying output in CSV format

You can obtain the response in CSV format instead of JSON.

By default, the response will be in JSON format. You can receive responses in CSV format by adding the following code:

"contenttype":"csv"

Request

Notice the addition of content type at the end of the code.

{ "ACTION":"getDataExport", "plarea":"SAPMODEL1", "select":"SM1CUSTID,SM1PRDID,PERIODID0,SALESFORECASTQTY,MARKETINGFORECASTQTY", "orderby":"SM1CUSTID,SM1PRDID,PERIODID0", "filter":"IN(SM1PRDFAMILY,'x Phone')ANDBT(PERIODID0,'2013-07-01 00:00:00.0','2013-09-30 23:59:59.999')", "contenttype":"csv"}

Response

This is a portion of the full response.

SM1CUSTID,SM1PRDID,PERIODID0,PERIOD_FROM,PERIOD_TO,SALESFORECASTQTY,MARKETINGFORECASTQTY 101,x107 Phone,1055,2013-07-01 00:00:00.0000000,2013-07-31 23:59:59.9990000,1234.136843,1221101,x107 Phone,1056,2013-08-01 00:00:00.0000000,2013-08-31 23:59:59.9990000,1219.5,1219.5101,x107 Phone,1057,2013-09-01 00:00:00.0000000,2013-09-30 23:59:59.9990000,1279.643158,1279.63

10C U S T O M E R© 2016 SAP SE or an SAP affiliate company. All rights reserved.

SAP Sales and Operations Planning 3.0 SP03 API GuideExamples

Page 11: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

Important Disclaimers and Legal Information

Coding SamplesAny 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 to 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, unless damages were caused by SAP intentionally or by SAP's gross negligence.

AccessibilityThe information contained in the SAP documentation represents SAP's current view of accessibility criteria as of the date of publication; it is in no way intended to be a binding guideline on how to ensure accessibility of software products. SAP in particular disclaims any liability in relation to this document. This disclaimer, however, does not apply in cases of wilful misconduct or gross negligence of SAP. Furthermore, this document does not result in any direct or indirect contractual obligations of SAP.

Gender-Neutral LanguageAs far as possible, SAP documentation is gender neutral. Depending on the context, the reader is addressed directly with "you", or a gender-neutral noun (such as "sales person" or "working days") is used. If when referring to members of both sexes, however, the third-person singular cannot be avoided or a gender-neutral noun does not exist, SAP reserves the right to use the masculine form of the noun and pronoun. This is to ensure that the documentation remains comprehensible.

Internet HyperlinksThe SAP documentation may contain hyperlinks to the Internet. These hyperlinks are intended to serve as a hint about where to find related information. SAP does not warrant the availability and correctness of this related information or the ability of this information to serve a particular purpose. SAP shall not be liable for any damages caused by the use of related information unless damages have been caused by SAP's gross negligence or willful misconduct. All links are categorized for transparency (see: http://help.sap.com/disclaimer).

SAP Sales and Operations Planning 3.0 SP03 API GuideImportant Disclaimers and Legal Information

C U S T O M E R© 2016 SAP SE or an SAP affiliate company. All rights reserved. 11

Page 12: SAP Sales and Operations Planning 3.0 SP03 API Guide Overview The SAP Sales and Operations Planning 3.0 SP2 data export API is a RESTful web service replacement of the now-deprecated

go.sap.com/registration/contact.html

© 2016 SAP SE or an SAP affiliate company. 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 SE or an SAP affiliate company. The information contained herein may be changed without prior notice.Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors. National product specifications may vary.These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP or SAP affiliate company 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.SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names mentioned are the trademarks of their respective companies.Please see http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.