sop301_api_en.pdf

12
SAP Sales and Operations API Guide

Upload: xdgr

Post on 06-Sep-2015

217 views

Category:

Documents


3 download

TRANSCRIPT

  • SAP Sales and Operations API Guide

  • Table of Contents1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1 Business case. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Data export API from SAP S&OP 2.0 SP2 is no longer supported. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    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

    2 2014 SAP AG or an SAP affiliate company. All rights reserved.SAP Sales and Operations API Guide

    Table of Contents

  • 1 OverviewThe SAP Sales and Operations Planning 3.0 SP1 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 caseSAP 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 ArchitectureThe 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 API GuideOverview 2014 SAP AG or an SAP affiliate company. All rights reserved. 3

  • Figure 1: S&OP key figure export architecture

    1.3 Data export API from SAP S&OP 2.0 SP2 is no longer supportedThe data export API from SAP Sales and Operations Planning (S&OP) 2.0 is no longer supported in SAP S&OP 3.0 SP1.The new API is a RESTful web service.

    4 2014 SAP AG or an SAP affiliate company. All rights reserved.SAP Sales and Operations API Guide

    Overview

  • 2 API ReferenceThe 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 :///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":"", "select":",", "filter":"IN(,'','')" "contenttype":}

    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 ID, sales forecast quantity, and marketing forecast quantity for all entries in the x Phone product family in the SAPMODEL1 planning area.

    { "ACTION":"getDataExport",

    SAP Sales and Operations API GuideAPI Reference 2014 SAP AG or an SAP affiliate company. All rights reserved. 5

  • "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

    Parameter Descriptionaction This will always be set to getDataExport. Required.plarea The Planning Area ID, for example, SAPMODEL1. Re

    quired.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 quantity. 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 obtaining key figure data 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 for an example.

    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 format for an example

    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

    6 2014 SAP AG or an SAP affiliate company. All rights reserved.SAP Sales and Operations API Guide

    API Reference

  • 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 API GuideAPI Reference 2014 SAP AG or an SAP affiliate company. All rights reserved. 7

  • 3 ExamplesThe 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"}]

    8 2014 SAP AG or an SAP affiliate company. All rights reserved.SAP Sales and Operations API Guide

    Examples

  • 3.2 Specifying a scenario for obtaining key figure dataYou 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(, '')

    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 API GuideExamples 2014 SAP AG or an SAP affiliate company. All rights reserved. 9

  • 3.3 Specifying output in CSV formatYou 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,MARKETINGFORECASTQTY101,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

    10 2014 SAP AG or an SAP affiliate company. All rights reserved.SAP Sales and Operations API Guide

    Examples

  • SAP Sales and Operations API GuideExamples 2014 SAP AG or an SAP affiliate company. All rights reserved. 11

  • www.sap.com/contactsap

    2014 SAP AG 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 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. National product specifications may vary.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.SAP 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.Please see http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.

    SAP Sales and Operations API GuideTable of Contents1 Overview1.1 Business case1.2 Architecture1.3 Data export API from SAP S&OP 2.0 SP2 is no longer supported

    2 API Reference3 Examples3.1 Using time period IDs instead of date and time3.2 Specifying a scenario for obtaining key figure data3.3 Specifying output in CSV format

    Copyright and Trademarks