Lesson4 - Create IFlow in CPI
Lesson4 - Create IFlow in CPI
Click on ‘Create’:
Click on ‘Save’.
Go to ‘Artifacts’, Add – Integration Flow:
‘Sender’ and ‘Receiver’ we can directly configure from here, these are externalized parameters. We can
externalize it internally also.
The IFlow has been created. The version shown is 1.0.0.
Basic component of the IFlow – Sender, Receiver and Integration Process.
We can have many senders and receivers but only one integration process.
Copy and paste buttons shown above. If we want to copy the sender and receiver systems, or any
components inside the Integration Process, we use these buttons. We can copy and paste the components
in any other IFlow. We can copy and paste any reusable components in other IFLows.
Participants sender and receiver. We use this to add extra sender and receiver.
Process We have 3 processes – Exception subprocess, Integration Process and Local Integration
Process.
Integration Process – we use it to define the steps, process the message to transfer between sender and
receiver. Message processing and data processing takes place in Integration Process.
Exception Subprocess – configured inside the integration process. Used to catch any exception thrown in
the integration process to handle them, so that the integration process doesn’t fail.
Local Integration Process – Used to simplify the integration process like suppose we have a very
complex integration process which requires so many components. Local Integration Process is used to
break down a main big integration process into smaller fragments. We can combine these fragments to
achieve the main integration process.
Events
End Event – To end any integration process, we use the end event.
End message – Ends the message event, ends a message processing sequence.
Escalation End Event – Used for routing conditions that have not been met.
Error End Event and Error Start Event – we get in Exception Subprocess.
Add ‘Exception Subprocess’:
Mapping –
Message Transformers:
Exchange Property:
If we want to convert from CSV to JSON, we have to use 2 converters1st convert from CSV to XML and
then from XML to JSON.
Decoder:
Base64 Decoder – used to decode messages using Base64 technique.
GZIP Decompression, etc.
EDI Extractor: Enables you to extract EDI headers and transform to camel headers and this element
extract data from single incoming EDI document and add in message processing.
External Call:
Content Enricher – Mechanism to combine the incoming message with additional data retrieved from an
external source.
As per its name (Enricher), adding something to the content. The content enricher adds the content of the
payload with the original message in the course of integration process and this converts 2 separate
messages into single payload and this feature enables you to make external call during the course of
integration process to obtain the additional data.
Poll Enrich – Polls to external system and enriches incoming message. We can use this to read the Poll
message from external component and add the content to the original message in the middle of the
message processing sequence.
Request reply – It represents call to external system. We use it to call an external receiver system in
asynchronous step to get back a response.
Send – Represents a one-way call to an external system. Used to configure a call to receiver system for
scenario and adapter where no reply is expected.
In request reply we expect a reply but in send we don’t expect a reply. We can use these in different types
of adapters. Like a Mail.
Local Call:
Message Routing:
Aggregator – With Aggregator we can collect and store individual messages until the complete set of
messages are received. Aggregates several incoming messages to a single one.
Gather and Join – Gather step gets messages from different routers with option to define certain strategy
to combine the messages. Gather defines the aggregation strategy. Join step is used in combination with
the gather step. It brings messages from different routers, but it must not affect the content of the
message. Join sends multiple incoming messages to a single outgoing path.
Multicast – Sends same messages to different paths.
Security:
Decryptor – Decrypts the encrypted data contained in the body of the incoming message.
In CPI we use the data type ‘java.lang.String’ to represent a string. In CPI we use groovy script.
Request Reply – To use OData we have to add Request Reply, to the request reply we have to add one
receiver. Because we are sending request to OData to get the information about the product HT-1080.
Here to connect the request reply and receiver we use an adapter OData V2. We have to configure the
OData connection:
In the connection, we have to give the address of OData.
In processing, we use a GET call, we want data from OData.
Click on Finish.
We want the data to be seen in the monitoring section, so for that e have to do some groovy script. Like
we want to log the data.
Add ‘groovy script’ component in the Integration Process. There will be a ‘create’ option to do some
coding:
We want to just LOG the message. For this we used the above groovy script.
If we are using the groovy script in CPI, we have to import
‘com.sap.gateway.ip.core.custom.util.Message’
Without importing this, it won’t work in CPI.
Also, import ‘java. util.HashMap’.
We define a message to process the message data and in that we are defining the body, as a message
string.
We are logging the message and keeping it in the message log.
We are checking if the message log is not null, we will add the attachment as Log current Payload, in the
body as a plain or text. Then return the message.
‘Start’ is triggered when the data is sent from the sender system. Here we don’t have any sender system,
we have to use a timer. In the timer, there is an option- when we deploy it it will automatically start. We
can also configure the timing like:
‘Run Once’ when we deploy the IFlow, it will automatically go on the Run Mode.