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 new column mimics previous column value

magopa
Member
0 Kudos

Hi. I'm new here and I need a little help with a problem (that seems easy but I guess it's not...).

I have to add a new column to an ALV, but it's not working how I expected it to work. Does not matter where I set it, it keeps copying previous column data, and if I try to make it be the first column the report crashes.

Step by step what I did:

1. Add new column to fieldcat.

There is a subroutine named "build_fieldcatalog" where I put my new column the next way (just copied the other columns):

ls_fieldcat-fieldname = 'commentaire2_desc'.

ls_fieldcat-seltext_m = 'Comment'.

ls_fieldcat-col_pos = 34.

APPEND ls_fieldcat TO i_fieldcat.

CLEAR :ls_fieldcat.

2. Add the new value to the internal table that corresponds to the table receiving the ALV.

The ALV is being called in a subrouting named "LIST_DISPLAY" with a line with "CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'".

This function receives the catalog and a table named "t_echedit1" that corresponds to "t_outtab", and a lot more things.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = ls_program

i_callback_pf_status_set = 'GUI_STAT'

i_callback_user_command = 'F_USER_COMMAND' " Drill Down Form

is_layout = ls_layout

i_save = alvvr_sav_all

is_variant = alvvr

it_fieldcat = i_fieldcat

it_sort = i_sort

* i_save = ls_alvvr_sav_all

* is_variant = ls_alvvr

it_events = i_events

TABLES

t_outtab = t_echedit1 "i_t001

EXCEPTIONS

program_error = 1

OTHERS = 2.

I modified that table to get the new value and when I run the report, at this point, the new field is filled.

I asked a coworker and tolds me that this could be caused because the it_fieldcat and t_outtab does not have the same fields. Fieldcatalog has 35 columns added but the outtab has 6 lines with 48 values each.

The thing is that new my new column is the only one that don't work properly... The others works even if there is this difference of columns.

Any ideas? And let me know if I'm missing any information.There's something I'm not seing and I'm sure it will be something very easy to see...

Thank you in advance!

3 REPLIES 3

Sandra_Rossi
Active Contributor
0 Kudos

Please edit your question (Actions>Edit), select your code and press the button [CODE], which makes the code appear colored/indented, it'll be easier for people to look at it. Thanks!

e.g.

ls_fieldcat-fieldname = 'commentaire2_desc'.
ls_fieldcat-seltext_m = 'Comment'.
ls_fieldcat-col_pos = 34.
APPEND ls_fieldcat TO i_fieldcat.
CLEAR :ls_fieldcat.

2. Add the new value to the internal table that corresponds to the table receiving the ALV.

The ALV is being called in a subrouting named "LIST_DISPLAY" with a line with "CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'".

This function receives the catalog and a table named "t_echedit1" that corresponds to "t_outtab", and a lot more things.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_callback_program = ls_program
    i_callback_pf_status_set = 'GUI_STAT'
    i_callback_user_command = 'F_USER_COMMAND' " Drill Down Form
    is_layout = ls_layout
    i_save = alvvr_sav_all
    is_variant = alvvr
    it_fieldcat = i_fieldcat
    it_sort = i_sort
    it_events = i_events
  TABLES
    t_outtab = t_echedit1 "i_t001
  EXCEPTIONS
    program_error = 1
    OTHERS = 2.

Sandra_Rossi
Active Contributor
0 Kudos

Possibly due to the ALV buffer. Empty it via program BALVBUFDEL.

raymond_giuseppi
Active Contributor
0 Kudos

You could

Or switch to non-obsolete ALV tools, such as CL_SALV_TABLE ,which handle itself field catalog.