Skip to content

Commit 0530b03

Browse files
committed
Switch to Process Orders API
1 parent faa9e06 commit 0530b03

11 files changed

Lines changed: 570 additions & 1160 deletions

File tree

META-INF/MANIFEST.MF

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Synchronize Production Plan
44
Bundle-SymbolicName: Synchronize_Production_Plan; singleton:=true
5-
Bundle-Version: 1.0.0
5+
Bundle-Version: 1.0.1
66
SAP-BundleType: RESTAPIProvider
77
SAP-NodeType: IFLMAP
88
SAP-RuntimeProfile: iflmap
@@ -34,4 +34,3 @@ Import-Package: com.sap.esb.application.services.cxf.interceptor,com.sap
3434
"
3535
Origin-Bundle-Name: Synchronize Production Plan
3636
Origin-Bundle-SymbolicName: Synchronize_Production_Plan
37-

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ interface SAP to Factbird.
99

1010
## Use cases
1111

12-
Import products
12+
Common use cases include:
1313

14-
Import Production orders
14+
- Import products into Factbird
15+
16+
- Import process orders into Factbird
17+
18+
- Manage process order execution from within Factbird (executing and terminating of a process order) ()

metainfo.prop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#Store metainfo properties
2-
#Thu Mar 27 23:54:29 UTC 2025
2+
#Sun Mar 30 21:58:52 UTC 2025
33
description=

src/main/resources/parameters.prop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#Thu Mar 27 23:48:11 UTC 2025
1+
#Sun Mar 30 21:58:24 UTC 2025

src/main/resources/scenarioflows/integrationflow/createProduct.iflw

Lines changed: 531 additions & 1124 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import com.sap.gateway.ip.core.customdev.util.Message;
2-
import java.util.HashMap;
3-
import groovy.json.*;
2+
import groovy.json.JsonSlurper;
43

54
def Message processData(Message message) {
65
def body = message.getBody(String.class);
76
def jsonSlurper = new JsonSlurper();
87
def payload = jsonSlurper.parseText(body);
98

109
message.setProperty("manufacturingOrder", payload.data.ManufacturingOrder);
10+
1111
return message;
1212
}

