我正在使用sales调用OData服务API_SALES_ORDER_SIMULATION_SRV来进行销售订单模拟。
我使用的负载如下:
{
"SalesOrderType" : "**",
"SalesOrganization" : "**",
"DistributionChannel" : "01",
"OrganizationDivision" : "01",
"SoldToParty" : "1000",
"TransactionCurrency" : "EUR",
"PurchaseOrderByCustomer" : "E2E S4HANA",
"to_Item":[
{ "SalesOrderItem" : "10",
"Material" : "**",
"RequestedQuantity" : "1000",
"to_ScheduleLine" : []
}
]
}我从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"
}
}
}
}它在navigation客户机中运行良好,并返回我想要的所有数据,包括项目中的to_ScheduleLine导航数据。
但是,当我使用Cloud调用API并设置相同的有效载荷时,销售订单模拟数据将在没有to_ScheduleLine导航数据的情况下返回。
我深入研究了SDK的源代码,发现这部分数据包含在响应中。但是,当将数据结果传递给销售订单模拟实体时,数据会丢失。
当使用类EntityT中的属性构造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;
}to_ScheduleLine数据对于我们的业务工作流非常重要。因为当客户进行销售订单模拟并提供商品的RequestedQuantity时,他或她需要知道存储是否足够。
你能帮我看一下这个问题吗?
版本:3.3.1S/4HANA on前提版本: 1909
=============================================================================
更新
根项目中的pom.xml
<?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
<?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>谢谢,
曾傑瑞
发布于 2020-03-05 11:06:45
请更新到SDK的3.14.0版本。
为了重现这个问题,我将前面的测试结果(如注释中所描述的)与来自Wiremock测试和版本3.13.0 (以及更早版本)的测试结果进行了比较。原来您所描述的问题是在一次迭代之后修复的。用3.14.0固定。
https://stackoverflow.com/questions/58637397
复制相似问题