SAP CPI (Cloud Platform Integration
Create a Trial BTP account and initial Setup.
    Follow below blog to create your Trial BTP account and Initial setup for Cloud Platform
    Integration.
    Trial Account Setup for SAP Integration Suite
    What is SAP CPI?
    It’s a tool that facilitates seamless communication and integration between different
    applications system and data sources within an organization.
    SAP CPI enabling Cloud, integrates data Cloud services, integration across on-premise
    and mobile applications by consolidating, processing and publishing data quickly and
    securely.
    Why is SAP CPI used?
          Cloud Integration
          simplified connectivity
          Data transformation and Mapping
          Real-time Monitoring and Analytics
          security and compliance
          Scalability and Flexibility
    Key Components of SAP CPI?
          Integration flow Design
          Pre-built Adapters
          Monitoring and Administrator tools
          Graphical Mapping tool
          Deployment options
    Key Benefits?
          Reduced integration costs
          Improved Productivity
          Enhanced Agility and Analytics
          Real time Monitoring
    Public Cloud Services Provides:
          Amazon Web Services (AWS)
          Microsoft Azure
          Google Cloud Platform (GCP)
       Benefits of Cloud Computing:
1
          Faster Deployment
          Access to innovation
          Agile deployment configuration
          Lower TCO & faster time to value
       Cloud Computing providers offer their services according to different models-
          Infrastructure as a service (IaaS)
           Example: Google drive, SAP converged Cloud
          Platform as a service (PaaS)
               Example: CPI, wix.com
          Software as a service (Saas)
               Example: Success Factor, Ariba, Concur
    Sender and Receiver:
    The sender represents the system that initiates the data transmission while the receiver
    is the system that receives the data.
    The sender is the source of the message, and the receiver is the target system where the
    message is delivered.
    The sender is connected to the start of the Iflow and sends data to the integration
    process. While the receiver is connected to the end of the Iflow and receives the
    processed data.
    Sender is act like our outbound message and receiver is inbound message.
    Adapters:
    Adapters are used to connect different systems and applications.
    HTTPS Adapter: A lightweight adapter that can exchange data between systems over
    HTTPS protocols. It supports various message formats, including XML, JSON and plain
    text.
    IDOC: The IDOC adapter enables SAP Cloud integration to exchange intermediate
    document (IDoc) messages with systems that support web communication via SOAP
    services.
    OData: Allows users to communicate with an OData API using the OData protocol.
    SFTP (Secure File Transfer protocol): The SFTP Adapter connects an Integration tenant to
    a remote system using the SSH (Secure Shell) file transfer protocol system to write files
    to the system.
    Definition - SFTP adapter to encrypt and exchange sensitive business data between
    trading partners.
2
    (RFC) Remote Function Call: It is a standard SAP interface that allows communication
    between SAP systems and other systems. It enables the exchange of data and execution
    of functions in remote systems.
    SOAP(Simple Object Access Protocol) Adapter: It allows you to exchange SOAP messages
    between remote clients or web services server and the integration server and supports
    security setting for signing and verifying the SOAP body.
            SOAP Adapter is based on XML.
            We can use SOAP Adapters to consume web services that are secured by a
             Security Token Service (STS).
    when select SOAP Adapter so it gives us 2 options-
    1) SAP RM ( Connect SAP system)
    2) SOAP 1.x (Connect third party application)
    SOAP Processing Setting:
       1. Robust : If you want to get request and response. once you send the request you
          want the response then to go for robust.
       2. WS Standard: If you don't want to see any response to the client to go for the WS
          Standard.
    WSDL:
    Web Services Description language (WSDL) file for a SOAP Call, SOAP is the standard
    format for web services.
    CSRF:
    For fetch the token we’ve to use HEAD in postman.
    HEAD        API will be written here
    Key         Value
    x-csrf     Fetch
    Why have we expose endpoint?
    Exposing an endpoint allows external applications or systems to access and interact with
    an integration flow.
    Types of Integration Process:
    Integration process: To define the steps to process the message transfer between sender
    and receiver system.
    Local Integration process: To simplify the integration process we can break down the
    main integration into smaller fragments by using local integration process.
