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

Problem with saving layout in ALV-Grid

Former Member
0 Likes
1,425

Hello guys,

I got a weird problem in some selfmade OO ALV-Grid tables regarding the fieldcatalog and layout.

First of all I got for example a Grid list which displays me all the batch jobs taking the information from the dictionary tables for it.

For creating my fieldcat I use the default tables like:


CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
     EXPORTING
       i_structure_name = 'TBTCP'
     CHANGING
       ct_fieldcat      = ct_fieldcat.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
     EXPORTING
       i_structure_name = 'TBTCO'
     CHANGING
       ct_fieldcat      = ct_fieldcat.

   CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
     EXPORTING
       i_structure_name = 'BTCEVTJOB'
     CHANGING
       ct_fieldcat      = ct_fieldcat.

After that I do a loop over my fieldcat for formating fields (key fields, emphasized fields, etc.) like I need them so


LOOP AT ct_fieldcat ASSIGNING <fs_fieldcat>.
     CLEAR: <fs_fieldcat>-key,
                 <fs_fieldcat>-tabname.

     MOVE <fs_fieldcat>-fieldname TO <fs_fieldcat>-ref_field.

     CASE <fs_fieldcat>-fieldname.
       WHEN 'JOBNAME' OR 'JOBCOUNT'.
         <fs_fieldcat>-key = 'X'.
       WHEN 'AUTHCKNAM'.
         <fs_fieldcat>-emphasize = 'X'.
     ENDCASE.
ENDLOOP.

When displaying my Grid It all looks fine. Every emphasized field is emphasized, every key field is marked blue as key field. Everything ok. But when in the grid list trying to save an own layout, SAP marks some other fields as key fields, even if I did not define them as key fields. Of course these are not ANY key fields, but the key fields of the original dictionary table which I unmarked as key fields in my Grid. But I do not know why the grid overwrites my fieldcat settings after saving an own layout?

Any idea?

Regards

Michael

1 ACCEPTED SOLUTION
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,172

Try CLEAR <fs_fieldcat>-fix_column & <fs_fieldcat>-emphasize field in that LOOP.

-- Tomas --
5 REPLIES 5
Read only

JJosh
Active Participant
0 Likes
1,172

Hi Michael,

Can you try changing the field-catalog or layout after the display?


Use alv methods :

get_frontend_fieldcatalog

set_frontend_fieldcatalog


and


get_frontend_layout

set_frontend_layout


Not sure whether I am correct. Just a try.


Regards,

Josh

Read only

Former Member
0 Likes
1,172

Hey Josh,

normally I do not use any refresh when working with alv without any hotspots because it is displayed only once. But I tried in this case, so i putted an refresh form routine after the set_table_for_first_display method, which is called in every case (with or without bound grid).


FORM alv_refresh.

   DATA: ls_stable  TYPE lvc_s_stbl.

   CALL METHOD gr_alv->get_frontend_fieldcatalog
     IMPORTING
       et_fieldcatalog = gt_fieldcat.

   CALL METHOD gr_alv->get_frontend_layout
     IMPORTING
       es_layout = gs_layout.



ENDFORM.                    " Refresh_alv

I tried both, get and set, but nothing changed.

The funny thing is when debugging I can see SAP calling my routine directly after clicking the layout button. But at this time the key fields are not changed yet. They got changed from SAP after saving the layout. It looks like SAP makes an own internal refresh after saving a layout?

Regards

Michael

Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,173

Try CLEAR <fs_fieldcat>-fix_column & <fs_fieldcat>-emphasize field in that LOOP.

-- Tomas --
Read only

0 Likes
1,172

What the...?

This really works, great. But WHY?

Read only

0 Likes
1,172

LVC_FIELDCATALOG_MERGE function sets not only KEY but also EMPHASISE color for key fields in field catalog. And fix_column marks column that always stays on the left side of ALV.

Maybe only CLEAR emphasise is needed, try

-- Tomas --