Skip to content

"Align parameters and components": Align assignments across multiple parenthesis in one VALUE #54

Closed

Description

@ConjuringCoffee

Hi Jörg-Michael, I'm sorry to open another issue for rule "Align parameters and components" - I hope I don't annoy with this... 😅

This issue is about the option "Align assignments" in a VALUE statement to create an internal table. Example:

  METHOD example.
    TYPES: BEGIN OF ly_type,
             short       TYPE i,
             medium      TYPE i,
             longer_name TYPE i,
           END OF ly_type.

    DATA lt_example TYPE TABLE OF ly_type WITH EMPTY KEY.

    lt_example = VALUE #( ( short       = 1
                            medium      = 1
                            longer_name = 3 )
                          ( short  = 2
                            medium = 2 )
                          ( short       = 3
                            longer_name = 3 ) ).
  ENDMETHOD.

The second table line is aligned based on its longest component name medium. Instead, I'd like it to be aligned to the longest component used (in this case longer_name):

  METHOD example.
    TYPES: BEGIN OF ly_type,
             short       TYPE i,
             medium      TYPE i,
             longer_name TYPE i,
           END OF ly_type.

    DATA lt_example TYPE TABLE OF ly_type WITH EMPTY KEY.

    lt_example = VALUE #( ( short       = 1
                            medium      = 1
                            longer_name = 3 )
                          ( short       = 2
                            medium      = 2 )
                          ( short       = 3
                            longer_name = 3 ) ).

    lt_example[ 1 ]-longer_name = 1.
  ENDMETHOD.

For completeness, here are my settings:
image

Activity

  1. changed the title [-]"Align parameters and components": Align assignments across multiple VALUE lines[/-] [+]"Align parameters and components": Align assignments across multiple VALUE table rows[/+] on Jun 9, 2023
  2. changed the title [-]"Align parameters and components": Align assignments across multiple VALUE table rows[/-] [+]"Align parameters and components": Align assignments across multiple parenthesis in one VALUE[/+] on Jun 9, 2023
  3. jmgrassau commented on Jun 9, 2023

    @jmgrassau
    Member

    Hi ConjuringCoffee,

    another issue on "Align parameters and components" is not a surprise, given that it is a rather complex rule!

    And you're completely right, alignment should work (at least by default) across these table rows; that has actually already been on my list…

    Kind regards,
    Jörg-Michael

  4. self-assigned this
    on Jun 9, 2023
  5. jmgrassau commented on Jun 10, 2023

    @jmgrassau
    Member

    Hi ConjuringCoffee,

    this should work now :-) If I enter

        ets_table = VALUE #( date = gc_any_date
                               id = gc_any_id
    
                               ( item_name = 'ANY'
    *                      size = 'M'
                                  quantity = 1 )
                                 ( item_name = 'OTHER'
                                    quantity = 2
                                    reference_id = '12345' )
                                       ( item_name = 'THIRD'
                                      quantity = 3 ) ).

    activating the new option
    image

    the "Align parameters and components" rule produces:

        ets_table = VALUE #( date = gc_any_date
                             id   = gc_any_id
    
                             ( item_name    = 'ANY'
    *                           size         = 'M'
                               quantity     = 1 )
                             ( item_name    = 'OTHER'
                               quantity     = 2
                               reference_id = '12345' )
                             ( item_name    = 'THIRD'
                               quantity     = 3 ) ).

    Deactivating the option leads to the previous behavior:

        ets_table = VALUE #( date = gc_any_date
                             id   = gc_any_id
    
                             ( item_name = 'ANY'
    *                           size      = 'M'
                               quantity  = 1 )
                             ( item_name    = 'OTHER'
                               quantity     = 2
                               reference_id = '12345' )
                             ( item_name = 'THIRD'
                               quantity  = 3 ) ).

    Kind regards,
    Jörg-Michael

  6. jmgrassau commented on Jun 12, 2023

    @jmgrassau
    Member

    Hi ConjuringCoffee,

    thanks for the "hooray emoji(s)" :-) And again, very good point, this has now really improved the optics of such VALUE statements.

    Kind regards,
    Jörg-Michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions