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_LIST_DISPLAY default layout problem

Former Member
0 Kudos

hi every body

I am trying to display my itab content using FM ALV_LIST_DISPLAY

the problem facing is

in my internal table there r 100 fields if i create field catalog for all fields

are displaying in ALV list

my requirement is out of 100 fields only 20 fields need to be displayed

every time we run the report and who ever runs the report

and also there should be a provision to the user to select specific fields

in specific order from the available 100 fields in the internal table.

please suggest me how to solve this one

Thanks in advance for your kind suggestions

6 REPLIES 6

former_member181962
Active Contributor
0 Kudos

Hi Ramana,

for the 80 fields that you don't need to display in the default, you have to set the fieldcatalog-no_out as 'X'.

That would be sufficient.

regards,

Ravi

Former Member
0 Kudos

Hi

U have to give the opportunity to create the layout variant to the user, so you need to transfer the variant parameter:

  DATA GT_VARIANT  LIKE DISVARIANT.
  
  GT_VARIANT-REPORT = SY-REPID.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
          ................................................
          I_SAVE                   = 'A'
          IS_VARIANT               = GT_VARIANT
          ........................................................

In this way the user can create the layout variant and sets one as default.

The default variant will be automatically used by ALV.

Max

Former Member
0 Kudos

ramana,

First in your output create your required layout and save with one name like "/venkat".

by us ing the below FM , pass that variant ,Declare gs_variantx.

MOVE '/venkat' TO gs_variantx-variant.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

I_SAVE = 'A'

CHANGING

CS_VARIANT = gs_variantx-variant

EXCEPTIONS

WRONG_INPUT = 1

NOT_FOUND = 2

PROGRAM_ERROR = 3

OTHERS = 4.

Pls. mark if useful

Former Member
0 Kudos

Hi,

U have to change the fieldcatalog accordingly. See the below example, i would like to disaply only he below two fields from the MARA table, in tahtc ase code as below.

FORM f9300_modify_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat.

  FIELD-SYMBOLS: <lfs_fieldcat> TYPE lvc_s_fcat.

  LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.
    CASE <lfs_fieldcat>-fieldname.
      WHEN 'MATNR'.
        <lfs_fieldcat>-hotspot  = 'X'.
        <lfs_fieldcat>-key      = 'X'.
      WHEN 'NTGEW'.
        <lfs_fieldcat>-do_sum      = 'X'.
      WHEN OTHERS.
       <lfs_fieldcat>-no_out     = 'X'.
    ENDCASE.

  ENDLOOP.

U have to specify <b>when others no_out = 'X'</b> now it wont dispaly the otehr firlds.

So u put all the twenty fields as dispaly and wont get dispalyed.

Hope its clear.

Former Member
0 Kudos

Build the filed catalog using FM 'REUSE_ALV_FIELDCATALOG_MERGE'.

Loop thru the fld catalog and hide the unnecc ones. Users can create variants

in the ALV and provide provide a field on the screen to select a variant .

Kindly Go thru cod below :

FORM set_alv_fieldcat_n_layout

CHANGING c_layout TYPE slis_layout_alv

c_tab_fieldcat TYPE slis_t_fieldcat_alv.

FIELD-SYMBOLS: <wa_fieldcat> TYPE slis_fieldcat_alv.

DATA : l_pos TYPE i VALUE 4.

    • create default field catalogue with DDIC information of

    • output structure:

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

  • i_program_name = g_con_callback_prog

  • i_internal_tabname = 'GT_OUTTAB'

i_structure_name = 'FTI_INT_INSTR_DATA'

  • i_client_never_display = 'X'

  • i_inclname = sy-repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

ct_fieldcat = c_tab_fieldcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

    • modify the field catalogue in a specific required way:

LOOP AT c_tab_fieldcat ASSIGNING <wa_fieldcat>.

IF <wa_fieldcat>-fieldname = 'MANDT'.

DELETE c_tab_fieldcat.

CONTINUE.

ENDIF.

