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: 

HELP IN ALV FIELD CAT

Former Member
0 Kudos

HI,

I use that function for alv and fieldcat and its working o.k. but i wont to add

field name to colman and its not working ,and optimaize colman for text , and title how i do that?

Regards



DEFINE m_fieldcat.
  add 1 to ls_fieldcat-col_pos.
  ls_fieldcat-fieldname   = &1.
  ls_fieldcat-ref_tabname = &2.
  ls_fieldcat-fix_column = &3. "this is not working 
  append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.



  DATA l_rnd_value TYPE integer2.

  FIELD-SYMBOLS : <itab> LIKE LINE OF itab .

  LOOP AT itab ASSIGNING <itab>.

    CASE <itab>-object.
      WHEN 'Badi'.
        <itab>-line_color = 'C510'.   " Blue.
      WHEN 'User Exit'.
        <itab>-line_color = 'C611'.   " Red.

    ENDCASE.

  ENDLOOP.

ENDFORM. 

FORM f_display_data.

  DATA:
    ls_layout   TYPE slis_layout_alv,
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv.

* Build the field catalog
  m_fieldcat 'OBJECT' 'ITAB' 'X'.
  m_fieldcat 'OBJECT_NAME' 'ITAB' 'X' .
*  m_fieldcat 'VBELN' 'VBAK'.
*  m_fieldcat 'NETWR' 'VBAK'.

* Fill Layout - Name of the field with color
  ls_layout-info_fieldname = 'LINE_COLOR'.

* Display the list
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      is_layout   = ls_layout
      it_fieldcat = lt_fieldcat
    TABLES
      t_outtab    = itab.

ENDFORM.                    "f_display_data
 

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

You need to use the

in field catalog

fieldcat-reptext_ddic = 'Col 1'.  " Column heading

in layout

 WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

Regards,

Naimesh Patel

5 REPLIES 5

naimesh_patel
Active Contributor
0 Kudos

You need to use the

in field catalog

fieldcat-reptext_ddic = 'Col 1'.  " Column heading

in layout

 WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

Regards,

Naimesh Patel

0 Kudos

hi naimesh

Thanks the optimize is working well.

i try to your suggestion and add the line in fcat but what i get is un the 2 column i have 'column 1' how i change it and get in all colman diffrent text?

Regards


DEFINE m_fieldcat.
  add 1 to ls_fieldcat-col_pos.
  ls_fieldcat-fieldname   = &1.
  ls_fieldcat-ref_tabname = &2.
  ls_fieldcat-fix_column = &3.
  ls_fieldcat-reptext_ddic = 'Col 1'. "here
  append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.

0 Kudos

You will have to use this:

1. Change the macro following way:

DEFINE m_fieldcat.
  add 1 to ls_fieldcat-col_pos.
  ls_fieldcat-fieldname   = &1.
  ls_fieldcat-ref_tabname = &2.
  ls_fieldcat-fix_column = &3.
  ls_fieldcat-reptext_ddic = &4.    " << will repalce from the macro's argument
  append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.

2. Call the macro like this.

 m_fieldcat 'OBJECT' 'ITAB' 'X' 'Object'
  m_fieldcat 'OBJECT_NAME' 'ITAB' 'X'  'Oject Name'.

Regards,

Naimesh Patel

0 Kudos

Oh.. I forgot that you also need the title of the ALV

To give a TITLE,

Pass this Exporting parameter in the FM REUSE_ALV_GRID_DISPLAY

I_GRID_TITLE = 'This is my Title'.

Regards,

Naimesh Patel

0 Kudos

hi

Thanks

naimesh u solved all my problem

Regards