0% found this document useful (0 votes)
62 views

Data Store

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Data Store

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Data store: data base lo table lantidi its like a data base table ------entries ID -> you can

give dynamic
value or contast value (you can store employe id in property and provide it here also if you dont give it
will generate an unique value )

Difference between get and select – single message we can read is get and select is multiple
messages /entries ->

Get = message header+body select is only = Message body

When to use property vs variable in sap cpi?

If you store values in headers or properties in your iflow, those values will be gone when the iflow
finishes. If you need to store values longer than that, you can store them in a variable using the Write
Variables step. In other words, they're a way to persist data.

A global variable can be accessed by any iflow, but a local variable can only be accessed by the iflow that
wrote it.

You can see all the variables, you've stored, in the Operations view => Manage Stores => Variables.

Variables are similar to Data Stores, really. But variables store scalar values (i.e. one number, one
timestamp etc.) whereas Data Stores contain complete payloads (e.g. an XML or JSON document).

Please note that while there's a Write Variables step, there's no Read Variables step. To fetch the value
of a variable into a property or header, you use a Content Modifer with the type set to either Local
Variable or Global Variable.

------------------------------------------------------------------------------------------------------------------------------------------

Delta load records fectching can be achieved usign write variables


Write variable :

To use a variable across multiple integration flows deployed on the same tenant, define it as a global
variable.

You use the Write Variables step type to create a variable at a certain point within the message
exchange. To consume the variable (either in another step of the same integration flow or in another
integration flow), you can use a Content Modifier. With this step, you can set a header or an Exchange
property based on a variable.

Question: What is the difference between Header, and Property?

The scope of the element declared in the Header is beyond the scope of the IFlow,

The scope of the element decalred in the Property is only within the IFlow i.e. the property
parameters are not handed over to the receiver.

SAP CI – Data Persistence: Variables and Number Ranges

Like most middlewares, we associate SAP CI (a.k.a. SAP Cloud Integration = formerly CPI) with ETL
operations- Extract, Transform and Load data. This gives the perception that data only passes through
SAP CI and no data is stored on it. While in most cases this may be true, there can be certain situations
in which we want to persist some data on SAP CI as well.

For example, we may wish to store Last Successful run Date of a particular IFlow (integration flow). This
could be required because we use this date in another IFlow, or another execution of the same IFlow,
like fetching data based on this date. Some may argue that we can just look into the tenant’s Message
Processing logs for finding the last execution date, right? And if that’s the case, why do we even need to
store this data? But it’s not necessary that every execution is a successful one and thus, the Last
Successful Run Date cannot be fetched directly from Message Processing logs.

As another example, let’s say that there are multiple paths of execution within an IFlow, and the path
taken is decided on the basis of input data.
We wish to store the timestamp only when Path 1 is taken last. For Path 2 and Path 3, we do not require
to store this information. Looking at Message Logs will not be of much help to us anymore. In such cases
(and many more), we need some mechanism for persisting data on CI.
Thankfully, SAP CI already provides features for persisting data. Under Operations view of your CI
tenant, you will find a section titled “Manage Stores”. This houses the various data persistence options
provided by SAP CI. Let’s have a look at them one by one.

Variables

Let us come back to the scenario we had described earlier: we wish to store last successful run date of a
particular IFlow. For this purpose, we can use a variable.

Creation of a variable

In our IFlow, we have to include a ‘Write Variables’ shape to do this. Using simple camel expression as
shown below, we can store values in variables. Please note that we did not need to create a Variable by
going into Operations view first.

As we had discussed earlier, we may wish to store this value only for a particular path of execution
among many. In that case, we can place this shape in only that path.

Reading Variable value

To read the values stored in variables, all we need to do is reference the variables as shown below. This
can be done in Message Exchange Properties as well.
Inspecting Variables in Operations View

To look at the value of this variable, go to ‘Variables’ under Manage Stores in Operation view. You can
identify the variable using its name and the ID of the integration flow it belongs to. We can read this
variable in the same IFlow and write back another value. This is because the scope of this variable is
limited to that particular IFlow.