3
    Exception subprocess: To catch any exceptions thrown in the integration process and
    handle them.
    Events:
    Start Message and End Message: “Start Message” event marks the beginning of a
    message processing flow.  While an “End Message” event indicates the end of the flow,
    sending the processed message to the receiver.
    Error Start and Error End: “Error Start and Error End” can be used only within an
    exception sub-process.
    Timer Start: An integration flow to automatically start and run on a particular schedule.
    Terminate Message: A Terminate Message event stops further processing of a message.
    Synchronous and Asynchronous:
    Synchronous: The message flow waits for a response from the receiver
    (Acknowledge receive to sender)
    Asynchronous: The SAP application does not wait for a response from the receiver.
    (Acknowledge does not receive to sender)
    Content Modifier:
    We use the Content Modifier step to modify the content of the incoming message by
    providing additional information in the header or body of the message.
    Data type: java.lang.String
    Headers: Headers can be access outside of the CPI. We can use headers to provide
    authorization.
    Exchange Property: We can create property to use values within Iflow.
    JSON to XML Converter:
    Why we add root element?
    It acts as the top-level container for all other elements defining the overall structure of
    the document and ensuring that there is only one parent element for every other
    element within the xml file.
    Why we use namespace mapping?
    To prevent naming conflicts between element and attributes from different sources by
    associating them with unique identifiers.
    XML to JSON Converter:
4
    Suppress Json root element: we can check this option when we want Json response
    without root element.
    Streaming: To convert a single-line item into an array form.
    Request Reply:
    To allows a user to call an external system and receive a response.
    Send Pallet:
    Using send pallet for sending mail. It acts like request reply.
    Message Mapping:
    A process that transforms data between systems by mapping fields between messages.
    In simple words use message mapping for converting one structure to another structure.
    Why isn’t message mapping working without root?
    Because it is not receiving the header node.
    Value Mapping:
    Value mapping is used to translate source values into target values during data
          integration.
    Splitter:
    A splitter is used to break message into smaller parts that can be processed
            independently.
    Grouping: The size of the groups into which the composite message is to be split.
    For example, if a message has 10 nodes and grouping is defined as 2, the message is
           split into 5
    messages with 2 nodes each.
    Streaming: Select this option if you want to stream the process of splitting a large
    composite message.
    If you activate streaming, the system already starts processing parts (chunks) of the
    composite message before the message is fully transferred to the memory (of the
    runtime node).
5
    If you deactivate this option, the message is transferred fully to the memory before it is
            split and processed
    further. Deactivating streaming is more memory-intensive than activating it.
    General Splitter: Split a message into individual messages, while preserving the context
          of the root nodes.
    Iterating Splitter: Splits a general document into its constituent elements but does not
    include the enclosing tags in the individual messages.
    How to Create Service Key?
         1. Go to the instance and subscriptions.
         2. Now here we’ve to create instance.
         3. After Create the instance we’ll create service key.
    * In instance we’ve to choose SAP Process Integration Process Service.
     HTTP Status Codes:
     1    200          Success/Ok
     2    201          Created
     3    203          Non-Authoritative Information
     4    401          Unauthorized
     5    403          Forbidden
     6    404          Not Found
     7    500          Internal Server Error
     8    502          Bad Gateway
     9    503          Service Unavailable
     1    504          Gateway Timeout
     0
     1    415          Unsupported Media
     1
    XSD File:
    An "XSD file" stand for "XML Schema Definition" file, which essentially defines the
    structure and data used types of an XML message used in integration flows, allowing for
    data validation and ensuring the consistency of data exchanged between different
    systems the integration process.
    An XSD file specifies the element, attributes, and their data types within an XML
    message, acting like a blueprint for How the data should be organized.
    Validation Tool: By using an XSD, CPI can Validate incoming XML message against the
    defined structure, identifying any errors or in the data.
    XSD files are crucial for creating message mappings in CPI. where you transform data
    from format (e.g. an external system) to another based on the defined structure.
    OData:
    The OData adapter allows you to communicate with an OData protocol. you can use
    messages in ATOM or JSON format for Communication.
