2021 Feb 24 12:04 PM
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
2021 Feb 24 1:16 PM
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,2021 Feb 24 12:09 PM
Hello mrsap99
How did you manage to have 4 columns with the same name in the structure?
Kind regards,2021 Feb 24 12:33 PM
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
2021 Feb 24 12:46 PM
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 😄
2021 Feb 24 12:55 PM
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.
2021 Feb 24 1:11 PM
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
2021 Feb 24 1:16 PM
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,2021 Feb 24 1:32 PM