Node Functions ‘Collapse Context’ and ‘Remove Context’ can be confusing if you are new to PI/PO space. Although Collapse Context and Remove Context have similarities, there are a few major differences between them.
SAP Versions used in the illustration:
- SAP PO 7.5
What is a Context in PI?
Before we look at the differences between Collapse Context and Remove Context, let’s look at what a ‘Context’ in PI/PO means.
XML messages in PI are handled as Queues. In a queue, Context is the position or the level of a XML node (element) relative to a parent node. If elements belong to the same parent node, the elements are in same Context. When the parent node changes, Context Change is inserted to the queue. Context Changes are shown in dark gray color.
Therefore, when we talk about Context of a message it is always based on a certain parent node. An XML element can have different Context queues depending on the parent node it is related to.
Let’s use the Message Type below to understand Context Changes and Node Functions.
XML can have multiple exam grades of multiple students.
Element ‘Grade’ context changes based on immediate parent node ‘Grades’.
Grade values of each exam are assigned to separate Contexts.
Element ‘Grade’ Context Changes based on higher level parent node ‘StudentDetail’.
Now all grades of each student are in one Context.
Collapse Context vs Remove Context.
Although the two node functions behave differently, both Collapse Context and Remove Context delete the Context Changes from the input queue.
1. How Context Values are Copied in Collapse and Remove Context.
The major difference between these two functions is how they copy input Context values to the output. While Collapse Context only copies first value of each Context from the input, Remove Context copies all the values from the input to output.
|Only first value of each context is copied to the output.||All values form input context are copied to the output.|
2. How SUPPRESS Values Are Interpreted by Collapse Context and Remove Context When “Keep SUPPRESS Values” Are Disabled.
Let’s look at how each function acts when “keep SUPPRESS values” property of IF-THEN function is disabled.
Another difference is how these node functions handle SUPPRESS values in queues. While Remove Context ignores the SUPPRESS values and does not copy them to output, Collapse Context copies them as null  values to output.
Collapse Context copies SUPPRESS Values as .
Remove Context ignores SUPPRESS Values.
3. How SUPPRESS Values Are Interpreted by Collapse Context and Remove Context When “Keep SUPPRESS Values” Is Activated.
In this situation both functions handle SUPPRESS values the same way. SUPPRESS values are considered similar to any another value in the same context.
Both functions remove the Context Changes. Collapse Context function copies the first value from each Context, and Remove Context copies all values of each context to output.
You can only remove these SUPPRESSED values using a UDF.
If you have any questions about Collapse Context and Remove Context node functions, please, leave a comment below. I will be happy to help.