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!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor

In the continued spirit of collaborating with karol.kalisz, I wanted to see if I could add some additional utility to his new Design Studio SDK: Array Util Component.  This was born out of a need to do things you'd want to do with arrays such as How to get "Top X" our of resultset, for example.

Next up is that I wanted to get back a for loop in BIAL.  We have a forEach loop but for loops are not yet allowed.  Karol also added me as a co-author to his GitHub repository (KarolKalisz/DesignStudioSdkPack · GitHub) so I figured I'd see how easy or hard it is to use GitHub as intended as a code check-in and collaboration tool versus just a sharing code site.

So, I've enhanced DesignStudioSdkPack/contribution.ztl at master · KarolKalisz/DesignStudioSdkPack · GitHub with a new method called 'eaches' -- This also is an example of how you can markup your ZTL code with some JavaDoc information for your BIAL scripters to know what things do.

The code:

  Generates an array of integers for use in BIAL forEach statement in order to emulate a traditional for loop.
  Fill a list box with 10 values:
  <code>ARRAY_1.eachesAsString(0, 9, 1).forEach(function(element, index) {<br>
  LISTBOX_1.addItem(element, "Item " + (element + "") );<br>
  This would be equivalent to a loop in JavaScript:
  for(var element = 0;element<=9;element++){<br>
  Your code here.<br>
  Array eaches(/*Starting int*/ int start, /* Ending int */ int finish, /* Interval increment */int interval) {*
  var a = [];
  for(var i=start;i<=finish;i+=interval){
  return a;

That's it!  What's it do?  The code documentation is shown above, but it's a bit easier to read during BIAL scripting time:

As we can see here, a little effort in documenting will help out your BIAL scripters know what the method does, so as we see in this tooltip, it does (or should do) what I mentioned, which is a for loop.  Let's click the Button and see what the results are at runtime:

Looks like it's working!  :smile:

As far as my experience with pulling down Karol's repository, that's easy.  I suggest using 'GitHub for Windows' unless you are a big PowerShell fan, the GUI version is very easy to use.  Here's the main interface, with some of my own repos aas well as Karol's:

I right-clicked his repository, and cloned it to a location on my hard drive.  Next, I switched to my Eclipse SDK and went to File -> Import... and browsed to the location and chose the subfolder containing the project I wanted to import.  In this case, it was 'org.kalisz.karol.scn.pack'.  I unchecked 'Copy projects into workspace' since I wanted it to stick with the Git repo clone location.  Below is an example of what an Eclipse project looks like when it senses there is a Git repo associated with it.

I then made modifications mentioned at the beginning of the blog to the contribution.ztl file.

Once I was done coding and testing on my local repo, I wanted to commit the changes back to Github.  After fumbling around, I found the context menu path to do so:

I was then prompted to describe my change, which I said "Added 'eaches' method to Karol's Array component." and then clicked 'Commit and Push'.

When switching back to my GitHub for windows, I could see the changes in the history, as well on on the web.  Success!

I'm sure for GitHub veterans, this is child's play but for me this was easier than I expected.  There's a bunch of other stuff I'm sure GitHub is good at doing indicated in the context menu screenshot, but this was good for now :smile:

Labels in this area