Welcome to this series of hands on tutorials from the SAP HANA Academy
I'm Philip Mugglestone
in this series. We're covering the SAP Business Technology Platform
in this video tutorial we're going to take a
closer look at connectivity when
we're working with the SAP Business Technology Platform
in particular, we're going to look at destinations.
Now it makes sense when you're building applications
that you want to abstract out the way you
connect to back end systems or in fact
any external system and SAP BTP provides the destinations service
to allow you to do exactly that.
So it's probably a good idea to start with the reference guide.
If you go to help dot SAP.com
and then search on SAP BTP connectivity,
then you'll find
the suggested product, SAP BTP connectivity
and this is where we get much more detail about that.
Now you'll find there are a number of different aspects here,
we've got issues related to whether you're using one or
other of the environments or
runtime such as SAP BTP, Cloud Foundry runtime or SAP BTP, Kyma runtime
we've got information for example about the destination service
and we've also got information about something called the cloud connector.
Now the cloud connector allows you to access to back end systems that are behind,
for example, a corporate firewall,
they're not publicly available from SAP BTP can't get to them.
So what you do is you install the
cloud connector service actually behind your firewall and tunnel
it out to your SAP BTP sub account and
then SAP BTP can then access those back end systems
and then you set them up as destinations.
So there's lots of really good information here gives
you much more of a guide of how you
can actually work with connectivity now in terms of
how it looks when you're working with the cockpit
then
if you go to our sub account
then you'll find there's a connectivity section
and if you look at that there are two parts of that. First one is called destinations.
This is where you can define destinations that exist
at your sub account level so they're accessible to
anything that you can access that sub account so
you can actually create them here through the menu.
It's also possible to do it programmatically or to import or export.
So you can say create a new destination for example and we give it a name
and then we'd actually put in the URL that would use for
example want to access an OData service or a back end system.
Now you've got the option of proxy type which allows you to specify,
is it going to be the internet or on premise which implies we're going to be using
the cloud connector that I mentioned a moment
ago and we've also got things for authentication.
So here you can see there are loads of different types of authentication,
you can have none.
You can have basic authentication where you're
working with this straightforward user and password.
You can also have lots of different types of
two authentication.
For example client credentials where you'll need to then put in a client ID in secret
and also a URL that points the token service.
So if you want to do that type of authentication you can
and the great thing is if you use the SAP Cloud SDK from SAP it would actually take care of
the access tokens going through whatever the process is based
on the settings you define and encapsulate in your destination.
You can also configure additional properties for a destination.
Now there's a list of a whole load of standard ones.
If you're a partner you'd also maybe want to use the application interface key,
you can easily configure additional properties then safe and
effectively you encapsulated the details of that destination.
So that's how you can create a destination at the sub account level.
Also you can set up cloud connectors. This
as we mentioned, is how you can then access
systems that are going to be tunneled from behind the corporate firewall.
Now it's also possible to define destinations as instance destinations
and this means the destinations are specific to a
service instance of the destination service that you create
and instead of everyone accessing that sub account having access
only the apps that you want to can access those.
So it means you can have maybe
applications specific destinations which are really kept
specific to those apps and there are two apps running the same sub account,
they cannot see or work with each other's destinations,
whereas if you do them here at the sub account level,
they'll be available for access for anything from that sub account.
So probably the best way to have a look at an instance. Destination
is to build an application that will create them for us.
I said we can create destinations programmatically.
So we'll go to SAP Business Application Studio and we'll
go ahead and use the template wizard
and we'll use one of the SAP HANA Academy generators.
We've got the MTA generator here.
Let's hit start
now we'll create an app, we'll call it just app,
we'll deploy it to the SAP BTP, Cloud Foundry runtime
but it will also work for SAP BTP, Kyma runtime
and for example,
what we'd like to do is say we want to access the SAP S/4HANA Cloud sales order,
API maybe from the sandbox on API have to
start and maybe we want to also test the destination
service with the SAP Cloud SDK but in this case we
won't be accessing on prem through the cloud connector.
So what this will do when we hit next
is to go ahead
and scaffold out the project code.
Now just keep things simple.
I'm just going to turn off the authorizations there,
we've seen that in the previous video tutorial.
Let's hit next.
Now we see that we've got a project scaffolding out.
If we look at our MTA YAML file, which is where we have a lot of the plumbing.
You'll see that in the resources section we've actually got
a destination service instance and it's specific to our app we
called it app dash best and then we can see
we've actually set up to create a couple of instance destinations
you can see one of them is for the SAP S/4HANA Cloud API pointing in the sandbox
with the relevant settings
and we've also got the same to access the Northwind as an example.
Now, just before we build and deploy it,
let's just take a quick look at some of the code,
you can see here that we're actually using
the SAP Cloud SDK So we're requiring SAP Cloud SDK we
actually got functions using functions of the SAP Cloud SDK
and we're able to just execute http requests
and get information out.
So the great thing about that is that it's really only the
name of the destination that you might specify in your source code,
you're not actually putting any of those
credentials or sensitive information that might change,
it might be a security issue,
particularly if you're then using GIT or GIT hub to
actually work with the source code maybe for CI/CD process
and when you're using the SAP Cloud SDK for example using the function
core.executeHttpRequest
It will take care of actually getting you
the access token as required.
You don't have to do the multiple queries yourself to do that Of course
you can if you want you can use axes or something from Node.js
the SAP Cloud SDK basically encapsulates that for you.
It understands SAP BTP destinations will do most of
the donkey work for you as a developer.
So let's go ahead and build and deploy the application.
So now that the app has been deployed we can go back to our cockpit,
we can have a look at our service instances
and now we can see that we've got
an instance of the destination services being created
and we can see it's also got a service
binding with the relevant credentials that the app is
going to use and we can see we've got a little link on the left hand side here.
Now if we select that it will allow us to go to the dashboard where we can manage those
instance destinations that are specific to this service instance
and then we can select destinations and you'll see that
a couple of destinations have been created for us.
Now I'm going to make some changes here because the great
thing is we can then use the cockpit to edit these
because there are things that we wouldn't want to put in
our source code in terms of this destination for example,
the API key that we need to use or maybe the application interface
as a partner. So what I can do is set that value here in the destination.
So it's never stored in any source code
and again for the API key as I'm going to use the sandbox from SAP API Business Hub
let's go to SAP API Business Hub and I'll log in and then I'll go to my settings,
show my api key
I'm going to copy the key and close
and then paste that value in here
and I can save my destination
and then we can go to our application.
So we'll go to actually to the
scope which is the SAP BTP, Cloud Foundry runtime space.
In this case we'll go to our dev space we'll
find this is the front end of our application,
let's go ahead and launch it
and you'll see we've got an end point to look at SAP S/4HANA Cloud sales order,
click it and indeed we're getting data out
of our SAP S/4HANA Cloud system and that's been done as
the code we saw already using the SAP Cloud SDK
and it's going via the destination that we've configured
the same kind of thing here where we're actually accessing Northwind customers.
Now I did mention it's also possible to
access destinations and manage them using the API
so we can just take a quick look at that.
Now if you go to SAP API Business Hub, we'll just go to the main page
then we'll look at SAP BTP product
and then API s
and we'll search on
destination and then we'll find the destination service.
Now it says SAP BTP, Cloud Foundry runtime but it's
not exclusively that it also works.
For example when you're working with SAP BTP, Kyma runtime or even
when you're not using one of the specific run times
so we can go to the tryout link and
there we can see these are the different endpoints available
so for example if we want to see our instance destinations,
we can see destinations on service instance level
and we've got one called get instance destinations
now in order to run that we just need to put a value in for page
and we'll also need to set up all the credentials to do that
so we can very easily do that by adding a new environment.
Give it a name maybe relates to our app.
So we'll call it app will need to specify the starting URL
and this is where we really need to specify what
is the region we're running in in our case we're
running a sub account in us10 and we'll need
to specify a client id client secret the token URL
that would be done for us. If we put in the sub domain name
that we have it will then fill in the token URL for us.
You can see that actually is a sub domain name.
When we look at the overall sub account.
So here
and then what we want to do is we're going to need that client ID in secret.
So for that we can go and look at the binding.
You can actually create your own service key if you want to
at this point but we'll look at the binding that the apps using
and there we can see we've got our client ID
and also the client secret. Now this service binding also has
the URL that will use you need to add
token on the end of it.
It also contains information for example about how you actually call the URI so
all the information you need to do an off to authentication to access this.
API for the destinations
is available through these credentials.
So having done that then we can choose configure and now we should be able to run
and we see we get results back, we get some JSON
and we see we have the two destinations that have been defined back in JSON format of
course you'll get all the settings that have
been set up including the API keys etcetera.
So you need to just be careful about how you share
that information but it means you can use it programmatically from
your app and of course if you want to make changes
rather than using the copy you I you can do it
this way in this case for example use put would allow
you to actually maybe set specific values within your destination definition.
Now if you want to see some really good examples of using the destination service,
I highly recommend that you go to the SAP community
and look at the tag quovadis,
my colleague Piotr Tesny
he's created a number of really excellent blogs
that show in detail some very specific ways
that you can actually configure different types of
destinations when you're working with the SAP BTP environment.
So I highly recommend that you look at those
and of course we have lots of videos in the SAP HANA Academy that show more details.
Many of the videos.
Many of the projects will involve using destinations to access back end systems.
So there are a whole load of series here that you
could use when you want to learn more about accessing destinations,
but in particular
I would go to the one with the extension generators
and there it's got many of these will
actually generate destinations as part of the process
to different back end systems for example.
And then you can actually learn from those examples
in this video tutorial. We've seen how we can define
destinations in terms of connectivity.
When you're working with the SAP Business Technology Platform
you can find more video tutorials on our Youtube channel
if you'd like to be informed as soon as
new video tutorials are published then please subscribe.
Thanks for watching