6
    Host:
    This is the IP address of the server hosting the OData service.
    Port:
    The port number on which the OData service is listening. The default ports are 80 for http
    and 443 for https.
    Path:
    This is the base path for the service. it identifies the service and OData and specifies the
    namespace for the entities exposed by the service.
    Sublevel:
    A Sublevel typically refers to the depth of nested entities or related data that can be
    expanded in an OData query.
    Entity:
    An "entity" represents a single, structured record of data, like a customer or product.
    (Set of Records)
    Proxy type:
    Internet: Internet proxy type is Suitable when your OData service is externally hosted or
    available on the internet. it allows the adapter to communicate with the service over the
    public network.
    On-premise: The on-premise proxy type is suitable for Scenarios where the OData service
    is hosted within your organization’s network.
    Metadata Document:
    When you access the URL in your step-1, typically the service will respond with metadata
    about the available entity sets, properties. relationships and operations exposed by the
    service.
    "The metadata document describes the Structure and capabilities of OData service,
    allowing the clients to understand how to interact with it programmatically.
    In summary, when you access the full URL, you'll receive metadata and information
    about the available resources and operations provided by the OData service.
7
    *.edmx is the extension of metadata.
    EDMX (Entity Data Model XSD):
    EDMX is an XML-based file that encapsulates the metadata of an OData service. it
    includes information about entities, properties, relationship and other aspects of the
    services data model.
    XSLT Mapping:
    "Extensible Stylesheet Language Transformations" mapping refers to the process of using
    XSLT to transform and map data between different formats during integration scenarios.
    XSLT is a language used to transform XML structure into various format.
    XSLT mapping is a powerful tool in SAP CPI that enables you to manage complex data
    transformations and mapping in integration scenarios, easing seamless communication
    between different systems with varying data formats.
    Let's say your source XML looks like this:
    <employee>
      <name>John</name>
      <age>30</age>
    </employee>
    You want to transform it into:
    <person>
      <fullName>John</fullName>
      <years>30</years>
    </person>
    Then your XSLT would look like:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" indent="yes"/>
      <xsl:template match="/employee">
        <person>
          <fullName><xsl:value-of select="name"/></fullName>
          <years><xsl:value-of select="age"/></years>
        </person>
8
      </xsl:template>
    </xsl:stylesheet>
    Code Explanation (Element-by-Element)
    1. <?xml version="1.0" encoding="UTF-8"?>
         What it does: Declares this document as an XML file.
         Why it's important: Ensures it’s interpreted correctly by XML processors.
    2.                   <xsl:stylesheet                                version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         What it does: Defines the document as an XSLT stylesheet.
         version="1.0": Specifies the version of XSLT you're using (1.0 in SAP CPI).
         xmlns:xsl=...: Declares the xsl namespace. All XSLT commands use this
          prefix.
    3. <xsl:output method="xml" indent="yes"/>
         What it does: Tells the processor how to output the result.
         method="xml": Output should be in XML format.
         indent="yes": Makes the output pretty-printed (readable with line breaks
          and spaces).
    4. <xsl:template match="/employee">
         What it does: Starts a template rule for the <employee> element.
         match="/employee": This template will run when the root element is
          <employee>.
         Think of it as: “When you find an <employee> element, apply this block
          of transformation.”
    5. <staff> (inside the template)
         What it does: This creates the root of the output structure.
         New tag: It’s not coming from the source; you define this to match the
          target structure.
9
     6. <staffId><xsl:value-of select="id"/></staffId>
            What it does:
                o   Creates a <staffId> element in the output.
                o   Fills it with the value of the <id> element from the input.
            xsl:value-of select="id": Selects the <id> inside the current <employee>
             context.
     7. <fullName><xsl:value-of select="name"/></fullName>
            Same as above: Takes <name> from input and maps it to <fullName>.
     8. <division><xsl:value-of select="department"/></division>
            Maps the <department> from source to <division> in output.
     9. </xsl:template>
            Ends the transformation template for <employee>.
     10. </xsl:stylesheet>
            Ends the XSLT document.
     JSON:
     JavaScript Object Notation (JSON) is a standard text-based format for representing
     structured data based on JavaScript object syntax.
     JSON Object:
            JSON object literals are surrounded by curly braces.
            JSON object literals contain Key/Value pairs.
            Keys and Values are separated by a colon.
     JSON Arrays:
     JSON arrays values must be type string, number object, array, boolean or null.