IF <wa_fieldcat>-fieldname = g_param1.

<wa_fieldcat>-col_pos = '3'.

ELSEIF <wa_fieldcat>-fieldname = g_param2.

<wa_fieldcat>-col_pos = '4'.

ELSEIF <wa_fieldcat>-fieldname EQ 'ACTIVE_PASSIVE'.

<wa_fieldcat>-col_pos = '2'.

ELSEIF <wa_fieldcat>-fieldname EQ 'ICON_SUBTOTAL'.

<wa_fieldcat>-col_pos = '1'.

ELSE.

<wa_fieldcat>-col_pos = l_pos.

l_pos = l_pos + 1.

ENDIF.

IF <wa_fieldcat>-fieldname = g_param1 OR

<wa_fieldcat>-fieldname = g_param2 OR

<wa_fieldcat>-fieldname = 'ACTIVE_PASSIVE' OR

<wa_fieldcat>-fieldname CP '*_LC' OR

<wa_fieldcat>-fieldname CP '*_PC' OR

<wa_fieldcat>-fieldname CP '*_DC' OR

<wa_fieldcat>-fieldname CP 'MED_*' OR

<wa_fieldcat>-fieldname CP 'ICON_*'.

ELSE.

<wa_fieldcat>-no_out = 'X'.

ENDIF.

IF p_skflg = ftico_xtrue.

IF <wa_fieldcat>-fieldname CP '*_LC' OR

<wa_fieldcat>-fieldname CP '*_PC' OR

<wa_fieldcat>-fieldname CP '*_DC'.

<wa_fieldcat>-round = p_skalv.

<wa_fieldcat>-decimals_out = p_decim.

ENDIF.

ENDIF.

IF <wa_fieldcat>-fieldname CP '*_LC' OR

<wa_fieldcat>-fieldname CP '*_PC' OR

<wa_fieldcat>-fieldname CP '*_DC'.

ELSE.

<wa_fieldcat>-key_sel = 'X'.

<wa_fieldcat>-no_sum = 'X'.

ENDIF.

IF <wa_fieldcat>-fieldname CP '*_LC' OR

<wa_fieldcat>-fieldname CP '*_PC' OR

<wa_fieldcat>-fieldname CP '*_DC'.

<wa_fieldcat>-outputlen = '16'.

ENDIF.

IF <wa_fieldcat>-fieldname EQ 'ANZGW' OR

<wa_fieldcat>-fieldname EQ 'CALC_CCY' OR

<wa_fieldcat>-fieldname EQ 'NPV_CC' OR

<wa_fieldcat>-fieldname EQ 'CLEAN_PRICE_CC' OR

<wa_fieldcat>-fieldname CP 'ERR_*'.

DELETE c_tab_fieldcat.

CONTINUE.

  • <wa_fieldcat>-no_out = 'X'.

ENDIF.

IF <wa_fieldcat>-fieldname EQ 'INT_CAT' OR

<wa_fieldcat>-fieldname EQ 'ACTIVE_PASSIVE'.

<wa_fieldcat>-outputlen = '3'.

ENDIF.

IF <wa_fieldcat>-fieldname CP 'ICON_*'.

<wa_fieldcat>-icon = 'X'.

<wa_fieldcat>-outputlen = 3.

ENDIF.

IF <wa_fieldcat>-fieldname EQ g_param1 OR

<wa_fieldcat>-fieldname EQ g_param2 OR

<wa_fieldcat>-fieldname EQ 'ACTIVE_PASSIVE'.

<wa_fieldcat>-key = 'X'.

ENDIF.

ENDLOOP.

ENDFORM. " set_alv_fieldcat_n_layout

Former Member
0 Kudos

Hi!

One very simple solution is that you display all the 100 feilds. Then create a

layout varient with the 80 colums and set it as default layout. Create another

layout varient with the 100 columns ( the 80 columns first) . So, when someone views the report he will see the default layout(80 columns) and if he wants to make his own layout let him choose from the other layout(100 columns).

Hope it helps you,

regards

purnima.