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: 
sajid-khan
Explorer

Introduction

Identifying the changes present between different versions of workflow templates can be a challenge. Unlike other objects, there isn't a built-in functionality for direct comparison. Manually scrutinizing each step of the templates side-by-side can be both tedious and error-prone.

This lack can be frustrating, as I’ve witnessed firsthand through inquiries from few of my colleagues struggling to identify changes between versions for troubleshooting or maintaining consistency across environments. Fortunately, I’ve been able to help them by employing a couple of effective techniques that help bridging this gap.

While there are few solutions available online, I haven’t encountered a comprehensive resource specifically dedicated to guiding users through this process. Therefore, I’m writing this post with the hope of empowering you with effective method for comparing workflow template versions in SAP. Additionally, it serves as a future resource for my colleagues whenever they encounter similar challenges, allowing me to simply direct them to this guide.

Comparing Workflow Templates

Gearing Up:

  • For this post, I’ll be using two workflow templates which are nearly identical, except for a few differences which I have deliberately introduced in order to demonstrate the process.
  • We are going to need a text editor which supports two key functionalities: “Find” feature using regular expressions, as well as has feature to compare two text files (diff tool). I will be using Visual Studio Code for this as it offers both features seamlessly.
  • We will be comparing the two workflow templates by exporting the templates as XML file and comparing the exported files in Visual Studio code. However, there's a catch. By default, these exported files may be compressed and lack proper formatting, making it difficult to see any changes. To address this, we'll need to format the XML files using the "XML Tools" extension within VS Code. This extension transforms the raw XML into a human-readable format, allowing us to easily identify any modifications/differences when comparing the files using the built-in diff tool.

Now that we’ve got our list of tools prepared, let's explore the steps to identify differences in two workflow templates.

Step 1. Export the templates as XML file.

In this step, we will open both templates in Workflow Builder (SWDD) and export the templates as XML file. The menu option to export the files can be found at Menu > Workflow > Import/Export > Export to XML File > Export Workflow as Internal XML

sajid5ts_0-1710317533969.png

Step 2. Open exported files in Visual Studio Code

In this Step, we will move the two exported files to a separate folder named “Compare” and open this folder in Visual Studio Code. To open the folder in Visual Studio Code, File > Open Folder command can be used from the menu bar.

sajid5ts_1-1710317533971.png

Step 3. Formatting the XML files

It can be seen that the exported XML files are compressed and do not contain proper indentation. We will need “XML tool” extension to convert these XML files to readable format so that the changes are easily visible when compared.

sajid5ts_2-1710317533976.png

The “XML tools” extension can be installed in Visual Studio code by following these simple steps:

  • Navigate to View menu.
  • Select Extensions
  • Search for “XML Tools” in the search bar
  • Click the install button.

sajid5ts_3-1710317533978.png

 

Once the “XML Tools” extension is installed, go back to the XML files, right click on the XML code, and choose Format Document With > XML Tools. Do this for both XML files.

sajid5ts_4-1710317533985.png

 

After formatting, the files will be transformed into a more readable format, similar to the files in following screenshot.

sajid5ts_5-1710317533991.png

 

Step 4. Comparing the two files

In this step we will finally compare the differences between two XML files. To compare two files, right click on first file and chose “Select for Compare”, then right click on the second file and choose “Compare with Selected”.

sajid5ts_6-1710317533992.png

 

The difference checker tool should now open in the main panel of Visual Studio code, and the differences between two files should be highlighted in Red and Green. An overview of all changes present throughout the whole file can also be seen at the right-hand side present in a panel called mini-map (highlighted in below screenshot). This mini-map offers a quick glimpse at all modifications throughout the files and facilitates scrolling when clicked on the highlighted part on minimap.

sajid5ts_7-1710317534001.png

 

As can be seen in the mini-map every difference present in two XML files is highlighted. However, the changes including workflow IDs, version numbers, and timestamps have also been highlighted. These differences aren't relevant to our goal. These irrelevant differences are creating noise in the difference checker tool, making it harder to identify the actual changes we're interested in. To address this, we'll strategically remove these irrelevant differences from both files, ensuring only the significant modifications remain highlighted.

To eliminate these irrelevant differences, we will leverage the Regular expressions powered “find” feature of Visual studio code.

Let's begin by addressing the discrepancies caused by different workflow IDs within the two XML files. Press Ctrl+F to open find feature, enter the workflow ID in the find box and replace all occurrences of workflow ID with an empty string. Do this for both files.

sajid5ts_8-1710317534009.png

 

In my case, removing the workflow IDs significantly reduced irrelevant highlights, however, the differences in "Changed Date" and "Changed Time" were still creating noise (highlighted below). To achieve a cleaner comparison, let's eliminate these discrepancies as well.

sajid5ts_9-1710317534015.png

 

Removing individual <CHANGED_ON><CHANGED_AT> and similar tags would not be efficient due to their multiple occurrences with  different enclosed timestamp within each XML file. Simple find and replace operation would not help because the timestamp enclosed within tags are different in same XML file. Instead, we'll utilize a regular expression to target all such tags effectively.

Here’s how to proceed:

  • In the Find input box, enter the following regular expression: <(CHANGED|ACTIVAT)_(ON|BY|AT)>[^<>]+
  • Enable the “Use Regular Expression” option (highlighted in screenshot below)
  • Replace all matched occurrences with and empty string in both XML files.

sajid5ts_10-1710317534023.png

 

The above regular expression effectively targets all occurrences of Changed/Activated on/at/by tags and replaces those with empty string.

While much of the noise was removed after performing above step, examining the mini-map revealed additional noise in the form of <VCYPOS>, <VCXPOS>, <LCXPOS>, and <LCYPOS> tags (can be seen in below screenshot). My understanding of these tags is that they represent the X and Y coordinates of object/node positions within the workflow. As we're not interested in these changes, we can eliminate them from both XML files as well.

To achieve this, we will use <(LC|VC)(X|Y)POS>\d+ Regular expression. Enter this regular expression in the “find” box and replace all matched occurrences with empty string in both XML files.

sajid5ts_11-1710317534030.png

 

 

Finally, with all the irrelevant differences eliminated, the comparison tool now displays only the four key changes within the XML files that we were originally looking for.

sajid5ts_12-1710317534038.png

 

With the help of highlighted differences, I found the following changes that were made in workflow template:

  1. The template name was changed from ZTICKET1 to ZTICKET2 (Line 6).
  2. The description of the template was changed from “Example workflow for Ticket system (V1)” to “Example workflow for Ticket system (V2)”. This can be noted in line 7.
  3. The Object ID, similar to the workflow template ID, differs between the files. This is expected and is irrelevant to our analysis. We could've removed it during the de-noising process if it had numerous occurrences.
  4. Further down the file (line 1118, as indicated by the mini-map), I encounter another important change.
    sajid5ts_13-1710317534040.pngThis modification suggests that the Expression binding of node 50 has been changed from &_WF_INITIATOR& to &AGENT& which is indeed correct and can be confirmed from below imagesajid5ts_14-1710317534044.png

 

Conclusion:

By following these steps, I was able to identify the exact changes that were made in the workflow template. This approach streamlined the process and ensured accurate identification of modifications made between different versions/templates of workflow.

I hope this guide has proven informative. Feel free to leave comments below with any questions or suggestions for further improvement.

Thank you for your time!

1 Comment
Labels in this area