Context Objects are a great alternative to Xpath expressions in SAP PI/PO. When creating Xpath based (Content Based) Receiver Rules or Receiver Conditions in Integration Directory, sometimes rules can becomes unreadable and complex due to the long Xpaths. Context Objects allows us to represent a Xpath with easily readable Context Names and reuse them in Receiver Rules and Receiver Conditions.
SAP Versions used in the illustration:
- SAP PO 7.5
Example Use of Context Object.
Lets assume we have a XML file sender and we want to create a Content Based Receiver Rules or a Condition based on Xpath ‘FlightBookingOrderRequest/AgencyData/AgencyID’.
If Xpath ‘FlightBookingOrderRequest/AgencyData/AgencyID’ equals to ‘AA’ receiver should be ‘Test_B’.
Step 1: Create Context Object for ‘AgencyID’.
Create Context Object and assign the Reference Type property based on the XML element. AgencyID is a String element, therefore we assign the reference Type of the Context Object as xsd:string.
Step 2: Assign Context Object to Outbound Service Interface.
Assign the Context Object created in step 1 to corresponding Xpath of the Message Type or External Definition in Outbound Service Interface. Make sure your Outbound Service Interface is of Interface Pattern ‘Stateless (XI30 – Compatible)’. Context Objects are only compatible with Interface Pattern ‘Stateless (XI30 – Compatible)’.
Use the drop down list to select the Context Object. Once Context Object is correctly assigned, it would be shown under Context Object Column with the data element.
Step 3: Use the Context Object in Integration Directory for Receiver Rule or Content Based Rule.
Now you can use Context Object ‘AgencyID’ instead of full Xpath for Content Based Receiver Determination in Integration Directory. Use the down down list to select the Context Objects created in Enterprise Service Repository (ESR).
If you cannot view the Context Objects created in ESR in ID, make sure you have assigned the Context Object assigned to the Outbound Service Interface and Interface is in Interface Pattern XI30 – Compatible as shown in Step 2.
Please leave a comment if you have any questions on Context Objects.
Hi
Your blogs are so good
Can you share how to learn Java mapping.
Hi Sai, I will try to include a post about Java Mappings in the future. Just to give a basic idea, java mapping is mostly used for complex mapping which cannot be handled by graphical mapping alone or if the performance is a main priority. Also if you have a complex mapping, you can handle the complex logic first using a java mapping and then do a graphical mapping as the step 2.
Thank you Sir eagerly waiting for some more interesting blogs.please cover all the topics which are difficult to understand in SAP PO/PI.
What is the difference here context object and X path ?
Hi Rao,
Context Object is a one of methods to use Xpath conditions.
Cheers!
your blog was so good.
about Java Mappings could you please give a basic idea, java mapping is mostly used for complex mapping .
Hi Dasthagiti,
Subscribe to email updates to get notified when I write new content. I will try my best to include more Java Mapping content.
Cheers!
Context object create in esr OK fine.
Now X path create in id but it’s not taking particular field
Hi Krishna,
Seems like an issue with cache, try again after clearing cache.
Cheers!
Isuru
Hi Fernando,
Can we use Context Objects for two fields with the same Service Interface?
Example: I want to determine Receiver when A=1 and B=2 with very long Xpath, can I use Context Objects in this requirement.
Best Regards,
Kishore.
Hi Kishore,
Yes, you can have more than one context objects in the same service interface.
Regards,
Isuru
Hi Isuru,
I have a scenario from IDOC to multiple receivers in single stack PO7.5. Can you tell me how can i achieve this using context object?
Regards,
Prameela