Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member1232
Active Contributor

“Everything is going to be connected to cloud and data…
All of this will be mediated by software.”
Satya Nadella, CEO, Microsoft


 





Source: Bing

 

Do you remember how communication activities were handled in Email software in the early 2000s? With smartphone arrivals, things got totally changed. And, who would have imagined 30 years ago that we would carry the internet in pockets, homes would become our offices, IVR/bots will be answering your queries before connecting to your bank and other businesses, or simply paying using a smartphone as a credit card, or good part - getting our favorite food order by using a smartphone app only.
A similar important and significant shift is happening in Serverless space! It is getting more focus on business logic and code, not underneath servers or infrastructure. This isn’t the first time we’ve seen a massive shift in how technology affects our working lives, and it certainly won’t be the last, indeed.

While COVID-19 continues to make face-to-face collaboration an impossibility, cloud-based applications and workloads provide a well-defined method for remote development and project deployment, and Serverless applications already started playing an important role. Today this article will show you a good example of SAP and Serverless engine integration using Logic apps.

Serverless offerings, like Azure Logic Apps and Azure Functions, take this to the next level while allowing us, as developers, to focus only on our application functionality and not the backing infrastructure or uptime of servers. Also, here Azure Logic Apps and Azure Functions are big entry gates for non-coders and may finally be making the coveted 'citizen developers' idea a reality. Since the last decade, there has been the expectation that 'citizen developers' => non-coders and non-technical staff will be able to leverage the power of connectors and APIs through a range of visual design tools and drag and drop connectors. And I guess all Cloud providers are working on a similar goal! With the latest SAP and Azure integrations tools and processes, the focus is on getting on business logic built, not your servers.

Let's explore and run a 'hands-on' session on this topic!



Source: Bing

Get Started!


We are going to build an Azure Logic App to save cloud resources cost running SAP Application. Here Logic App plays with the SAP system to automate shutdown (SAP and VMs both) using an Email handler. It is a convenient tool for Basis managers/Leads who want to control SAP resources and IT budgets on the Cloud. I decided to build Logic Apps for SAP Infrastructure controlling purposes to integrate with SAP Application and VM altogether.



With Logic Apps, Basis folks of any organization can take complete control of shutting/starting the Sandbox/Development/Training/QA -SAP system not being heavily used after business hours or over the weekends. Along with this idea, Basis Manager/Leader will receive a list of logged-in users directly in an e-mail before pressing the 'Shutdown' button that too from e-mail only. Sounds interesting!!!

In General, to build the Logic Apps, you can use one of the already existing templates. It’s a terrific way to learn and understand how the workflows are designed, and I highly recommend spending some time reviewing them. Hence before we jump into the main topic, I suggest you play around with Logic apps to see many outstanding features. My reaction to it until now has been none less than wow! You can do so many things using this Azure Service for SAP workloads. Awesome!!

 

Creating Sample Logic Apps - Quick look for beginners!


Go to Azure Portal and enter the Logic Application pane to create your first workflow and click +Add. Fill out the form with the app name, resource group, and location. Confirm by clicking Create. To build the Logic Apps, you can use one of the already existing templates on the dashboard. There are more than 40+ ready-to-deploy templates available and including the SAP Connector template too.


See below sample Architecture for Idoc flow from SAP to external documents. To run this similar scenario, you can refer to this article as well created by db8ac33b71d34a778adf273b064c4883


<Sample Architecture>


 



(Source: Microsoft Learning)

This solution aims to facilitate a controlled shutdown/startup of SAP on Azure systems, a common request from customers who want to save costs by shutting down environments that are not in use, as I explained earlier. This custom scenario doesn’t have a predefined template, so I chose to create a Blank Logic App to build everything from scratch.
(Source: Microsoft Learning)





Source Bing

 

Curtain-raiser on our Architecture scenario


Let's understand the architecture workflow before we build and run the scenario. I'd like to spend a moment explaining how the workflow works here. Just imagine for a second and consider Logic App a giant mothership controlling all flying saucers, aka. SAP, workflow, JSON/XML, Azure VMs, and required human intervention sitting on the ground (using outlook throttle!) to decide the ultimate action.

