Praveen Call Me Whatsapp Hire Me !

Forecast Weather using OpenWeatherMap with SAP MII

Home

In this tutorial, we are going to create a SAP MII application to display weather forecast information using an API. I have used OpenWeatherMap service to implement this with SAP MII. We will just grab the weather information provided by the API and display it in the application.

This is one of the best API service that provides weather forecast. It provides tremendous volume of weather data regularly. It is a free service with limited access. For basic usage, it should be sufficient and for advanced you may have to pay for it. Integrating this API with a SAP MII application is easy. The following three steps are used for the integration.

  1. Get API key
  2. Locate city id
  3. Request weather forecast by sending API key and city id

Get OpenWeatherMap API key

  1. To get the API key, we need to register with OpenWeatherMap . After signing up, it will redirect us to the profile settings.
  2. Above the profile settings form, there is a top menu containing several tabs. Click the API keys tab and copy the API key. This will be later used to request API for the weather forecasts.
Norway

Locate city id

By clicking the below link, the cities name will be given in a url. Unzip the file and get the id of the city/state.

https://api.openweathermap.org/data/2.5/weather?q={CITY NAME}&appid={API ID}

Example:
https://api.openweathermap.org/data/2.5/weather?q=Mumbai&appid=60bab3f0f3e6d69db68e049b3990b213

After loading, it will have the JSON formatted data containing an array of datails. Each array item contains the geodata like latitude, longitude, country, city/state,temp,huminnity, city id.

Transcation to Request Weather Forecast by sending keys and location

This is the Transcation to request the OpenWeatherMap service to get the weather forecasts. While sending the request, the API key and the city id is sent with request URL query string. I used TEXT LOADER to send the API request. It response will be in a JSON format. we can get the weather data.


Norway

XML Code to Show Weather Forecasts

This XML code is used to display the weather forecast by decoding the JSON object response. In this section, we access the location, weather description, icon, min-max ranges of the temperature, humidity and wind speed.


Norway

JSON Code to bind data


Norway
Norway
Norway

Output of Weather Forecast using OpenWeatherMap with SAP MII


Norway
Norway
Norway