10
     XML:
     XML (Extensible Markup Language) is a way to store and exchange data between
     systems. It's a file format that can be read by both humans and computers.
     XML Schema:
     An XML schema describes the structure of an XML document.
     XML Attributes:
     Attributes values must always be quoted. for a person's gender, the <person> element
     can be written like this-
     <person gender=“male” />
     attribute
     XML Element:
     An XML the element is everything from element's start tag to the elements end tag.
     <price> 20.39<price/>
     element
     Filter:
     Use filter to from an extract information from an incoming message, in other words you
     Filter out parts of the message that you don’t want and extract only the data that you
     want.
     We can pass condition like this :
        1. //elementname[filterParameter = ‘value’]
        2. Multiple : //elementname[filterParameter = ‘value1’, ‘value2’]
     Router:
     We use router when you specify conditions based on which the messages are routed to
     receive an interface during runtime.
     The router is a tool directs messages to different recipient’s based on specific conditions.
     SAP Client ID:
11
     We’ve to define the client id in our iflow. There are 3 types of client id-
           Development
           Quality
           Production
     Security Material:
     This is for create our credentials.
     Groovy:
     Groovy is an object-oriented language which is based on java platform.
     Import: The import statement can be used to import the functionality of other libraries.
     which can be used in your code. By default, groovy includes the following libraries in your
     code.
     import java.lang.*
     import java.util.*
     import java.iot.*
     import java.net.*
     import groovy. lang.*
     import groovy.util.*
     import java. math. BigInteger
     import java. math. BigDecimal
     // using a println statement to print output to the console.
     Println(“Hello World!”);
     *Identifiers: Identifiers are used to define variables, functions or other user defined
     variables, identifiers start with letter, dollar or an underscore. they cannot start with
     number.
     // use semi-colon after statement.
     def x = 5;
     define the processData(Message, message)
     It is a function that runs the code inside it when the system calls this script.
     In processData (Message, message), the word Message and message have different
     purpose:
     1) Message (with a capital M) is the type (or class) of the object. it tells the system what
     kind of working with.
12
     2) message (with a lowercase m) is the name of the variable that holds the actual data or
     object passed into the function.
     Example-
           processData is the recipe function
           Message (this is a recipe for cake)
           message (the cake is named Chocolate cake)
     Why we use SAP Cloud Connector?
     The SAP Cloud Connector like a secure bridge that connects on-premise systems like
     (SAP ECC or databases) to applications running on SAP BTP (Business Technology
     Platform) in the cloud.
     The Cloud Connector serves as a link between SAP BTP applications and on-
     premise systems.
     Why we use Location ID?
     A "Location ID" is used to uniquely identify a specific Cloud Connector within a
     subaccount, allowing you to route messages to the correct on-premises system when you
     have multiple Cloud Connectors configured for the same SAP BTP account,
     Write Variable:
     Write variables to share data across different integration flows (deployed on the same
     tenant).
     There are 2 types of write variables
        1. Local Variable
        2. Global Variable
     A "Write Variable" step is used to store a piece of data (like a timestamp, token, or
     configuration value) as a variable that can be accessed and reused across different parts
     of an integration flow or even in other integration flows within the same tenant.
     Multicast:
     We can use the Multicast step to send copies of the same message to multiple routes. we
     can send copies to all routes at once using Parallel Multicast or in an order of your choice
     using Sequential Multicast. This allows you to perform multiple operations on the same
     message in a single integration process. Without Multicast, you needed multiple
     integration processes to perform this task.
