SAPscript forms breakdown tool
“SAPscript forms breakdown helper” is a free tool for analysing forms. It has different features to help you understanding the structure of a form and the used SAPscript commands. Therefore you are quickly ready to decide what has to be changed to fulfill your requirements. Please note that you cannot make changes to a form with this tool. That’s the task of transaction SE71 which you can easily call from the tool.
Current version is 2017.2-01 (23.04.2017).
Please pay attention to the license, disclaimer and installation section at the end of this blog. It is not recommended to use this tool in productive environment.
Download latest version from GitHub.
A reduced german translation of this blog is available on Berater-Wiki.
2017.2-01 (23.04.2017): navigation to source code of subroutines | statistics (enfolded different metrics like source lines of code (SLOC), McCabe and Halstead)
2017.1-01 (01.01.2017): navigation to included text via transaction SO10 | better F4 help to select a form on selection screen
2016.4-02 (01.11.2016): edit line via transaction SE71 in same and new window
2016.4-01 (03.10.2016): easy color selection via selection screen | update checker | collapse and expand of blocks
Using SAPscript forms to output document data is a long time used and well proofed technique. New projects normally do not make use of this aged technique but there are still a lot of forms in use. Therefore many programmers will face the same scenario some day: You will have a requirement to change an existing SAPscript form. And that’s not easy, especially when different conditions in combination control the program flow.
In this context I remember one sentence of the book “Back to Basic” (John G. Kemeny, Thomas E. Kurtz): “Programmers now generally agree that indentation, properly used, helps them understand programs” (page 35). In forms there is as far as I know no automatic indentation and that makes understanding program flow extremely difficult.
So please have a look at my approach to make it a lot easier to understand a SAPscript form and save time by planning your changes goal-oriented. I wrote an ALV tool with the following features to support breakdowns.
Please note that the following screenshots are just for demonstration purpose.
The missing feature to make it a lot easier to analyze a SAPscript form. Actually it works with IF, ELSE, ENDIF, CASE, WHEN and ENDCASE statements. In the ALV you have two columns: “Original” and “Adapted”. Only the “Adapted” column use indentation and so you have the option to compare with the original source.
A nice feature to identify the partner of a IF or CASE statement. You can double click on IF, ELSE, ENDIF, CASE, WHEN and ENDCASE statements. Double click is only working on the “Adapted” column.
Integration of Form Painter (transaction SE71)
In context menue (right click) you will find two functions called “Edit line in same window” and “Edit line in new window”. By these functions, you can easily switch between doing breakdowns and changing a form. Please note that both functions will only work with up-to-date releases of SAP Basis like 7.50 and you have to deactivate the graphical editor in “SAPscript” section of your personal settings.
To get a fast evaluation of a form, you can use the function “Show stats” (have a look at the context menue). You will find different metrics like source lines of code, McCabe and Halstead. To be fair, I’m still thinking about the benefit of some Halstead measures like “Difficulty” in context of SAPscript. So please do not pay too much attention to these measures at the moment – I will have to spend more work on this topic later.
Navigation to subroutine
You can double click on an PERFORM statement. The software will forward you to the source code of the subroutine. That’s nice to easily get a clue of what is happening with the parameters of the PERFORM statement.
Integration of Standard Text (transaction SO10)
You can double click on an INCLUDE statement. The software will forward you to the selection screen of transaction SO10 and all fields are filled with proper values of the statement. Please note that this feature will only works with static standard text.
Collapse and Expand
You can collapse and expand IF/ENDIF and CASE/ENDCASE blocks by the symbol in the column “Collapse/Expand Icon”. Please note that this feature is implemented with ALV standard filters. If you work with additional filters please do not change the values in the field “Collapse/Expand Id”.
Colors are a good instrument to distinguish different formats. You can set up to 4 different colors to mark lines. On selection screen, you can choose them from a dropdown list or you can define the colors by their color codes. Choose the option “individual” from the corresponding dropdown list to open the “Color code” field for input. Have a look at the internet for an ALV color palette (for example http://www.kerum.pl/infodepot/00005).
Up to 5 symbols will be detected in an SAPscript statement. The symbols will be placed in own columns of the ALV, called “Symbol 1” and so on. Therefore you are able to sort by your needs.
Copy to Clipboard
You can simply copy the content of the “Adapted” column to your clipboad and paste it into your form (SE71). You will find the function by using the context menu (right click). Mark one or more rows first.
You can simply look out for new versions of this tool via the update check button on selection screen. Your version is shown next to the button. By pressing the button your standard browser will open this blog. There you can compare with latest version and download if necessary.
There are ideas to implement new features or to improve existing ones. Here are some of them:
- In combination with a printer program it’s possible to get additional data dictionary information about program symbols.
- Bring your own code (BYOC): To bring your source code and the latest release of this tool in line, different user exits would be useful.
If you have any ideas for more features: You can implement them by yourself or you can contact me to implement them. Anyway it would be nice to share your ideas.
License and Disclaimer
In very simple words: It’s free. Until now it was an interesting and funny free time project, not more. The idea was to make life of every developer, consultant and user a little bit easier. If you can save one minute by using this tool you have one more minute for coffee break and to talk with your friends and colleagues about new ideas. So please feel free to use it, to improve it and to share it (not sell it).
I do not take any responsibility and I am not liable for any damage caused through use of this tool. Use it at your own risk. It is not recommended to use this tool in productive environment.
I put all source code in one report (have a look at the attached file). That makes it easy to adapt it to your development system. I had to apply some perhaps unusual techniques to implement features I want because everything had to fit in one report. So please forbear with me.
Instead of right click menu you can work with your own GUI Status as long as you will use the same function codes.
Thanks for sharing it. I tried it quickly and found it really useful.
I didn't like the color codes in the selection screen, but not a big deal, played around until I liked it and saved it as a variant.
One more idea:
Collapsing IF-ENDIF block could be also useful to implement similar to new ABAP-Editor, however I'm not sure how difficult it would be. Just an idea 🙂
at first thanks for testing the tool and your feedback 🙂
You are right, color codes are really user-unfriendly. I think dropdown-lists with predefined color codes and corresponding caption would be the better choice.
The idea of collapsing IF-ENDIF blocks is great. Complexity could be easy reduced by a feature like that. I think it should not be as hard as it sounds to implement because we can use the values of column "Level" to identify a block. With a new column consisting of an icon like "+" or "-" next to the column "Adapted" the user can expand or collapse a block (unhide or hide some lines).
I think I can implement the two features with the next version of the tool.
A drop down approach would be great for the color codes.
"I think I can implement the two features with the next version of the tool."
That sounds great, thanks!
Just noticed that there is a new version, so I quickly installed it.
I like the color codes in the selection screen this way much better and also the Collapse/Expand feature. Thanks for implementing them!
nice to hear that you like the new features. And thanks again for testing them.
At the moment I'm thinking of a easy way to integrate transaction SE71. In my opinion most people will first analyse the form, then change or enhance the form. So the tool should offer an easy possibility to switch to the proper SAPscript lines. Perhaps a call transaction with batch input could be a solution. I will check that soon.
Maybe it's also worth to check how the download/upload tool (RSTXSCRP) implemented saving the changes, it could be easier than batch input.
For GC_SPACE, to "simplify the distribution", you may change it to :
For me in the editor when I copied and pasted the code from notepad came a popup if I want to convert the special characters. I just pressed no, and it worked fine.
Same thing. Anyway, it's better to explicitly show the "no-break space" in the code (even the name of gc_space -> gc_nobr_space).
Yeap. I agree.
thanks for your tip. I will check that as soon as possible. It's always a good idea to keep things clear and simple. To have everything in one big text file is a great advantage and user friendly 🙂
So easy to use and very useful. Thanks a lot Michael..
you're welcome. There are a lot of ideas to make the tool better. Next version is coming and hopefully it is still easy to use but more useful than today ... 😀
Pardon my silly question here. But I did not see attachment in the blog.
Based on the reply on the blog I am eager to use this. But Seems I am not good at finding attachment here.
Thanks for your help here.
I have to excuse oneself for the missing attachment (source code).
As I noticed that, I talked with the support team (at this point my thanks goes out to Kirill, Monika, Dan and all other helpful people). They told me that my blog was moved when SCN was upgraded and attachments were lost because the function to have attachements is not existing anymore.
At the moment I'm looking for web space to store the source code and to link it in my blog. Then everyone would be able to download it as it was possible in the past.
As a fast solution for the problem: Everyone who is interested in using the tool, please get in touch with me. There is an option to send direct messages in SCN. If you send me your e-mail address I can send the source code to you.
Thanks for the new version (2016.4-02).
Just had a quick look.
Unfortunately I got syntax error in basis release 7.02 due to the message statements with &&. After changing them it worked fine. BTW I also got a warning for gc_burl3, because the value was longer than the definition.
What I liked:
- jumping directly to the line is really nice feature
What I would like:
- the F4 help for the the form in the selection screen jumps to the tree view, but I personally prefer the characteristic search (just like in SE71: Form -> Find).
It's nice to see that this tool is getting better and better 🙂
as always: Thanks for your help!
My development platform is a basis release 7.50. I will not use new syntax elements in future releases of the tool to avoid problems as you described. The current problems will be fixed as fast as possible.
I will check your idea with the F4-help. The tree view help is really not a good F4-help.
sorry for the long delay. I had a lot of things to do. Unfortunately further development had to wait. But now new version is ready. Syntax errors and warnings are repaired. F4 help is enhanced. You can decide which one you want to use. And forward navigation to transaction SO10 is integrated. Just double click on a static include statement. Furthermore I did some research on forward navigation to transaction SE38 by double clicking on a PERFORM statement. Perhaps that's coming with next version 🙂
Thanks a lot for the update.
F4 help is really nice. 🙂
SO10 is also a good idea, however most of the time I use dynamic ones.
PERFORM would be also useful, I'm looking forward to it 🙂
BTW it would be useful to add a feature list to the blog every time you have an update. This way it's immediately visible what was changed, what is new without going through the comment section of this blog.
Just stumbled upon this. Interesting tool. Thanks for sharing!
you are welcome. As you said: interesting – the tool offers some possibilities for more useful functions.
Here is an example: At the moment I’m thinking about the idea to calculate a score. The concept behind the score is to easily see how complex a part of a form or even the entire form is. Could be an indication for how many hours a developer has to spend to change something or how many time a tester should spend.
Thanks for the notification about the new version:2017.2-01 (23.04.2017).
I had problem again on 7.02 system, but they could be fixed in 10 sec 🙂
I also noticed if I select the ALV layout in the selection screen, it's not taken in the result screen.
SO10 picked up the whole line as value (Example line: INCLUDE 'SD_RVADIN01' OBJECT TEXT ID SDVD PARAGRAPH HT, in SO10 it tried the whole to display "SD_RVADIN01 OBJECT TEXT ID SDVD PARAGRAPH HT").
I have to admit, I never heard about McCabe and Halstead before. Now I have something the read 🙂
thanks for your tests. Sounds like homework for me 🙂 Will fix the problems as soon as possible. And please tell me about your experience with the statistics in private chat. I think there are a lot of improvements to do. But first step is done ...
helpful stuff indeed.
But when printing the ALV-result, the <space> used for indenting is translated into <#> which overthrows most of your efforts. I therefore added a new paramter on the selction Screen and moved the relevant coding to another place. You will easily identify my changes by todays date.
If I just could get the coding transmitted to you.... I could not find an "attach"-button in here. 'am just too dumb 🙁
thanks for your help to improve the tool. I don’t know any function to share source code in a SAP community network blog. Therefore please send your source code to <deleted>.
I will adopt your changes to my latest version.
Best regards and thanks in advance
what a great stuff ... 🙂
After using for a while I found that I'm missing one more function, which could be useful for others to = ACTIVATE
Now we have to click CHANGE + Menu <Forms> <Activate> + F11 + F3
This is some work if you want to activate (Transport) more than one SAPscript
Maybe you could think about 🙂
thanks for your idea. Please contact me by mail (<deleted>). We can discuss your idea better by mail.
Thanks in advance and merry christmas
Really useful program. Many thanks for offering it to the community.
Would it be possible to add the possibility to choose between a form or a standard text at selection screen?
scenario: We have many scripts inside standard texts as includes. These includes are complex as the form, but of course without windows, pages, etc. The need is to be able to indent the content of a standard text.
This scenario could be added when working in a form, you have a not dynamic standard text as include, in that moment you could be able to open it in another window/session indented. If finally you need to edit it, it would be opened in SO10 as you currently are doing.
I guess most of code should be practically ready.
do you think would it be feaseble?
thanks and best regards,
Thanks for your request, Luis Rodriguez. I quit my work on this tool back in 2017. No further updates on this tool are planned.
Thanks for sharing this! Very useful when verifying lots of code inside the script form after remediation. Make life easier!
You're welcome. In the meantime, I wrote a business-ready solution with automatic analysis and reporting of many SAPscript forms at once. A lot more advantages are included. But that's a retail version.
Thanks for the info.
Recently I use these tools intensively and find one observation of version 2018.x-01: If one script form has multiple languages, some languages have specific windows while others don't. The return of FM 'READ_FORM' contains the correct windows while form_lines contains all the lines even though this language doesn't have that window.
I just loop each window from gs_form-windows and filter gs_form-lines by TDWINDOW before APPEND ls_lines TO lt_lines inside the FORM alv_data_prepare. After this update, I could skip lines from Windows which not existed for specific languages.