Time,Sales Entity,Month,Invoice Customer Code,Article Code,Allocation Code,Planning Type,Preferred Site,Preferred Warehouse,Vendor Account,Final Commercial Forecast,Commercial Forecast Lag 3M,Commercial Forecast Production Program
22-Mar,BE03,202205,300612,10000155,,STS,0241,27,BE03,500,1049,648
22-Mar,BE03,202205,300612,20000155,,STS,0241,27,BE03,501,1049,648
22-Mar,BE03,202208,300612,10000157,,STS,0241,27,BE03,500,1049,648
22-Mar,BE03,202209,300612,10000158,,STS,0241,27,BE03,501,1049,648
<root>
<row>
<Product>10000155</Product>
<Plant>0241</Plant>
<PlndIndepRqmtType>VSF</PlndIndepRqmtType>
<PlndIndepRqmtVersion>00</PlndIndepRqmtVersion>
<RequirementPlan/>
<RequirementSegment/>
<RequirementPlanIsExternal>false</RequirementPlanIsExternal>
<PlndIndepRqmtIsActive>X</PlndIndepRqmtIsActive>
<PlndIndepRqmtPeriod>202205</PlndIndepRqmtPeriod>
<PeriodType>M</PeriodType>
<PlannedQuantity>500</PlannedQuantity>
<WithdrawalQuantity>0</WithdrawalQuantity>
<UnitOfMeasure>KG</UnitOfMeasure>
</row>
<row>
<Product>10000155</Product>
<Plant>0241</Plant>
<PlndIndepRqmtType>VSF</PlndIndepRqmtType>
<PlndIndepRqmtVersion>00</PlndIndepRqmtVersion>
<RequirementPlan/>
<RequirementSegment/>
<RequirementPlanIsExternal>false</RequirementPlanIsExternal>
<PlndIndepRqmtIsActive>X</PlndIndepRqmtIsActive>
<PlndIndepRqmtPeriod>202205</PlndIndepRqmtPeriod>
<PeriodType>M</PeriodType>
<PlannedQuantity>501</PlannedQuantity>
<WithdrawalQuantity>0</WithdrawalQuantity>
<UnitOfMeasure>KG</UnitOfMeasure>
</row>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<Product>10000155</Product>
</row>
<row>
<Product>10000155</Product>
</row>
</root>
<batchParts>
<batchChangeSet>
<batchChangeSetPart>
<method>POST</method>
<PlannedIndepRqmt>
<PlannedIndepRqmtType>
<Product>10000155</Product>
<Plant>0241</Plant>
<MRPArea/>
<PlndIndepRqmtType>VSF</PlndIndepRqmtType>
<PlndIndepRqmtVersion>00</PlndIndepRqmtVersion>
<RequirementPlan/>
<RequirementSegment/>
<RequirementPlanIsExternal>false</RequirementPlanIsExternal>
<PlndIndepRqmtIsActive>X</PlndIndepRqmtIsActive>
<to_PlndIndepRqmtItem>
<PlannedIndepRqmtItemType>
<Product>10000155</Product>
<Plant>0241</Plant>
<MRPArea/>
<PlndIndepRqmtType>VSF</PlndIndepRqmtType>
<PlndIndepRqmtVersion>00</PlndIndepRqmtVersion>
<RequirementPlan/>
<RequirementSegment/>
<PlndIndepRqmtPeriod>202205</PlndIndepRqmtPeriod>
<PeriodType>M</PeriodType>
<PlannedQuantity>500</PlannedQuantity>
<WithdrawalQuantity>0</WithdrawalQuantity>
<UnitOfMeasure>KG</UnitOfMeasure>
</PlannedIndepRqmtItemType>
</to_PlndIndepRqmtItem>
<link>
<to_PlndIndepRqmtItem>
<PlannedIndepRqmtItemType>
<Product>10000155</Product>
<Plant>0241</Plant>
<MRPArea/>
<PlndIndepRqmtType>VSF</PlndIndepRqmtType>
<PlndIndepRqmtVersion>00</PlndIndepRqmtVersion>
<RequirementPlan/>
<RequirementSegment/>
<PlndIndepRqmtPeriod>202205</PlndIndepRqmtPeriod>
<PeriodType>M</PeriodType>
</PlannedIndepRqmtItemType>
</to_PlndIndepRqmtItem>
</link>
</PlannedIndepRqmtType>
</PlannedIndepRqmt>
</batchChangeSetPart>
</batchChangeSet>
<batchChangeSet>
<batchChangeSetPart>
<method>POST</method>
<PlannedIndepRqmt>
<PlannedIndepRqmtType>
<Product>10000155</Product>
<Plant>0241</Plant>
<MRPArea/>
<PlndIndepRqmtType>VSF</PlndIndepRqmtType>
<PlndIndepRqmtVersion>00</PlndIndepRqmtVersion>
<RequirementPlan/>
<RequirementSegment/>
<RequirementPlanIsExternal>false</RequirementPlanIsExternal>
<PlndIndepRqmtIsActive>X</PlndIndepRqmtIsActive>
<to_PlndIndepRqmtItem>
<PlannedIndepRqmtItemType>
<Product>10000155</Product>
<Plant>0241</Plant>
<MRPArea/>
<PlndIndepRqmtType>VSF</PlndIndepRqmtType>
<PlndIndepRqmtVersion>00</PlndIndepRqmtVersion>
<RequirementPlan/>
<RequirementSegment/>
<PlndIndepRqmtPeriod>202205</PlndIndepRqmtPeriod>
<PeriodType>M</PeriodType>
<PlannedQuantity>501</PlannedQuantity>
<WithdrawalQuantity>0</WithdrawalQuantity>
<UnitOfMeasure>KG</UnitOfMeasure>
</PlannedIndepRqmtItemType>
</to_PlndIndepRqmtItem>
<link>
<to_PlndIndepRqmtItem>
<PlannedIndepRqmtItemType>
<Product>10000155</Product>
<Plant>0241</Plant>
<MRPArea/>
<PlndIndepRqmtType>VSF</PlndIndepRqmtType>
<PlndIndepRqmtVersion>00</PlndIndepRqmtVersion>
<RequirementPlan/>
<RequirementSegment/>
<PlndIndepRqmtPeriod>202205</PlndIndepRqmtPeriod>
<PeriodType>M</PeriodType>
</PlannedIndepRqmtItemType>
</to_PlndIndepRqmtItem>
</link>
</PlannedIndepRqmtType>
</PlannedIndepRqmt>
</batchChangeSetPart>
</batchChangeSet>
</batchParts>
<batchPartResponse>
<batchChangeSetResponse>
<batchChangeSetPartResponse>
<headers>
<Accept></Accept>
<Accept-Language></Accept-Language>
<Content-Length>1594</Content-Length>
<dataserviceversion>1.0</dataserviceversion>
<Content-Type>application/xml;charset=utf-8</Content-Type>
</headers>
<statusInfo>Bad Request</statusInfo>
<contentId/>
<body><?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>PPH_FCDM/033</code><message xml:lang="en">Material &amp;000000000010040155&amp; in Plant &amp;0241&amp; or MRP Area not defined</message><innererror><application><component_id>PP-MRP</component_id><service_namespace>/SAP/</service_namespace><service_id>API_PLND_INDEP_RQMT_SRV</service_id><service_version>0001</service_version></application><transactionid>75592a5cc25d40f2924ec2b4538ca465</transactionid><timestamp/><Error_Resolution><SAP_Transaction/><SAP_Note>See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)</SAP_Note><Batch_SAP_Note>See SAP Note 1869434 for details about working with $batch (https://service.sap.com/sap/support/notes/1869434)</Batch_SAP_Note></Error_Resolution><errordetails><errordetail><ContentID/><code>PPH_FCDM/033</code><message>Material &amp;000000000010040155&amp; in Plant &amp;0241&amp; or MRP Area not defined</message><propertyref/><severity>error</severity><target>MRPArea</target><additionalTargets><target>Plant</target><target>Product</target></additionalTargets><transition>true</transition></errordetail><errordetail><ContentID/><code>PPH_FCDM/033</code><message>Material &amp;000000000010040155&amp; in Plant &amp;0241&amp; or MRP Area not defined</message><propertyref/><severity>error</severity><target>MRPArea</target><additionalTargets><target>Plant</target><target>Product</target></additionalTargets><transition>true</transition></errordetail></errordetails></innererror></error></body>
<statusCode>400</statusCode>
</batchChangeSetPartResponse>
</batchChangeSetResponse>
<batchChangeSetResponse>
<batchChangeSetPartResponse>
<headers>
<Accept></Accept>
<Accept-Language></Accept-Language>
<Content-Length>1594</Content-Length>
<dataserviceversion>1.0</dataserviceversion>
<Content-Type>application/xml;charset=utf-8</Content-Type>
</headers>
<statusInfo>Bad Request</statusInfo>
<contentId/>
<body><?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>PPH_FCDM/033</code><message xml:lang="en">Material &amp;000000000010040155&amp; in Plant &amp;0241&amp; or MRP Area not defined</message><innererror><application><component_id>PP-MRP</component_id><service_namespace>/SAP/</service_namespace><service_id>API_PLND_INDEP_RQMT_SRV</service_id><service_version>0001</service_version></application><transactionid>75592a5cc25d40f2924ec2b4538ca465</transactionid><timestamp/><Error_Resolution><SAP_Transaction/><SAP_Note>See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)</SAP_Note><Batch_SAP_Note>See SAP Note 1869434 for details about working with $batch (https://service.sap.com/sap/support/notes/1869434)</Batch_SAP_Note></Error_Resolution><errordetails><errordetail><ContentID/><code>PPH_FCDM/033</code><message>Material &amp;000000000010040155&amp; in Plant &amp;0241&amp; or MRP Area not defined</message><propertyref/><severity>error</severity><target>MRPArea</target><additionalTargets><target>Plant</target><target>Product</target></additionalTargets><transition>true</transition></errordetail><errordetail><ContentID/><code>PPH_FCDM/033</code><message>Material &amp;000000000010040155&amp; in Plant &amp;0241&amp; or MRP Area not defined</message><propertyref/><severity>error</severity><target>MRPArea</target><additionalTargets><target>Plant</target><target>Product</target></additionalTargets><transition>true</transition></errordetail></errordetails></innererror></error></body>
<statusCode>400</statusCode>
</batchChangeSetPartResponse>
</batchChangeSetResponse>
</batchPartResponse>
import com.sap.gateway.ip.core.customdev.util.Message
import groovy.xml.MarkupBuilder
import java.time.LocalDate
import java.time.format.DateTimeFormatter
Message processData(Message message) {
// Access message body and properties
Reader reader = message.getBody(Reader)
def messageLog = messageLogFactory.getMessageLog(message);
def mapProperties = message.getProperties();
def valueProperty = mapProperties.get("ListItems");
// Define XML parser and builder
def feed = new XmlParser().parseText(valueProperty)
def i=0;
def lista = feed.row.'*'.findAll{ node->
node.name() == 'Product' }*.text()
def errorLog = "<root>";
def root = new XmlSlurper().parse(reader);
int y =0;
root.batchChangeSetResponse.each {
y = y+1;
statusCode = "${it.batchChangeSetPartResponse.statusInfo}";
if(statusCode != "Created") {
errorLog = errorLog + "<error>"+"<Product>"+lista[y-1]+"</Product>"+"${it.batchChangeSetPartResponse.body}"+"</error>";
ErrorFoundFlag = 'ErrorFound';
message.setProperty("ErrorFoundFlag", ErrorFoundFlag);
removal = errorLog;
removal=removal.replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>","");
errorLog = removal;
}
}
errorLog = errorLog + "</root>";
message.setBody(errorLog);
return message;
}
<root>
<error>
<Product>10040155</Product>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>PPH_FCDM/033</code>
<message xml:lang="en">Material &000000000010040155& in Plant &0241& or MRP Area not defined</message>
<innererror>
<application>
<component_id>PP-MRP</component_id>
<service_namespace>/SAP/</service_namespace>
<service_id>API_PLND_INDEP_RQMT_SRV</service_id>
<service_version>0001</service_version>
</application>
<transactionid>75592a5cc25d40f2924ec2b4538ca465</transactionid>
<timestamp/>
<Error_Resolution>
<SAP_Transaction/>
<SAP_Note>See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)</SAP_Note>
<Batch_SAP_Note>See SAP Note 1869434 for details about working with $batch (https://service.sap.com/sap/support/notes/1869434)</Batch_SAP_Note>
</Error_Resolution>
<errordetails>
<errordetail>
<ContentID/>
<code>PPH_FCDM/033</code>
<message>Material &000000000010040155& in Plant &0241& or MRP Area not defined</message>
<propertyref/>
<severity>error</severity>
<target>MRPArea</target>
<additionalTargets>
<target>Plant</target>
<target>Product</target>
</additionalTargets>
<transition>true</transition>
</errordetail>
<errordetail>
<ContentID/>
<code>PPH_FCDM/033</code>
<message>Material &000000000010040155& in Plant &0241& or MRP Area not defined</message>
<propertyref/>
<severity>error</severity>
<target>MRPArea</target>
<additionalTargets>
<target>Plant</target>
<target>Product</target>
</additionalTargets>
<transition>true</transition>
</errordetail>
</errordetails>
</innererror>
</error>
</error>
</root>
def root = new XmlSlurper().parse(reader);
int y =0;
def ErrorFoundFlag = "";
def status = "";
root.error.each {
errorLog = errorLog + "<error>"+"<Product>"+lista[y-1]+"</Product>"+"<Message>"+"${it.error.message}"+"</Message>"+"</error>";
ErrorFoundFlag = 'ErrorFound';
message.setProperty("ErrorFoundFlag", ErrorFoundFlag);
}
errorLog = errorLog + "</root>";
message.setBody(errorLog);
if(ErrorFoundFlag.contains('ErrorFound'))
{
messageLog.addAttachmentAsString("POST Call Errors", errorLog, "text/plain");
}
return message;
}
<root>
<error>
<Product>10000155</Product>
<Message>Invalid period name for period type</Message>
</error>
<error>
<Product>20000155</Product>
<Message>Material &000000000020000155& in Plant &0241& or MRP Area &0241& not defined</Message>
</error>
</root>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
16 | |
9 | |
9 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 |