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: 

Additional Fieldcatalog in ALV Grid

Former Member
0 Kudos

Hi,

Using ALV grid for output list. In fieldcatalog i have field names but also want column nos in a row just below the Column headings. How it can be done.

Like 1 should be displayed in 1st row for EBELN.

Right now using following code

DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV

WITH HEADER LINE.

FIELDCATALOG-FIELDNAME = 'EBELN'.

FIELDCATALOG-SELTEXT_L = 'PO No'.

FIELDCATALOG-COL_POS = 1.

APPEND FIELDCATALOG TO FIELDCATALOG.

CLEAR FIELDCATALOG.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = GD_REPID

I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IS_LAYOUT = GD_LAYOUT

IT_FIELDCAT = FIELDCATALOG[]

IT_EVENTS = GT_EVENTS

IS_PRINT = GD_PRNTPARAMS

I_SAVE = 'X'

TABLES

T_OUTTAB = ITEMP

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

Looking forward for your responses.

thanks

anu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

It sounds like you want two headings one with the name of the column and the other with the column position.

But dual headings are not possible with ALV.

What you can do is to add a row to the table with the col position data and insert that as the first row of the table. But if the user sorts the data the display will go for a toss.

Regards,

Ravi

Note : Please mark all the helpful answers

5 REPLIES 5

Former Member
0 Kudos

It sounds like you want two headings one with the name of the column and the other with the column position.

But dual headings are not possible with ALV.

What you can do is to add a row to the table with the col position data and insert that as the first row of the table. But if the user sorts the data the display will go for a toss.

Regards,

Ravi

Note : Please mark all the helpful answers

dani_mn
Active Contributor
0 Kudos

Hi,

One solution is that you fill your first row in the internal table with column numbers.

<b>

wa_itab-field1 = 1.
wa_itab-field2 = 2.
INSERT wa_itab into itab index 1.

</b>

Regards,

Wasim Ahmed

Former Member
0 Kudos

Hi wasim,

i have already tries that logic of populating first row with column nos. But in few cases the field are numeric so when its populating the column index its displayed as '1.00'. any idea how to resolve this.

thanks

anu

Former Member
0 Kudos

Hi,

For displaying two headers in ALV, you have to use the following process...

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      i_bypassing_buffer     = c_x
      i_callback_program    = lv_repid
      is_layout                   = wa_layout
      it_fieldcat                  = it_fieldcat
      it_events                   = it_events
      i_save                      = c_a
    TABLES
      t_outtab                   = it_final
    EXCEPTIONS
      program_error          = 1
      OTHERS                 = 2.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

For setting layout use the following form -

*&---------------------------------------------------------------------*
*&      Form  F_SET_LAYOUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_set_layout .

  wa_layout-zebra             = c_x.
  wa_layout-colwidth_optimize = c_x.

ENDFORM.                    " F_SET_LAYOUT

Similarly for events use -

*&---------------------------------------------------------------------*
*&      Form  F_CALL_EVENT
*&---------------------------------------------------------------------*
*      Defining events which have to triggered
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_call_event .

  wa_events-name = slis_ev_top_of_page.
  wa_events-form   = c_top.                   

  APPEND wa_events TO it_events.
  CLEAR wa_events .

ENDFORM.                    " F_CALL_EVENT

where c_top is defined as -

c_top                TYPE slis_formname    VALUE 'TOP_OF_PAGE'

Also u have to define a form (mentioned below) with the same name which can be called from f_call_event form automaticaly...

*&---------------------------------------------------------------------*
*&      Form  TOP_OF_PAGE
*&---------------------------------------------------------------------*
*       Defining the column's main heading
*----------------------------------------------------------------------*
FORM top_of_page.

  FORMAT COLOR COL_HEADING.

  WRITE : / sy-uline(255).

  WRITE : / sy-vline,
            (10)c_space,
            sy-vline,
            (2) c_space,
            sy-vline,
            (8) c_space,
            sy-vline,
            (17)c_space,
            sy-vline,
            (18)c_space,
            sy-vline,
            (18)c_space,
            sy-vline,
            (26)c_space,
            sy-vline,
            (31)c_space,
            sy-vline,
            (12)c_space,
            sy-vline,
            (41)c_jan   CENTERED,
            sy-vline,
            (41)c_feb   CENTERED,
            sy-vline,
            (41)c_mar   CENTERED,
            sy-vline,
            (41)c_apr   CENTERED,
            sy-vline,
            (41)c_may   CENTERED,
            sy-vline,
            (41)c_jun   CENTERED,
            sy-vline.

  FORMAT COLOR OFF.

ENDFORM.                    "top_of_page

In this you can define the 1st column headings along with the position.

This will help you add 2 headers to each column viz....

1st Heading from the top of the page form

and

2nd heading from the field catalog you have defined.

Let me know in case any further detail is needed.

Thanks.

rosenberg_eitan
Active Contributor
0 Kudos

If the info is only for debugging purpose may suggest
using slis_fieldcat_alv-seltext_l = slis_fieldcat_alv-ieldname .

In this case I believe you will see the field name as tool tip.

For demo I used pgm "BCALV_DEMO_TOOLTIP" and using debug I change the values of ls_fcat-seltext_l

form display_fullscreen .

  data: ls_layout type slis_layout_alv,
        lt_fcat type slis_t_fieldcat_alv,
        ls_fcat type slis_fieldcat_alv.

      ls_layout-lights_tabname   = '1'.
      ls_layout-lights_fieldname = 'LIGHTS'.
      ls_layout-coltab_fieldname =  'TABCOL'.

      clear ls_fcat.
      ls_fcat-fieldname = 'LIGHTS'.
      ls_fcat-inttype = 'C'.
      ls_fcat-seltext_l = text-hl4.
      ls_fcat-seltext_m = text-hl4.
      ls_fcat-seltext_s = text-hl4.

      append ls_fcat to lt_fcat.

The result: