You are on page 1of 11

SAP Cloud Platform Integration – Validators

Document History
Version No. Date Revision Description

0.1 10-Oct-2021 Draft

0.2 18-Oct-2021 Review

1.0 19-Oct-2021 Final version

Document Asset Team


Name Email

Ramanakumar Achukolu ramanakumar.achukolu@accenture.com

Vishwajeet Ahluwalia Vishwajeet.ahluwalia@accenture.com

Amit Kumar Jain amit.c.kumar.jain@accenture.com

Machindra Patade machindra.patade@accenture.com

Ramana kumar
Contents

1. Introduction ...................................................................................................................................... 2
2. XML Validator.................................................................................................................................... 2
a. Test Case 1: XML Validator ............................................................................................................... 2
b. Test Case 2: XML Validator ............................................................................................................... 5
3. EDI Validator: Scenario ..................................................................................................................... 8
4. Conclusion ....................................................................................................................................... 10
5. References ...................................................................................................................................... 10

pg. 1 Copyright © Accenture 2018 All Rights Reserved


1. Introduction
Validators check the content of the message against a defined schema in SAP CPI.
SAP Cloud Integration offers capabilities to validate the message payload against the configured XSD
schema.

2. XML Validator
XML Validator (version 1.x) can validate XML against the XSD schema 1.0. The XML validator validates
the message payload in XML format against the configured XML schema.

a. Test Case 1: XML Validator


Validate XML against XML Schema– Stop Message Processing on Validation Failure.

Consider a scenario where you want to stop processing the message as soon as the validation error
occurs.

You use this procedure to assign XML schema (XSD files) to validate the message payload in a process
step. The validator checks the message payload against configured XML schema, and report
discrepancies in message payload.

If the validation fails, the Cloud Integration system stops the whole message processing by default.

XML Validator: Browse the XSD and keep the Prevent Exception on Failure checkbox unchecked.

pg. 2 Copyright © Accenture 2018 All Rights Reserved


Exception Content Modifier: Enter the header in the Message Body of the Content Modifier as shown
below.

pg. 3 Copyright © Accenture 2018 All Rights Reserved


Run the scenario with a Validation error: You would see the exception from the Exception sub process as
shown below:

XSD follows:

CPI Message Monitoring in Trace Mode as shown below:

pg. 4 Copyright © Accenture 2018 All Rights Reserved


b. Test Case 2: XML Validator
Validate XML against XML Schema – Continue Message Processing During Validation Failure.
If you want to continue the processing even if the system encounters error while validating, then select
XML Validator : Prevent Exception on Failure checkbox

Create a router with a condition ${header.SAP_XmlValidationResult} != null to handle the scenarios in


case of validation failures .

Once Prevent Exception on Failure option is checked, the processing will continue processing without
throwing an exception. You can handle the validation error scenarios with a route condition as shown
below:

pg. 5 Copyright © Accenture 2018 All Rights Reserved


After Validation Error Content Modifier:

In the Error route content modifier add Validation Error Result: ${header.SAP_XmlValidationResult} in
the Message Body to capture the validation result.

Run the scenario with a Validation error:

XSD follows:

pg. 6 Copyright © Accenture 2018 All Rights Reserved


CPI Message Monitoring in Trace Mode as shown below:

NOTE: The Validation Result is also available as an attachment in the Message Processing Log.

pg. 7 Copyright © Accenture 2018 All Rights Reserved


3. EDI Validator: Scenario
The EDI Validator validates the message payload in EDI flat file format against the configured XSD
schema.
EDI Validator supports UN-EDIFACT, ODETTE and ASC-X12 document types. You use this procedure to
assign XSD files to validate the message payload in a process step. The validator checks the message
payload against configured XSD schema and throws an exception in case of discrepancy.

Source Encoding: Select encoding format for the incoming payload.

EDI Schema Definition: Select the source of schema definition.

pg. 8 Copyright © Accenture 2018 All Rights Reserved


Schemas: If you select Integration Flow as EDI Schema Definition, then you can see the table Schemas,
in Properties view. Select the valid schemas against which the validation will take place.

Note:

• You can add XSD files to the integration flow.

• The file name of the xml schema for EDI payloads should have the following format:

o EDIFACT: UN-EDIFACT_ORDERS_D96A.xsd

o ODETTE: ODETTE_ORDERR_2.xsd

o ODETTE EDIFACT: UN-EDIFACT_ORDERS_D96A_A18051.xsd

o EANCOM: UN-EDIFACT_ORDERS_D96A_EAN008.xsd

HeaderName: If you select Header as EDI Schema Definition, then you can see the field HeaderName,
in Properties view. Enter a valid header for the field.

Note:
This header name is fetched from camel header. The header is added in script element. This script
element is added before converter element. You can add value for this header in the script element.

For example, you can add the value, /xsd/UN-EDIFACT_ORDERS_D96A.xsd for EDIFACT.

pg. 9 Copyright © Accenture 2018 All Rights Reserved


For example, you can add the value, /xsd/ASC-X12_810_004010.xsd for ASC-X12.

Prevent Exception on Failure:


If you want to continue the processing even if the system encounters error while validating, then select
this parameter. If an exception occurs, then the error payload is added
to SAP_EDIValidationResult header.

4. Conclusion
The document provides an overview of ways to use of Validator in SAP CPI.

5. References

• https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-
US/20e23e7893fb498480cf52355e09343d.html
• https://blogs.sap.com/2018/09/18/cloud-integration-working-with-xml-validator/

pg. 10 Copyright © Accenture 2018 All Rights Reserved

You might also like