13
     Gather And Join:
     The Gather step merges messages from different routes (into a single message) with the
     option to define certain strategies how to combine the initial messages. The Join step is
     used in combination with the Gather step. It brings together the messages from different
     routes, but it does not affect the content of the messages.
     Difference between Gather and Join:
     The Gather step merges messages from different routes into one, while the Join step
     combines messages from different routes without changing their content.
     Example Gather:
     Input:
     Message 1: {"OrderID": "123", "Status": "Shipped"}
     Message 2: {"OrderID": "123", "DeliveryDate": "2025-02-01"}
     Output (After Gather):
     {"OrderID": "123", "Status": "Shipped”, "DeliveryDate": "2025-02-01"}
     Example Join:
     Input:
     Message 1: {"OrderID": "123", "Status": "Shipped"}
     Message 2: {"OrderID": "123", "DeliveryDate": "2025-02-01"}
     Output (After Join):
     [ {"OrderID": "123", "Status": "Shipped"}, {"OrderID": "123", "DeliveryDate": "2025-02-
     01"}]
     What is API?
     API (Application Programming Interface) It's a set of rules that allows software
     applications to communicate with each other. APIs are used to exchange data, features,
     and functionality.
14
     What API headers do?
           Authorization: Provide proof that the user has permission to perform an action.
           Content type: Specify the format of the request body or response body.
           Content length: Specify the length of the request body or response body.
           Response caching: Reduce the number of requests made to the underlying
            dataset.
           Server monitoring: Provide basic information about the request or client.
           Server information: Provide information about the server that processed the
            request.
     What is form data in rest APIs?
     A method of sending data in a key-value pair format, typically used for submitting
     information from web forms, where each key represents a form field, and its
     corresponding value is the user input.
     What types of authorizations in rest APIs?
     1. Basic authentication
     A simple method that uses a username and password to authenticate a client with a
     server. It's widely supported by browsers and web servers, but it's not suitable for high-
     security applications.
     2. API key authentication
     A common method that uses a unique identifier to authenticate a client or
     application. The API key is sent with each request in the query string, request header, or
     cookie.
     3. OAuth 2.0
     A standard that allows third-party services to access data on behalf of a client. It uses
     access tokens to grant access without exposing the client's credentials.
     4. JSON Web Token (JWT) authentication
     An open standard protocol that uses a compact, URL-safe way to represent claims
     between two parties. JWTs are signed using a cryptographic algorithm to ensure that
     claims cannot be altered after the token is issued.
     5. Bearer Token
     A Bearer Token is a type of access token that is used to authenticate users and authorize
     access to resources in web applications and APIs.
     What is Cookie?
15
     API cookies are small pieces of data that a server sends to a client's browser. They are
     stored on the client's device and used to track and store information about the user.
     Why we use Cookies?
     We can use cookies for three primary purposes: session management, personalization,
     and tracking.
     Session and Cookies
     Sessions and Cookies both store user information but difference in key ways. Sessions
     are stored on the server and are more secure but temporary, while cookies are stored on
     the client’s computer and can last longer but are less secure.
     Difference Between Session and Cookies
                        Cookies                                      Session
      Cookies are client-side files on a local      Sessions are server-side files that contain
      computer that hold user information.          user data.
      Cookies end on the lifetime set by the        When the user quits the browser or logs
      user.                                         out of the programmed, the session is
                                                    over.
      It can only store a certain amount of info.   It can hold an indefinite quantity of data.
      The browser’s cookies have a maximum          We can keep as much data as we like
      capacity of 4 KB.                             within a session, however there is a
                                                    maximum memory restriction of 128 MB
                                                    that a script may consume at one time.
      Cookies are less secured.                     Session is more secured compare than
                                                    cookies.
      Cookies stored data in text file.             Session save data in encrypted form.
      Cookies stored on a limited data.             Session stored an unlimited data.
     What are iFlows in SAP CPI?
     IFlows (Integration Flows) represent the graphical representation of integrations. They
     define how data is transferred, transformed, and routed between systems.
     Explain the difference between SAP PI/PO and SAP CPI?
           SAP PI/PO is an on-premise middleware solution, while SAP CPI is a cloud-based
            integration solution.
16
           CPI offers more flexibility with cloud-native features, lightweight architecture, and
            is suitable for hybrid integrations.
     What are tenant and subaccount in SAP CPI?
           Tenant: The CPI runtime environment where integration artifacts are deployed
            and executed.
           Subaccount: Represents the environment within an SAP BTP account, hosting CPI
            services and managing users.
     What are the key components of SAP CPI?
           Integration Flows: Workflow logic.
           Adapters: Connectors to integrate different systems (e.g., HTTP, SFTP, IDOC,
            SOAP).
           Mapping: Transform data between different formats (XML, JSON, etc.).
           Security Artifacts: Certificates and credentials for secure communication.
     Key Aspects of Context in Message Mapping
     In graphical mapping, a context defines the level at which data is processed.
17