0

I am using the SAP Cloud SDK to invoke OData service API_SALES_ORDER_SIMULATION_SRV to do sales order simulation.

The pay load I used is as below:

{
    "SalesOrderType"            : "**",
    "SalesOrganization"         : "**",
    "DistributionChannel"       : "01",
    "OrganizationDivision"      : "01",
    "SoldToParty"               : "1000",
    "TransactionCurrency"       : "EUR",
    "PurchaseOrderByCustomer"   : "E2E S4HANA",
    "to_Item":[
        { "SalesOrderItem" : "10",
          "Material"       : "**",
          "RequestedQuantity"  : "1000",
          "to_ScheduleLine"    : []
        }
    ]
}

The response I got from S/4HANA.

{
    "d": {
        "__metadata": {
            "id": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderSimulation('')",
            "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderSimulation('')",
            "type": "API_SALES_ORDER_SIMULATION_SRV.A_SalesOrderSimulationType"
        },
        "SalesOrder": "",
        "SalesOrderType": "YTA",
        "SalesOrganization": "***",
        "DistributionChannel": "01",
        "OrganizationDivision": "01",
        "SalesGroup": "",
        "SalesOffice": "",
        "SalesDistrict": "000002",
        "SoldToParty": "***",
        "PurchaseOrderByCustomer": "E2E S4HANA",
        "CustomerPurchaseOrderType": "",
        "CustomerPurchaseOrderDate": null,
        "SalesOrderDate": "/Date(1571875200000)/",
        "TransactionCurrency": "EUR",
        "SDDocumentReason": "",
        "PricingDate": "/Date(1571875200000)/",
        "RequestedDeliveryDate": "/Date(1571875200000)/",
        "ShippingCondition": "",
        "CompleteDeliveryIsDefined": false,
        "ShippingType": "",
        "IncotermsClassification": "***",
        "IncotermsTransferLocation": "***",
        "IncotermsLocation1": "***",
        "IncotermsLocation2": "",
        "IncotermsVersion": "",
        "CustomerPaymentTerms": "0001",
        "PaymentMethod": "",
        "to_Credit": {
            "__deferred": {
                "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderSimulation('')/to_Credit"
            }
        },
        "to_Item": {
            "results": [
                {
                    "__metadata": {
                        "id": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderItemSimulation(SalesOrder='',SalesOrderItem='10')",
                        "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderItemSimulation(SalesOrder='',SalesOrderItem='10')",
                        "type": "API_SALES_ORDER_SIMULATION_SRV.A_SalesOrderItemSimulationType"
                    },
                    "SalesOrder": "",
                    "SalesOrderItem": "10",
                    "HigherLevelItem": "0",
                    "SalesOrderItemCategory": "***",
                    "SalesOrderItemText": "***",
                    "PurchaseOrderByCustomer": "E2E S4HANA",
                    "Material": "***",
                    "MaterialByCustomer": "***",
                    "PricingDate": "/Date(1571875200000)/",
                    "RequestedQuantity": "10000000",
                    "RequestedQuantityUnit": "PC",
                    "TransactionCurrency": "EUR",
                    "NetAmount": "0.00",
                    "TaxAmount": "0.00",
                    "CostAmount": "0.00",
                    "Subtotal1Amount": "0.00",
                    "Subtotal2Amount": "0.00",
                    "Subtotal3Amount": "0.00",
                    "Subtotal4Amount": "0.00",
                    "Subtotal5Amount": "0.00",
                    "Subtotal6Amount": "0.00",
                    "MaterialGroup": "01",
                    "MaterialPricingGroup": "",
                    "Batch": "",
                    "Plant": "***",
                    "StorageLocation": "",
                    "DeliveryGroup": "0",
                    "ShippingPoint": "***",
                    "ShippingType": "",
                    "DeliveryPriority": "0",
                    "IncotermsClassification": "***",
                    "IncotermsTransferLocation": "***",
                    "IncotermsLocation1": "***",
                    "IncotermsLocation2": "",
                    "CustomerPaymentTerms": "0001",
                    "SalesDocumentRjcnReason": "",
                    "to_Partner": {
                        "__deferred": {
                            "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderItemSimulation(SalesOrder='',SalesOrderItem='10')/to_Partner"
                        }
                    },
                    "to_PricingElement": {
                        "__deferred": {
                            "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderItemSimulation(SalesOrder='',SalesOrderItem='10')/to_PricingElement"
                        }
                    },
                    "to_SalesOrder": {
                        "__deferred": {
                            "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderItemSimulation(SalesOrder='',SalesOrderItem='10')/to_SalesOrder"
                        }
                    },
                    "to_ScheduleLine": {
                        "results": [
                            {
                                "__metadata": {
                                    "id": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderScheduleLineSimln(SalesOrder='',SalesOrderItem='10',ScheduleLine='1')",
                                    "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderScheduleLineSimln(SalesOrder='',SalesOrderItem='10',ScheduleLine='1')",
                                    "type": "API_SALES_ORDER_SIMULATION_SRV.A_SalesOrderScheduleLineSimlnType"
                                },
                                "SalesOrder": "",
                                "SalesOrderItem": "10",
                                "ScheduleLine": "1",
                                "RequestedDeliveryDate": "/Date(1571875200000)/",
                                "ConfirmedDeliveryDate": null,
                                "OrderQuantityUnit": "PC",
                                "ScheduleLineOrderQuantity": "10000000",
                                "ConfdOrderQtyByMatlAvailCheck": "0",
                                "OpenConfdDelivQtyInOrdQtyUnit": "0",
                                "CorrectedQtyInOrderQtyUnit": "10000000",
                                "to_SalesOrder": {
                                    "__deferred": {
                                        "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderScheduleLineSimln(SalesOrder='',SalesOrderItem='10',ScheduleLine='1')/to_SalesOrder"
                                    }
                                },
                                "to_SalesOrderItem": {
                                    "__deferred": {
                                        "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderScheduleLineSimln(SalesOrder='',SalesOrderItem='10',ScheduleLine='1')/to_SalesOrderItem"
                                    }
                                }
                            },
                            {
                                "__metadata": {
                                    "id": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderScheduleLineSimln(SalesOrder='',SalesOrderItem='10',ScheduleLine='2')",
                                    "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderScheduleLineSimln(SalesOrder='',SalesOrderItem='10',ScheduleLine='2')",
                                    "type": "API_SALES_ORDER_SIMULATION_SRV.A_SalesOrderScheduleLineSimlnType"
                                },
                                "SalesOrder": "",
                                "SalesOrderItem": "10",
                                "ScheduleLine": "2",
                                "RequestedDeliveryDate": null,
                                "ConfirmedDeliveryDate": "/Date(1571961600000)/",
                                "OrderQuantityUnit": "PC",
                                "ScheduleLineOrderQuantity": "0",
                                "ConfdOrderQtyByMatlAvailCheck": "18595.5",
                                "OpenConfdDelivQtyInOrdQtyUnit": "0",
                                "CorrectedQtyInOrderQtyUnit": "0",
                                "to_SalesOrder": {
                                    "__deferred": {
                                        "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderScheduleLineSimln(SalesOrder='',SalesOrderItem='10',ScheduleLine='2')/to_SalesOrder"
                                    }
                                },
                                "to_SalesOrderItem": {
                                    "__deferred": {
                                        "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderScheduleLineSimln(SalesOrder='',SalesOrderItem='10',ScheduleLine='2')/to_SalesOrderItem"
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        },
        "to_Partner": {
            "__deferred": {
                "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderSimulation('')/to_Partner"
            }
        },
        "to_Pricing": {
            "__deferred": {
                "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderSimulation('')/to_Pricing"
            }
        },
        "to_PricingElement": {
            "__deferred": {
                "uri": "http://host:port/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderSimulation('')/to_PricingElement"
            }
        }
    }
}

It works fine in SAP Gateway Client and it returns all the data I want including to_ScheduleLine navigation data in item.

But when I invoke the API using Cloud SDK and set the same payload, the sales order simulation data is returned without the to_ScheduleLine navigation data.

I looked deep into the source code of SDK, and found that this part of data was included in the response. But when transferring odata result to sales order simulation entity, the data is lost.

OData Response

The schedule line properties are lost when constructing EntityT with properties in Class FluentHelperCreate.class.

@Override
@Nonnull
public EntityT execute( @Nonnull final HttpDestinationProperties destination )
    throws ODataException
{
    final HttpClient httpClient = HttpClientAccessor.getHttpClient(destination);
    notifyQueryListeners(destination, getEntity());
    final ODataCreateResult result = toQuery().execute(httpClient);

    final EntityT createdEntity = new VdmEntityUtil<>(getEntityClass()).fromFields(result.asMap());
    createdEntity.attachToService(getServicePath(), destination);
    return createdEntity;
}

The to_ScheduleLine data is very important to our business workflow. Because when customer does the sales order simulation and provide the RequestedQuantity of item, he or she needs to know whether the storage is enough or not.

Could you help to take a look a this issue?

SAP Cloud SDK Version: 3.3.1 S/4HANA on premise version: 1909

=============================================================================

Update

pom.xml in root project

<?xml version='1.0' encoding='utf-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <name>Test3.11 - Root</name>
    <description>Test3.11 - Root</description>

    <groupId>com.bosch.test</groupId>
    <artifactId>Test3.11</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <spring-boot.version>2.2.1.RELEASE</spring-boot.version>

        <java.version>1.8</java.version>

        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <maven.compiler.testSource>${java.version}</maven.compiler.testSource>
        <maven.compiler.testTarget>${java.version}</maven.compiler.testTarget>

        <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.sap.cloud.sdk</groupId>
                <artifactId>sdk-bom</artifactId>
                <version>3.13.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>javax.validation</groupId>
                <artifactId>validation-api</artifactId>
                <version>2.0.1.Final</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <modules>
        <module>application</module>
        <module>unit-tests</module>
        <module>integration-tests</module>
    </modules>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M2</version>
                <executions>
                    <execution>
                        <id>SAP Cloud SDK Project Structure Checks</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>3.5</version>
                                </requireMavenVersion>
                                <requireJavaVersion>
                                    <version>${java.version}</version>
                                </requireJavaVersion>
                                <requireProperty>
                                    <property>project.artifactId</property>
                                    <regex>[^_]+</regex>
                                    <regexMessage>"The artifactId should not contain underscores (_) as this causes issues when deploying to Cloud Foundry."</regexMessage>
                                </requireProperty>
                                <reactorModuleConvergence />
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

pom.xml in application project

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <name>Test3.11 - Application</name>
    <description>Test3.11 - Application</description>

    <artifactId>Test3.11-application</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>com.bosch.test</groupId>
        <artifactId>Test3.11</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <dependencies>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- mybatis  -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.1</version>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <!--<version>42.2.8</version>-->
        </dependency>

        <dependency>
            <groupId>com.sap.xs2.security</groupId>
            <artifactId>security-commons</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sap.xs2.security</groupId>
            <artifactId>java-container-security</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sap.xs2.security</groupId>
            <artifactId>java-container-security-api</artifactId>
            <version>0.28.6</version>
        </dependency>
        <dependency>
            <groupId>com.sap.security.nw.sso.linuxx86_64.opt</groupId>
            <artifactId>sapjwt.linuxx86_64</artifactId>
            <version>1.1.19</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-jwt</artifactId>
            <version>1.0.10.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security.oauth</groupId>
            <artifactId>spring-security-oauth2</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sap.cloud.security.xsuaa</groupId>
            <artifactId>api</artifactId>
            <version>2.2.0</version>
        </dependency>

        <dependency>
            <groupId>com.github.ben-manes.caffeine</groupId>
            <artifactId>jcache</artifactId>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.sap.cloud.sdk.cloudplatform</groupId>
            <artifactId>scp-cf</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sap.cloud.sdk.s4hana</groupId>
            <artifactId>s4hana-all</artifactId>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sap.hcp.cf.logging</groupId>
            <artifactId>cf-java-logging-support-logback</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!--
        Since com.sap.xs2.security:java-container-security is not available in Maven Central as of today,
        you need to download this dependency manually.

        The library is available for download at:
        https://launchpad.support.sap.com/#/softwarecenter/search/XS_JAVA
        -->

        <!-- Dependencies for security setup -->
        <!--
        <dependency>
            <groupId>com.sap.xs2.security</groupId>
            <artifactId>java-container-security</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.unboundid.components</groupId>
                    <artifactId>json</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security.oauth</groupId>
            <artifactId>spring-security-oauth2</artifactId>
        </dependency>
        -->

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <attach>false</attach>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.sap.cloud.sdk.plugins</groupId>
                <artifactId>usage-analytics-maven-plugin</artifactId>
                <version>3.13.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>usage-analytics</goal>
                        </goals>
                        <configuration>
                            <skipUsageAnalytics>false</skipUsageAnalytics>
                            <generateSalt>true</generateSalt>
                            <!--
                            Note: A random salt is auto-generated once the project is built for the first time.
                            Please keep the generated salt in the POM file, for example, when pushing to git.

                            To learn more, visit: https://blogs.sap.com/2018/10/23/usage-analytics-s4sdk/
                            -->
                            <salt>438271d5d965d55c65e6913db160e0f9b6001952410dcb2f8e3d6956cbf14112</salt>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Thanks,

Jerry

Jerry Zhang
  • 179
  • 3
  • 13
  • 1
    Can you please provide us the expected response that you got e.g. via the gateway directly? Than we can have a deeper look into the behavior of the VDM and see where the navigation property is swallowed. Please make sure, that it doesn't contain any sensitive information! – Christoph Schubert Nov 01 '19 at 15:20
  • I provided the response with Json Format. – Jerry Zhang Nov 12 '19 at 12:37
  • Okay, I reproduced the the issue locally and found the root cause. There seems to be a bug in a library that we use. We will look into this internally and will come back to you with any updates we have. – Christoph Schubert Nov 15 '19 at 08:17
  • Can you please try SAP Cloud SDK `3.13.0` or later? We solved an issue with deserialization of navigation properties. If it is not working, can you please share the `pom.xml` that you are using? – Alexander Dümont Feb 26 '20 at 09:21
  • Seems it was not fixed in SAP Cloud SDK verson 3.13.0. Please verify pom.xml above. – Jerry Zhang Mar 02 '20 at 07:26
  • That surprises me. Currently with `3.14.0`, I'm trying to reproduce the problem, but my first tests showed correct / expected behavior. Now I'll try to reproduce with full wiremock test also for version `3.13.0`. In the meantime you could quickly check in a debugging session whether the variable `ODataCreateResult result` in your quoted code snippet contains all expected properties. – Alexander Dümont Mar 05 '20 at 09:46

1 Answers1

1

Please update to version 3.14.0 of the SAP Cloud SDK.


For reproducing the issue, I compared my previous test results as described in the comments with those from Wiremock tests and version 3.13.0 (and earlier). It turns out the issue that you've described was fixed one iteration later. It was fixed in 3.14.0.

Alexander Dümont
  • 903
  • 1
  • 5
  • 9