Skip to Content
Product Information
Author's profile photo Frank Müller

AMDP Pretty Printer

Maybe you know the blog post from Thomas Fiedler Where to hell is the Pretty Printer?

Since 2019 I am wondering where to hell is the Pretty Printer for AMDPs.

The SAP standard Pretty Printer (ABAP Source Code Formatter) does not really format the AMDP source code.

Therefore, I developed in my spare time an AMDP Pretty Printer. It is not an SAP product.

It has the following main features:

  • Write key words upper case and the rest lower case
  • Indent the AMDP (SQL) source code of the class
  • Leave the ABAP part of the class as it is

Here is a short demo:

The AMDP Pretty Printer consists like the SAP ABAP Development Tools of a Rest Service in the SAP Development System that contains the Pretty Printer logic and an Eclipse Plugin that calls the Rest Service and adjust the coding.

You can find it with an installation manual on my github account (MIT license).

https://github.com/fmabap/AMDP_Pretty_Printer

It saves me a lot of time during the development of AMDPs and it makes the source code more legible. I’m sure it will help you, too.

I’m looking forward for your feedback.

Best regards

Frank

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo AjeethKumar R
      AjeethKumar R

      Really a great work Frank. Thanks for bringing this.

      Author's profile photo Frank Müller
      Frank Müller
      Blog Post Author

      Thank you AjeethKumar R.

      Author's profile photo Peter Inotai
      Peter Inotai

      Thanks Frank for this add-on.

      It's a pity that it's not part of standard, but I like the idea that the ABAP community is implementing such useful functionalities as an add-on.

      I don't work much with AMDB yet. However I've installed on our S/4HANA sandbox system. It works fine and it's very useful.

      Report ZAPP_PRETTY_PRINTER_TEST is very nice, too.

      Author's profile photo Frank Müller
      Frank Müller
      Blog Post Author

      Thank you Peter. The ABAP community is great. Unfortunately, is the ADT SDK not so well documented like for example SAPUI5. I think there would be much more great community tools, if SAP would invest in it.

      Author's profile photo Nagamani Lb
      Nagamani Lb

      Hi Frank,

      I tried the pretty printer in Eclipse version 2022-03, but it doesnt work. If i click on the pretty printer button i am getting the below error, can you please advice.

       

      Error

      Error

      Author's profile photo Frank Müller
      Frank Müller
      Blog Post Author

      Hi Nagamani,

      sorry for the late reply.

      A colleague of me had a similar issue. Therefore, I added more details to the error message.

      See also here: https://github.com/fmabap/AMDP_Pretty_Printer/issues/7

      As he tried the new version then the error did not appear again (whyever).

      So please try the new version.

      Best regards

      Frank

      Author's profile photo Nagamani Lb
      Nagamani Lb

      Hi Frank,

      Thanks, its working after installing the ABAP program from git. There is one issue with the pretty printer, when we have an in line code in the sql statement, the pretty print is taking the code next to the comment to the next line and it produces incorrect results, can you please check and correct this in your next version.

      For e.g.
      lt_Result = select * from employee
      where eid = '101'; -- and ename = 'John';

      After Pretty Print

      lt_Result = select * from employee
      where eid = '101';--
      and ename = 'John';

       

       

      Author's profile photo Frank Müller
      Frank Müller
      Blog Post Author

      Hi Nagamani,

      I tested your issue with the test program ZAPP_PRETTY_PRINTER_TEST. The issue did not occur in my system.

      Screenshot%20Test%20Program

      Screenshot Test Program

      Can you please check, if you have installed the latest version of the AMDP Pretty Printer and if the issue occures in this test program in your system.

      If it occures, then please post here your example as coding block. So that there are no formatting issues.

      Please post also, which configuration you chose in the transaction ZAPP_SETTINGS. You can find more details regarding the configuration here:

      https://github.com/fmabap/AMDP_Pretty_Printer/blob/main/doc/Configuration/README.md

      You can find further information regarding the test program at the end of this page (older version).

      https://github.com/fmabap/AMDP_Pretty_Printer/tree/main/doc/Installation

      Thanks and best regards

      Frank

      Author's profile photo Nagamani Lb
      Nagamani Lb

      Hi Frank,

      I found the issue, its happening when there is no space between ; and the comment(--). Please check the below screenshot. Is there any resolution for this.

       

      Author's profile photo Frank Müller
      Frank Müller
      Blog Post Author

      Hi Nagamani,

      great, thank you.

      I think I could fix it.

      I created the github issue 19 for it.

      https://github.com/fmabap/AMDP_Pretty_Printer/issues/19

      Can you please check it?

      The coding with the fix is in the new branch "#19-comment-after-;-without-space".

      https://github.com/fmabap/AMDP_Pretty_Printer/tree/%2319-comment-after-%3B-without-space

      When you checked it successfully, then I will merge it to the main branch.

      Best regards

      Frank

      Author's profile photo Matthew Billingham
      Matthew Billingham

      Just saw this. Can you add the tag #plugin so I can find it again!