Application Development and Automation 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: 
Read only

About adding new fields into ALV

Former Member
0 Likes
1,102

Hello guys,

I am going to enhance a ALV with some new fields.

I have done all the changes (enhance structure, fieldcatlog, filling values), but the fields don't appear on the ALV. And only after I change the layout settings and create a new settings, it appears.

I assume the new fields is hidden by the layout settings. But before my enhancements, there is also no layout settings. Why the original fields appear without the layout settings?

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Yasin
Active Participant
0 Likes
1,035

There are a number of ways to create a fieldcat, you have to declare your new fields

( the fields which you want them to appear in your ALV grid ) in the code

depends on the way you are using to create your fieldcat:

for example:



form build_fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

hope it will help you...

5 REPLIES 5
Read only

Former Member
0 Likes
1,035

Was there a global display variant?

Read only

0 Likes
1,035

What do you mean for global display variant?

the ALV create method has the following parameter

call method alv_advicedata->set_table_for_first_display

exporting

is_layout = i_layout

it_toolbar_excluding = it_exclude[]

is_variant = i_variant

i_save = 'A'

i_default = 'X'

changing

it_outtab = me->alv_advicedata_tab[]

it_fieldcatalog = it_fieldcat[].

Read only

Yasin
Active Participant
0 Likes
1,035

Hi William

you can add as much as you can cols to the Alv grid just copy and paste in the code :


it_fieldcatalog-fieldname = 'NAME'.
it_fieldcatalog-seltext   = 'NAME OF THE STUDENT'.
it_fieldcatalog-coltext =   'NAME OF THE STUDENT'.
APPEND it_fieldcatalog TO it_fieldcat.
CLEAR it_fieldcatalog.

or you can try to remove the line:

is_variant = i_variant

Read only

Yasin
Active Participant
0 Likes
1,036

There are a number of ways to create a fieldcat, you have to declare your new fields

( the fields which you want them to appear in your ALV grid ) in the code

depends on the way you are using to create your fieldcat:

for example:



form build_fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

hope it will help you...

Read only

Former Member
0 Likes
1,035

Hi william,

whenever you want to add new fields to the alv displayed table you have to add

new fields to the fieldcatalog there is nothing like it hide unless you explicitly define it to be.

if i want to add seatsmax and seatsocc in my table then i add this for the existing fieldcatelog

code.

fcat-fieldname = 'SEATSMAX'.

fcat-outputlen = 15.

fcat-ref_table = 'SFLIGHT'.

fcat-key_sel ='X'.

APPEND fcat TO t_fcat.

fcat-fieldname = 'SEATSOCC'.

fcat-outputlen = 15.

fcat-ref_table = 'SFLIGHT'.

fcat-key_sel ='X'.

APPEND fcat TO t_fcat.

the other way is to pass directly the structure to the parameter i_structure_name

of the method set_table_for_first_display.

i hope it helped you.

Regards and Best wishes.