Scripts are, in short, one of the winning points of SAP Sourcing. As much as I appreciate the technology behind them (myself being a core java dev), they present huge gaps when it comes to methodology of development and maintenance.
The methodology in this case translates to either editing scripts directly in SAP Sourcing (yes, some people are masochists) or a low-level copy-paste. I cannot stress enough about the issues that can arise out of this.
This blog post will cover my recommendations for scripts on:
- Editing – editor, formatter
- Maintaining – source control maintenance, git, SourceTree app
Editing SAP Sourcing Scripts
When I’m not coding in Eclipse, my editor of choice for SAP Sourcing scripts (for Windows) is SynWrite (download here).
After installing SynWrite, we’ll add two plugins for it:
- Java lexer
- Code formatter
Adding java lexer
- Open SynWrite and follow menu Options -> Add-ons manager -> Install
- Search for Lexer: java and double click, confirm installation.
- ***Optional*** – Configure java lexer to parse .bsh files (if you prefer to keep your scripts with .bsh extension instead of .java)
- Options -> Customize lexers library -> Java -> File extensions: java jav bsh
Installing code formatter plugin
- The formatter I’m using is a customised jsbeauty plugin.
- To install, simply open the formatter zip file plugin.Alexey.extended.JsFormat.zip (download here) in SynWrite and confirm installation. File -> Open
- Format your code using Ctrl+Alt+F or Plugins -> JS Format -> Format
Maintaining SAP Sourcing Scripts
Now that we have an editor that can ensure the formatting is consistent, and will not impact our SCM, my recommendation is to:
- Download all your scripts from SAP Sourcing, and maintain them locally on your system
- Use either script’s EXTERNAL_ID or DISPLAY_NAME as file name (with extension .java or .bsh) for easy identification.
- Install a SCM tool of your preference and keep your scripts version-controlled
I like SynWrite a lot compared to other alternatives (Notepad++ etc), because of the option to have a good formatter and a neat tree structure which shows all your functions in the script (cool!).
- SOURCE CONTROL MANANGEMENT
Just compare what ever you are using as methodology (manual backups, oma extracts, attachment blobs etc) with the screenshot below.
If you’ve followed on to this point you might be having two questions:
- Can we have code autocomplete and validation like in a full-fledged IDE?
- NOT in SynWrite or other editors you might be using.
- YES, it can be done in Eclipse or Netbeans; I am using such options within Eclipse. BUT, coding beanshell in Eclipse is (for the moment) way too complicated to qualify for a public release or recommendation.
- What’s the point of all of this, if it doesn’t solve the initial problem – having to copy-paste scripts from local files back into SAP Sourcing?
- This post aims to provide a <<phase-one (the basis)>> for script management – getting the files in a coherent format into a version-control system.
- In the next couple of days (stay tuned) I will release the <<phase-two>>: A tool that will automatically deploy your scripts from your SCM into Sourcing. So make sure you get your scripts in a local format under version control as soon as possible.