This is what Manage Variables screen looks like. You can see a list of all the variables under this tenant
along with their visibility, name of the integration flow they’re associated with (in case of Local
variables), associated Dates and available options.

Scope/Visibility of Variables

Variables have Local scope by default. This means that they are visible and accessible to only one IFlow.
But what if we wanted to read this value, or possibly even modify this value from another IFlow? In that
case, we will have to use a Global variable. Like the name suggests, the scope of this variable is not
confined to just one IFlow. This variable can be read and modified by iFLow.

When can something like this be useful? As an example, suppose the value written by one IFlow is to be
used by another for its processing.

Since Global variables are not limited to one IFlow, when we look at these variables under Manage
Stores, they have no value mentioned for IFlow Ids.

Can we have multiple variables of the same name?

Another thing to note is that you can have multiple local variables of the same name. This is possible
because they can be differentiated by their IFlow Ids. But this is not possible for Global variables.

Can we have Local Variables by the same name as a Global Variable?

Yes, we can have multiple local variables of the same name. This name can be the same as a Global
Variable.
When we read a variable value, we specify whether we wish to get the value of a local or a global
variable. So there is no issue in having duplicate names.
What happens we try to reference variables that do not exist?

If we try to reference a variable that does not exist/provide an incorrect name. No value is extracted and
the header/property is effectively set to null.

Alternatively, we can specify Default Values to be used in such cases when we reference variables. If the
variable does not exist, this will be used as a replacement and treated as a String object.

Deleting a variable
Variables can be deleted from ‘Manage Variable’ screen under Operations view of your CI tenant by
clicking on the delete icon on the right side of the variable tile.
Retain Period of a variable

The period for which the value of a variable is stored is 400 days from Last Modification date of that
variable.
Number Ranges

Now we are going to hop on to the next topic: Number Ranges. We already know it’s a mode of data
persistence, but what exactly does it do and what makes it different?

Number ranges act as sequences which can be used for marking messages, among other applications.
Suppose that in a particular integration scenario, all messages to the destination system must have a
unique sequence number. This is where a number range can be of use.

Creating Number Ranges

Before use, Number ranges have to be created by specifying the following:


 Name: Give a unique name that will be used to reference this Number Range.
 Description: Not mandatory, but generally a good practice to include this information to avoid
any confusion in the future.
 Minimum value: A non negative integer value with maximum 14 characters. Cannot enter
string/characters here.
 Minimum value: A non negative integer value with maximum 14 characters. Cannot enter
string/characters here.
 Field Length: The length of the sequence number returned by this number range.
 Rotate: If the maximum value is reached, the first value is picked as the next number in
sequence.
Using Number Ranges

Number ranges can be used by referencing them in Message Headers/Exchange properties.

Number ranges can be used as per requirement. If they are to be used only under certain conditions and
not in every execution, they can be referenced within the path matching those conditions to avoid
unnecessary wastage of numbers in sequence. This can be done with the use of Routers, for example.

Can the same number range be referenced in multiple IFlows?

Yes, but remember that whenever they are referenced during an execution, the value is incremented by
1. If you are using the same number range for multiple integration flows, it can lead to confusion over
apparently skipped values. Moreover, if the destination systems are expecting a continuous sequence, it
will be problematic to use the same number range in multiple integration Flows.

Can the same number range be referenced at multiple places in the same IFlow?

Yes, this can be done as well. But we can expect skipped values as a result. For example, if a number
range is referenced twice during an execution, the value of that number range will be incremented by 2.
Keeping this in consideration, the same number range be referenced multiple times and even used to
create increments/steps of n instead of just 1.

Can the next value of a number range be changed?

We can manually set the next value of a number range to some specific value. Although this is not
usually encouraged, under some rare circumstances this may be warranted. This can be achieved by
Editing the Number range under Operations view->Number Ranges.
What happens we try to reference a Number Range that does not exist?

If we try to reference a number range that does not exist/provide an incorrect name, an exception is
raised of the format:
com.sap.it.rt.adapter.http.api.exception.HttpResponseException: An internal server error occured: Error
while fetching next value for number range: NumberRangeName.

