08-20-2019 12:11 PM - edited 02-04-2024 6:29 AM
{
"SalesOrderType" : "OR",
"SalesOrganization" : "2410",
"DistributionChannel" : "10",
"OrganizationDivision" : "00",
"SoldToParty" : "24100003",
"PurchaseOrderByCustomer" : "SalesOrder Simulation",
"to_Pricing" : {},
"to_PricingElement" : [],
"to_Item":[
{ "SalesOrderItem" : "10",
"Material" : "SOMEMATERIAL",
"RequestedQuantity" : "1"
}]
}
But with my code, instantiating those empty pricing elements gives me no pricing information:
/* New Sales Orders */
SalesOrderSimulation oSimulationInput = new SalesOrderSimulation();
oSimulationInput.setSalesOrganization("2410");
oSimulationInput.setSalesOrderType("O");
oSimulationInput.setDistributionChannel("10");
oSimulationInput.setOrganizationDivision("00");
oSimulationInput.setSoldToParty("24100003");
oSimulationInput.setPurchaseOrderByCustomer("2000000");
oSimulationInput.setPricingElement(new ArrayList<SalesOrderPrcgElmntSimln>());
SalesOrderPricingSimulation orderPricing = new SalesOrderPricingSimulation();
oSimulationInput.setPricing(orderPricing);
/* Add Item */
SalesOrderItemSimulation oItem = new SalesOrderItemSimulation();
oItem.setSalesOrderItem("10");
oItem.setMaterial("SOMEMATERIAL");
BigDecimal requestedQuantity = new BigDecimal("1");
oItem.setRequestedQuantity(requestedQuantity);
oSimulationInput.addItem(oItem);
SalesOrderSimulation oSimulation = oService._mSimulate(oSimulationInput);
Is there something I am overseeing? Is the serialization the problem? I'm using Springboot 1.41 for the project.
Thank you for your time!
Hi Germán,
I don't have an S/4HANA system to test the following code. So, could you test it and see if it works for you:
@WebServlet("/sosimulation")
public class SalesOrderSimulationServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(SalesOrderSimulationServlet.class);
private final ErpHttpDestination destination = DestinationAccessor.getDestination("MyErpSystem").asHttp().decorate(DefaultErpHttpDestination::new);
private static final String _SERVICE_PATH = "sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV/A_SalesOrderSimulation";
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException {
try {
SalesOrderItemSimulation soItemSimulation = SalesOrderItemSimulation.builder()
.salesOrderItem("10")
.material("SOMEMATERIAL")
.requestedQuantity(new BigDecimal("1"))
.build();
SalesOrderSimulation sosimulation = SalesOrderSimulation.builder()
.salesOrganization("2410")
.salesOrderType("O")
.distributionChannel("10")
.organizationDivision("00")
.soldToParty("24100003")
.purchaseOrderByCustomer("2000000")
.pricingElement(new SalesOrderPrcgElmntSimln())
.pricing(new SalesOrderPricingSimulation() )
.item(soItemSimulation)
.build();
SalesOrderSimulationCreateFluentHelper soSimulationHelper = new SalesOrderSimulationCreateFluentHelper(_SERVICE_PATH, sosimulation);
final SalesOrderSimulation fetchedSoSimulation = soSimulationHelper.execute(destination);
response.setContentType("application/json");
response.getWriter().write(new Gson().toJson(fetchedSoSimulation));
} catch (final ODataException e) {
logger.error(e.getMessage(), e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.getWriter().write(e.getMessage());
}
}
}
Best regards,
Ivan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.