Ok, cool, so how does this map to the cloud flow? What tools are required, Huh? Let's see!



 

 





List of prerequisites in order:



  • Access to Azure VM running SAP application

  • Access to SAP Application (ECC, S/4HANA, NetWeaver)

  • Access to Azure Account with Subscription

  • An email account from a service that's supported by Logic Apps (such as Office 365 Outlook or Outlook.com), other Emails like Gmail are supported as well. (I haven't tested yet)






Steps



  1. Created Azure Logic App with Blank name
    SAP_Auto_mail_shut_Controller_App_amit <your-Logic-app-name>, click on Azure Logic App Designer under the Development tools panel, as shown below.



 

2. Create a first HTTP trigger to run a Logic app

Search for workflow "request" and select "When an HTTP request is received." And you will get an automated URL generated by workflow after you save the Logic apps. This URL can be triggered through the POSTMAN utility using POST as well, or you can create a scheduler with a specific time for triggers on a daily or weekly basis, for example, 6pm every day or 5pm every Friday, it's highly flexible to schedule.






 

3. Setup an SAP Connection and select the SAP Table to fetch details. 

This step is crucial from a workflow perspective, here we will connect SAP to fetch the list of active users logged in SAP during that point in time when workflow triggers. This will help Basis decide to shut or keep running the SAP system based on the number of users count, including their usernames and terminal details. Follow -

  1. Click on + sign under HTTP Request, search for SAP and select "Send a message to SAP."

  2. Click on the SAP Action folder icon and pickup RFC_READ_TABLE

  3. Insert XML details into "Input Message" shown below. We are fetching a list of users from SAP Table USR41.  Additionally, you can add the batch table to see active batches running in the system if required. (I'm just covering the user list for now!)


<RFC_READ_TABLE xmlns="http://Microsoft.LobServices.Sap/2007/03/Rfc/">
<QUERY_TABLE>USR41</QUERY_TABLE>

</RFC_READ_TABLE>


 

SAP API Connection Details to fill, I did not activate SNC connection, SAP recommends activating for production connectivity. This is the main API connection screen!



 
⚠️Note, please don't proceed unless you see the successful connection here.⚠️

 

4. Data Operations - Compose stage

At this step, search for "Data Operations" and select "Compose," as shown below.


 

Under compose, add Expression in FX box, show shown below
It converts SAP table output to JSON readable format.

json(xml(body('Send_message_to_SAP')))



 

5. Parse JSON to fetch the relevant data using JSON schema

Here we will parse JSON output to get relevant array/objects in the JSON file underneath.

  1. Select Content - "Outputs" from the list

  2. Add JSON Schema using sample payload to generate the schema.


You can generate JSON schema using http://jsonschema.net/ or Use sample payload to generate it.

 


 

6. Initialize the Variable and append it to an array variable. 

This task is part of initializing array and append array variables for loading data.

Compose the output as well,
first(variables('test'))['RFC_READ_TABLEResponse']['DATA']['TAB512']['WA']



 

7. Setup the Outlook with options

Create workflow - "Outlook with options" and insert User Options - YES - Shutdown, No -Shutdown, Add Subject and Body with {outputs}, as shown in the screen. You can manipulate the Email body using HTML code as well.
If you see "Show HTML confirmation dialog," I opt yes here since I want the workflow to open a new browser session to get my final confirmation for my decision!


 

8. Apply conditional check with the selected output from the previous email

Here we have a condition workflow to re-direct Logic app flow based on the user's prior selection on email.

  • If the Email outcome is YES selected by an Admin/Basis user, then the logic app condition goes to the True side and follows the following workflow.

  • If the Email outcome is No selected by an Admin/Basis user, logic apps will check the VM's status and close the loop.


 


 

9. SFTP-SSH workflow Action now

Once the workflow is True, compose data operations workflows got the SelectedOption = Yes. We select the "SFTP-SSH" action workflow to directly create a new file under /tmp directory in SAP VM. This will create a custom "python program" to stop/start, and cleanup commands simple script.

Please ensure python3 is installed on SAP VM. (Link to download), I created this sap stop program in python 3.6 since it's one of my favorite ones. Feel free to write in PowerShell or bash scripting, no restrictions here since the logic app flow will be the same at the end. You can change it to use the sapcontrol tool since STOPSAP & STARTSAP are old tools now.



 

10. Next workflow triggers "delay" and deletes python file ⚠️

Since it required 4-5min. to stop the SAP app and DB along with CLEANIPC commands. Once Python shutdown SAP, that file will be automatically deleted from /tmp directory to manually safeguard accidental shutdown. An extra technical step to ensure no trouble by human intervention or so. After SAP is down, another delay of a few min. (I took ~30min. your call to reduce it to 1min.) to trigger VM shutdown.

Optional - You can add another Outlook trigger after SAP and VM graceful shutdown to send the notification back to Basis Manager as well.

 



<**End of configuration, save your logic apps designer before you close the session**>






 

Time to Trigger the Button on Logic Apps



Source: Gifer


 

Go and save your logic apps and press the 'Run' button; before you do that, please ensure SAP is up and running and at least one user is active. Otherwise, you miss the fun! ⚠️


 

You will see Logic App, start here with HTTP request, and connect to SAP, and collect the data and parsed it for view. Now, Logic App triggers send Email on Outlook account and wait for following user action here.


 

Now, I see a fresh e-mail in my Outlook mailbox, Logic apps requesting your input/action.



 

Open e-mail, and check the users logged actively. I see just one user now, and that's mine only.

Optional -Now, SAP Basis Operations can send an e-mail requesting further to that user list asking to save the work and log out immediately or simply go ahead with the shutdown. Again, it's an operational and admin call!!

Now I'm going to press the blue button => "YES - Shutdown" shown below on Outlook e-mail.

 


 



It will pop up the Logic App URL asking for a final decision here. Since I enabled in e-mail setting above in step#7.
Again, I pressed Confirm "YES-Shutdown." (You can disable that as well; it will ask directly by e-mail.)


Receive the confirmation screen below!



Going back to the Portal workflow logic screen, it moves to the next level and creates a new python file that will further shut down SAP Application and DB.


 

Python file created successfully based on our Logic App workflow, and SAP graceful shutdown triggered as well.


Well! No surprises...This is rocking!danceydoge random



 

At this stage, Logic App design flow will delete this *py python file and wait for VM Shutdown now.


 


After 30min. delay scheduler completed, VM Shutdown triggered successfully, and VM is stopped here. Another rocking moment and thumbs up here!

Azure Admin Team can check run history in Logic Apps on a daily/weekly basis for monitoring purposes and keep an eye on the overall functionality.



Conclusion


Cool! That was quite the ride through some no-code process to trigger graceful shutting of SAP and VM and demonstrates how your SAP system uses automation tools and Azure APIs altogether. I would suggest you go ahead and try this scenario and share your SAP integration experience with Logic Apps, especially Dev, Training, and Sandbox systems that can be powered-off to save resources until they are needed again and highly recommended for pay-as-you-go customers. This will help reduce the IT overheads linked, which can be avoided for this simple automation. You can consider it for your SAP systems running on Azure today or planning for future workloads.

In the following article or so, I can provide you with insights on how the SAP start functionality can work. It will be reversed Logic apps and can be configured easily.

 


Your questions/comments are always welcome




 

💻💻💻Happy Reading, Happy Learning! 💻💻💻


 
Below are links to my selective technical and personal insight articles published on SCN on diverse topics.

SAP Sales Forecast using Automated Machine Learning {Azure AutoML No-code}

Integrating SAP Data in Snowflake using Azure Data Factory

Running SAP HANA on Azure Container Instance {ACI} from Cloud shell. 

The Three E-Elephants: EAI, ETL, and EII in Enterprise world

Power BI Vs. SAC - One-page reference

 



"Reading brings us unknown friends” – Honoré de Balzac."



 





Disclaimer
These are my individual opinions and thoughts. This does not represent any formal opinions, POVs, inputs, product roadmaps, etc., from my current or past employers or partners or/and any Clients.






 
  • SAP Managed Tags:
7 Comments
Labels in this area