src/main/resources/script/script3.groovy

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,24 @@ def zipTimestampsIntoMillis(NodeChildren startDates, NodeChildren startTimes) {
3030
// https://api.cloud.factbird.com/v1/docs/#query-lines or a looped process call
3131
// against https://api.cloud.factbird.com/v1/docs/#query-linesPaginated (we have
3232
// not yet stabilized this latter one as of this writing)
33-
def lineIdMapping = [
34-
'1710': 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
33+
lineIdMapping = [
34+
'1710PACKING': 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
3535
]
3636

3737
def Message processData(Message message) {
38-
def productionOrder = new XmlSlurper().parseText(message.getProperty("productionOrder"))
39-
def productionOrderSerialNumber = new XmlSlurper().parseText(message.getProperty("productionOrderSerialNumber"))
38+
def processOrder = new XmlSlurper().parseText(message.getProperty("processOrder"))
4039

4140
def messageLog = messageLogFactory.getMessageLog(message);
4241
if (messageLog != null) {
43-
messageLog.addAttachmentAsString("productionOrder", message.getProperty("productionOrder"), "application/json");
44-
messageLog.addAttachmentAsString("productionOrderSerialNumber", message.getProperty("productionOrderSerialNumber"), "application/json");
42+
messageLog.addAttachmentAsString("processOrder", message.getProperty("processOrder"), "application/json");
4543
}
4644

4745
def builder = new JsonBuilder()
4846

4947
def output = []
5048

51-
productionOrder.A_ProductionOrder_2Type.each { order ->
52-
def serialNumber = productionOrderSerialNumber.children().find { type ->
53-
type.ManufacturingOrder.text() == order.ManufacturingOrder.text()
54-
}
55-
56-
if (!serialNumber) {
57-
return
58-
}
59-
60-
def released = order.to_ProductionOrderStatus.children().any { status ->
49+
processOrder.A_ProcessOrder_2Type.each { order ->
50+
def released = order.to_ProcessOrderStatus.children().any { status ->
6151
status.StatusShortName.text() == "SETC"
6252
//status.StatusShortName.text() == "REL"
6353
}
@@ -66,11 +56,11 @@ def Message processData(Message message) {
6656
return
6757
}
6858

69-
def operation = order.to_ProductionOrderOperation.A_ProductionOrderOperation_2Type
70-
71-
// Production Orders may propagate from one work center to another - we
59+
def operation = order.to_ProcessOrderOperation.A_ProcessOrderOperation_2Type
60+
61+
// Process Orders may propagate from one work center to another - we
7262
// simply make the assumption it'll remain at the same location.
73-
def initiallyAllocatedWorkCenter = order.WorkCenter[0]
63+
def initiallyAllocatedWorkCenter = operation.WorkCenter[0]
7464

7565
// With that same assumption, all operations are expected to take place
7666
// in order, so for actualStart and actualStop we find the extrema
@@ -86,7 +76,7 @@ def Message processData(Message message) {
8676
output << [
8777
externalLineId: order.Plant.text() + initiallyAllocatedWorkCenter.text(),
8878
batchNumber: order.ManufacturingOrder.text(),
89-
itemNumber: serialNumber.Product.text(),
79+
itemNumber: order.Material.text(),
9080
amount: order.TotalQuantity.text(),
9181
plannedStart: formatTimePair(order.MfgOrderPlannedStartDate.text(), order.MfgOrderPlannedStartTime.text()),
9282
actualStart: actualStart,
@@ -97,7 +87,7 @@ def Message processData(Message message) {
9787
def resultXml = new StringWriter()
9888
def xmlBuilder = new MarkupBuilder(resultXml)
9989

100-
xmlBuilder.'production-orders' {
90+
xmlBuilder.'process-orders' {
10191
output.each { row ->
10292
'order'(action: row.actualStop ? 'stop' : (row.actualStart ? 'start' : 'create')) {
10393
'line-id'(lineIdMapping[row.externalLineId])
@@ -112,6 +102,6 @@ def Message processData(Message message) {
112102
}
113103

114104
message.setBody(resultXml.toString())
115-
105+
116106
return message;
117107
}

src/main/resources/script/script4.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ def Message processData(Message message) {
1414
operationName: 'CreateBatchByItemNumber',
1515
variables: [
1616
input: [
17-
lineId: 'test',
17+
lineId: orders.order.'line-id'.text(),
18+
batchNumber: orders.order.'batch-number'.text(),
1819
itemNumber: orders.order.'item-number'.text(),
1920
amount: Float.parseFloat(orders.order.'amount'.text()),
20-
plannedStart: orders.order.plannedStart.text(),
21+
plannedStart: orders.order.'planned-start'.text(),
2122
]
2223
],
2324
query: 'mutation CreateBatchByItemNumber($input: CreateBatchByItemNumberInput!) { createBatchByItemNumber(input: $input) { __typename } }',
2425
])
2526

26-
// Set the generated JSON as the message body
2727
message.setBody(builder.toPrettyString())
2828

2929
return message;

src/main/resources/script/script5.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def Message processData(Message message) {
1414
operationName: 'StartBatchByBatchNumber',
1515
variables: [
1616
input: [
17-
lineId: 'test',
17+
lineId: orders.order.'line-id'.text(),
1818
batchNumber: orders.order.'production-order'.text(),
1919
actualStart: orders.order.'actual-start'.text(),
2020
forceStop: true

src/main/resources/script/script6.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def Message processData(Message message) {
1414
operationName: 'StopBatchByBatchNumber',
1515
variables: [
1616
input: [
17-
lineId: 'test',
17+
lineId: orders.order.'line-id'.text(),
1818
batchNumber: orders.order.'production-order'.text(),
1919
actualStop: orders.order.'actual-stop'.text(),
2020
]

0 commit comments

Comments
 (0)