cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CPI Production Order Creation Fails Due to Invalid Time Format in OData Response

JonathanR
Explorer
335

Hi team,

I'm working on a SAP CPI iFlow that creates production orders in SAP S4H, using the Production Order (Version 2) API.

I started by testing the connection between CPI and SAP, so I only have a Content Modifier with the payload and a Request Reply to connect to the OData adapter.

The payload is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<A_ProductionOrder_2>
<A_ProductionOrder_2Type>
<ManufacturingOrderType>ZP01</ManufacturingOrderType>
<Material>SG002</Material>
<ProductionPlant>3516</ProductionPlant>
<MRPController>001</MRPController>
<MfgOrderPlannedStartDate>2024-09-15T00:00:00</MfgOrderPlannedStartDate>
<MfgOrderPlannedStartTime>00:00:00</MfgOrderPlannedStartTime>
<MfgOrderPlannedEndDate>2024-09-16T00:00:00</MfgOrderPlannedEndDate>
<MfgOrderPlannedEndTime>00:00:00</MfgOrderPlannedEndTime>
<ProductionUnit>PC</ProductionUnit>
<TotalQuantity>10</TotalQuantity>
</A_ProductionOrder_2Type>
</A_ProductionOrder_2>

With this payload, I'm successfully creating production orders, so it doesn't seem like the payload is incorrect. However, CPI is always returning the following error:

com.sap.gateway.core.ip.processor.exception.ODataProcessingException: com.sap.gateway.core.ip.processor.exception.ODataProcessingException: Exception occurred in converting [class java.util.GregorianCalendar] with value [java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=false,zone=sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=?,YEAR=?,MONTH=?,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=?,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=24,MINUTE=0,SECOND=0,MILLISECOND=?,ZONE_OFFSET=?,DST_OFFSET=?]] to String., cause: java.lang.IllegalArgumentException: HOUR_OF_DAY

I believe the issue is related to two tags in the Request Reply response: MfgOrderPlannedEndTime and MfgOrderScheduledEndTime, with the value PT24H00M00S. It seems that java.util.GregorianCalendar only accepts hours in the range of 0-23, but according to SAP documentation, the hour 24:00 is allowed (which seems incorrect to me).

I'm struggling to find a solution for this issue, as it seems to be a very basic error.

Thanks in advance for your help.

Ryan-Crosby
Active Contributor
0 Kudos
CPI is throwing an error during what process? You mentioned that it's creating production orders so where is your flow failing?

Accepted Solutions (0)

Answers (1)

Answers (1)

JonathanR
Explorer
0 Kudos

Here

JonathanR_0-1726231963158.png

 

orhantas1
Discoverer
0 Kudos
Did you find any solution for this issue ? I have the same problem when I get the data of production order API with API_PRODUCTION_ORDER_2 ?
JonathanR
Explorer
0 Kudos
Not really, did you?
fedmarin
Explorer
0 Kudos

Hi, I think you need to read Help Portal SAP Documentation: https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/a6f0333202384ba2b48a841a4a6deb1b/d979183f4d01446d89e....
In particular, you have to specify BasicSchedulingType and maybe you have to put fields in the correct order (I'm not sure about that).

fedmarin
Explorer
0 Kudos

I've solved by calling the API via HTTP, pay attention to CSRF validation and etag header.

This guide helped me a lot: https://community.sap.com/t5/technology-q-a/csrf-token-validation-failed/qaq-p/12524895