Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Rename columns which have the same technical name

0 Kudos

Hey Guys,

I am needing help to Rename columns which have the same technical name in an ALV.

gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'LSTAR' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is shor text' ).

Problem is that i have 4 columns with the same technical name so this does not work.

Hope you can help me

Thx

1 ACCEPTED SOLUTION

mateuszadamus
Active Contributor

Hello mrsap99

Based on the comments under the question here is a possible solution.

Basically you had everything okay, just use the right column names.

gr_columns = gr_table->get_columns( ).

gr_column ?= gr_columns->get_column( 'FORML1' ). " <-- notice 1
gr_column->set_long_text( 'Formular Key 1' ).
gr_column->set_medium_text( 'Formular Key 1' ).
gr_column->set_short_text( 'FormKey1' ).

gr_column ?= gr_columns->get_column( 'FORML2' ). " <-- notice 2
gr_column->set_long_text( 'Formular Key 2' ).
gr_column->set_medium_text( 'Formular Key 2' ).
gr_column->set_short_text( 'FormKey2' ).

gr_column ?= gr_columns->get_column( 'LSTAR1' ). " <-- notice 1
gr_column->set_long_text( 'Performance Type 1' ).
gr_column->set_medium_text( 'Performance Type 1' ).
gr_column->set_short_text( 'PerfType1' ).

gr_column ?= gr_columns->get_column( 'LSTAR2' ). " <-- notice 2
gr_column->set_long_text( 'Performance Type 2' ).
gr_column->set_medium_text( 'Performance Type 2' ).
gr_column->set_short_text( 'PerfType2' ).
Kind regards,
Mateusz
7 REPLIES 7

mateuszadamus
Active Contributor

Hello mrsap99

How did you manage to have 4 columns with the same name in the structure?

Kind regards,
Mateusz

mateuszadamus
Active Contributor
0 Kudos

Hello

OK. So first get the proper technical names of these columns. I'm sure they are not the same, as this is not possible in ABAP (two have two different columns with the same name in the same structure). When you have the names the rest you can do as you showed.

Also, in the future, use "Comment" option to add information to the question. The "Answer" is for providing the possible solution.


Kind regards,
Mateusz

0 Kudos

Hello mateuszadamus

thank you,

the problem is that they are the same technical names cause its 3 time the same field. So basically there would be 4 lines in the table for every workplace, but i changed it to have the 4 "lines" behind each other, because the rest of selection is the same.

Where can i find the proper technical names ( ithink its the same).

i am very new at using abap and still have to learn much 😄

mateuszadamus
Active Contributor
0 Kudos

If you have this structure already and you show an ALV with the 4 fields with "Formula key" label, then I propose you put a break point just before the ALV is shown and see what field has what value. Then you will know which fields you're looking for.

If you want to join 4 records into one and have 4 fields then I propose you name them as LSTAR_1 .. LSTAR_4 and fill their value from records.

If it's still not solved, please show the code you use.


Kind regards,
Mateusz

0 Kudos

structure.pngreport.png

Thats my report.

I want to rename it to Formular Key 1 , Formular Key 2 ,... performance type 1, performance type 2 in my alv

best regards and ty

mario

mateuszadamus
Active Contributor

Hello mrsap99

Based on the comments under the question here is a possible solution.

Basically you had everything okay, just use the right column names.

gr_columns = gr_table->get_columns( ).

gr_column ?= gr_columns->get_column( 'FORML1' ). " <-- notice 1
gr_column->set_long_text( 'Formular Key 1' ).
gr_column->set_medium_text( 'Formular Key 1' ).
gr_column->set_short_text( 'FormKey1' ).

gr_column ?= gr_columns->get_column( 'FORML2' ). " <-- notice 2
gr_column->set_long_text( 'Formular Key 2' ).
gr_column->set_medium_text( 'Formular Key 2' ).
gr_column->set_short_text( 'FormKey2' ).

gr_column ?= gr_columns->get_column( 'LSTAR1' ). " <-- notice 1
gr_column->set_long_text( 'Performance Type 1' ).
gr_column->set_medium_text( 'Performance Type 1' ).
gr_column->set_short_text( 'PerfType1' ).

gr_column ?= gr_columns->get_column( 'LSTAR2' ). " <-- notice 2
gr_column->set_long_text( 'Performance Type 2' ).
gr_column->set_medium_text( 'Performance Type 2' ).
gr_column->set_short_text( 'PerfType2' ).
Kind regards,
Mateusz

Hello mateuszadamus,Its working now.Big thanks to you for your help and time, have a nice day Kind regards from Germany Mario