This is quite different to what happens in case of missing variables which simply returned null values.

Deleting a Number Range

Number Ranges can be deleted by clicking on Undeploy Button on ‘Manage Number Ranges’ screen
under Operations View of your CI tenant.

Retain Period of a Number Range

Number ranges do not have a fixed retain period. They are retained until undeployed.

Using Variables instead of number ranges

If you think about it, variables can be used to replace number ranges. In an integration flow, we can set
Message Headers/Properties to get value from variables (and set default value in case of its absence).
After use, the value can be increased/decreased as per requirements and this value can be written back
to the variable.

Pros:

 Can decrease values as well instead of just increasing. As an example, we can implement a
countdown using this logic.
 Can implement our own logic for more complex scenario. Example: we can both increase and
decrease values based on certain conditions.
 We can restrict usage of a sequence implemented with the use of Local Variables. This way, only
a particular IFlow will have access to one sequence.
 We can change the sequence values as and when required using some logic implemented in our
IFlow.
 We can assign default values to be used in absence of the specified variable.
Cons:

 The onus of incrementing/decrementing values is on the CI developer. Developer will have to


take care of all possibilities to ensure that the correct sequence is followed.
 We cannot set the value of variables manually as we could with Number Ranges.
Whether this should be done or not is debatable and is best left to the discretion of the reader. In this
Blog post, we learned about two modes of data persistence in SAP Cloud Integration and the differences
between them. This is all the information one needs to begin working with variables and Number
Ranges in SAP Cloud Integration. In the next post, we are going to discuss the third mode of data
persistence – Data Stores, and some more interesting scenarios.

2) Content Modifier to add/change/delete some data

a) Pipeline concept that CPI pass message contain headers, properties and body from one CPI step to
next step connected by arrow. Multiple CPI steps can be chained together sequentially/parallelly.

b) Content Modifier able to add/change/delete headers, properties and body (also number range &
variables).

c) Generally, header store smaller size data that might need send to receiver(s)a. E.g. as HTTP
headers.

d) Generally, property store larger size data and data need to store in earlier step of iflow and need
retrieve back at later step.

e) Body is main payload that can send to receiver(s).

) Request-Reply to make some calls and Adapter for Connectivity

Request-Reply simply mean make some request call to receiver and get reply/response back. Suggest to
first learn these 3 adapter types: HTTP, OData, SOAP because majority of use-case especially those
cloud-based API believed fall under these 3 adapter types.

4) Routing Concept mean where and how should my messages flow to?

Routing is common usage in integration, suggest to first learn these 3 routing patterns:

Router step to send message to different routes based on condition, process using different logic and
optionally back to single main route.

Multicast step to send the same message to multiple routes to process differently, and optionally gather
back results from all different routes.

Splitter step to tackle challenge of splitting large payload to smaller one then only process. Should
understand different between General and Iterating Splitter, and learn how to split by XPath, Line Break
and Token.

5) Converter to convert body from one format to another

Should learn the usage of standard converter JSON To XML, XML to JSON, CSV to XML, XML to CSV,
because these are common payload format hence common requirement.
6) Looping concept in CPI

If you come from imperative/procedural programming background (e.g. Java, ABAP, C#), you might
wondering how to looping in SAP CPI? What are the equivalent CPI ways to do for loop/while loop since
all these CPI steps is drag-and-drop only without coding? The answer is using CPI “Looping Process Call”
with condition to exit loop. You should also aware the concept of OData V2 vs V4 looping and leverage
build-in looping feature of OData adapter.

7) Filter/Sorting concept in CPI

Filter concept mean only take necessary data required, either source system only send required data, or
use CPI filter step to retain only required data. For filter step you will need fair good knowledge of XPath
to filter effectively. Alternatively, can use message mapping for filtering or use groovy mapping to do
advanced complex filtering.

For sorting, there are no build-in ready step by CPI to do sorting. Will have to resort to custom solution,
either XSLT, message mapping (not recommended due to need apply sorting to all fields) or groovy
mapping.

8) Enrich/Lookup concept in CPI

There will be cases you might need get different payloads from multiple sources or multiple calls, then
only enrich the main payload with data from lookup payload. You should understand default capability
and limitation of Content-Enricher step, and good to know ways to do advanced data enrichment using
groovy mapping, since message mapping(multi-mapping) that involved multiple messages normally will
be relatively much complex to develop and maintain.

) Integration flow design concept in CPI

Personally, I classify the CPI iflow design to 2 major considerations:

First is performance consideration. You should aware different iflow design although might still achieve
the result, but sacrificed performance and might become unbearable slow and error prone. General
advice is to reduce number of calls required and eliminate unnecessary calls. Avoid using unnecessary
large payload but split to reasonable smaller payloads.

Second is iFlow design that easy to understand, develop and maintain. For example, concept of
modular design, divide and conquer technique to sub-divide different group of CPI steps into local
integration process, make use of processDirect adapter for reusable logic. The iflow designed should be
relatively easy to understand. If you from programming background then know that Spaghetti code is
messy not maintainable, so the same apply to CPI iflow design, should easy to see where it start, how it
flow (left to right, top to bottom) and where it end.One example of badly design iflow is use only one
main process that have too many different CPI steps, multiple receivers and arrows that connecting
horizontal, vertical, diagonal in every direction, then essential become Spaghetti flow.
10) Groovy Scripting capable to tackle complex mapping (and many things else)

Since Groovy is general purpose programming language so it is very flexible and powerful, basically you
can use Groovy script to do a lot of tasks (not only mapping) as long as you able code the solution in
Groovy language, and supported in CPI environment. For example use groovy mapping to so source-
target fields mapping between these data format: Xml, Json, CSV, IDOC, Odata Batch. Using Groovy
scripting is extensible because able to import Java Jar libraries that contain the feature you needed.
Example CSV processing Jar library.

11) Message Mapping (Graphical Mapping) and Queue and Context concept

If you need to support existing message mapping from standard pre-packaged content iflow, or need to
migrate SAP PI/PO message mapping to SAP CPI, then there is no other choice but need to understand
those tricky mapping queue and context handling using node functions. It will be difficult to work on
complex message mapping without good understanding on message mapping queue and context
concept.

12) XSLT powerful in XML transformation but come with steep learning curve

SAP CPI XSLT processor support XSLT 3.0 specification, the key takeaway is with XSLT 3.0 it is even
feature-rich to do advanced xml transformation. For me I still not able to tune my thinking into XSLT way
and not skilled in XSLT. If you have the time, determination and brain-power to learn and think in XSLT, it
will be a great skillset to acquire.

13) Persistence/Variable/Data Store mean CPI keep data for later usage

For normal integration flow processing, all header, properties and body temporarily hold in CPI during
runtime will not able to retrieve them back again after iFlow processing end. This
persistence/variable/Data store concept is asking CPI to ‘remember’ by storing in SAP CPI. Generally,
global/local variable is for storing single value, while Data Store is to store list of value/payloads under
same data store name.

14) Exception handling concept in CPI

When error happened in CPI message processing, we can either do nothing then let it failed in CPI in red
error, or add exception sub-process. Ideally should at least able to get back the error message and error
stack trace, then see how to handle errors, e.g. send alert email, store error message in SFTP server or
design advanced re-processing mechanism using data store.

15) Security concept in CPI

First security concept is authentication. Should aware different authentication supported by SAP CPI. For
example username/password, OAuth2 token or client-certificate based authentication. Second concept
is authorization mean what access granted example developer role don't have admin access to manage
CPI tenant setting or security artifact. Other security concept is message level encryption(encrypt and
decrypt) and signature (sign and verify) that commonly used in file-based transfer like in SFTP, but some
also apply encryption in API-based HTTP calls.

16) Explore and learn other adapter types based on need and interest

For example: Explore SFTP adapter if need work with files sending/polling, with external partners
example Banks’ files. JDBC adapter if need connect and use SQL and stored procedure to interact with
database tables. SuccessFactors adapter if need query or post data to SuccessFactors API (either SOAP
or OData). You get the idea, hence no need to list all CPI adapter type here.

kleopatra

You might also like