Skip to Content

Pretty printer for Modified code only

It's generally not a good practice to use pretty printer on existing code. However, it would be really nice if Pretty printer can be used and only new/modified code is formatted. Old code remains as it is. Is there a way to do so?

I tried to search for such an SAP note before asking the question here. Could not find any helpful note.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Dec 19, 2016 at 10:34 AM

    Gaurav,

    "It's generally not a good practice to use pretty printer on existing code".

    It is indeed a good practice to use Pretty printer irrespective of whether it is a new code or existing code.If a developer hasn't used it previously then we need to set it right by using it now.If you are worrying about the version management differences then you can check "ignore upper/lower case" checkbox in the comparision options of version management.Pretty printer is a nice feature whose usage should be encouraged and not skipped.

    K.Kiran.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 19, 2016 at 07:29 PM

    It isn't an option to just pretty print your modified part. Within eclipse you may be able to write an extension which will be able to do so, but I think that is a very high effort for such a small use case.

    Sorry, but the short answer is "no" :-(

    ~Florian

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 19, 2016 at 09:11 PM

    Hi,

    I know you said no work around, but as you already know by now - that's the only choice you've got :)

    So I would suggest writing your code on some local object ZTEST kind of program and format your code there and then copy and paste it back to where you need to be.

    Another option is to write your code in a method/subroutine/function that is in a separate include (of which you can pretty format) thus reducing your code to a single line in the altered code.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 19, 2016 at 10:47 AM

    Hi Kiran,

    Thanks for your response.

    I am aware of ignoring cases and indentations. What if that is not an option?

    Is there a way to make sure that pretty printer works only for the newly added code? Not looking for any work around.

    Regards,

    GK

    Add comment
    10|10000 characters needed characters exceeded

    • No. You have two ways of pretty printer: the classic "pretty printer" button (whole code), and context menu in the dynpro-based ABAP editor "Format selection" to pretty print the selected text, but this is different from the classic pretty printer, with no formatting option. I don't know whether there are other options in Eclipse.

  • Dec 22, 2016 at 11:04 AM

    Hello Gaurav,

    Actually there is an option in Eclipse - Format Block(Ctrl+Shift+F1) which you can use to format the selected text.

    I am not sure if this is what you are looking for?

    @Sandra:

    "context menu in the dynpro-based ABAP editor "Format selection" to pretty print the selected text" - Tbh, i did not know such a feature existed in the GUI Editor.

    "but this is different from the classic pretty printer, with no formatting option" - What do you mean by this? Screenshots, maybe :-)

    BR,

    Suhas

    Add comment
    10|10000 characters needed characters exceeded