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: 

To hide the field

Former Member
0 Kudos
352

Hi experts,

In the below code how to hide the field name1 can some one solve this.,.,


*&---------------------------------------------------------------------*
*& Report  ZPROGRAM_USING_ALV_MERGE_FM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZPROGRAM_USING_ALV_MERGE_FM.

type-pools : slis.
data : it_fcat type slis_t_fieldcat_alv,
       wa_fcat like line of it_fcat.

data : BEGIN OF wa_kna1,
                kunnr type kunnr,
                name1 type name1,
  END OF wa_kna1.

  DATA: it_kna1 like TABLE OF  wa_kna1.

select kunnr name1 into table it_kna1 from kna1 up to 5 rows.


 CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
  EXPORTING
    I_INTERNAL_TABNAME           = 'IT_KNA1'
    I_STRUCTURE_NAME             = 'KNA1'

   CHANGING
     CT_FIELDCAT                  = it_fcat.

loop at it_fcat into wa_fcat.
  case wa_fcat-fieldname.
    when 'NAME1'.
      wa_fcat-no_out = 'X'.
  endcase.
endloop.


 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING

    I_GRID_TITLE                      = 'Report for customer details'
    IT_FIELDCAT                       = it_fcat

   TABLES
     T_OUTTAB                          = it_kna1.

Thanks and Regards,

Thirukumaran. R

1 ACCEPTED SOLUTION

Former Member
0 Kudos
183

think u missed out modifying the field catalog from the workarea:

data: l_index type i.

loop at it_fcat into wa_fcat.

l_index = sy-tabix.

case wa_fcat-fieldname.

when 'NAME1'.

wa_fcat-no_out = 'X'.

modify it_fcat index l_index from wa_fcat .

endcase.

endloop.

4 REPLIES 4

Former Member
0 Kudos
184

think u missed out modifying the field catalog from the workarea:

data: l_index type i.

loop at it_fcat into wa_fcat.

l_index = sy-tabix.

case wa_fcat-fieldname.

when 'NAME1'.

wa_fcat-no_out = 'X'.

modify it_fcat index l_index from wa_fcat .

endcase.

endloop.

faisal_altaf2
Active Contributor
0 Kudos
183

Hi, Rajendran

Please after replacing the following line with bellow one.

loop at it_fcat into wa_fcat.
  case wa_fcat-fieldname.
    when 'NAME1'.
      wa_fcat-no_out = 'X'.
  endcase.
endloop.

DELETE it_fcat WHERE fieldname = 'NAME1'.

LOOP AT it_fcat INTO wa_fcat.
  wa_fcat-col_pos = sy-tabix.
  MODIFY it_fcat FROM wa_fcat INDEX sy-tabix.
ENDLOOP.

Please Let me know if any Issue,

Best Regards,

Faisal

faisal_altaf2
Active Contributor
0 Kudos
183

Hi,

Test Sample Code Bellow..

TYPE-POOLS : slis.
DATA : it_fcat TYPE slis_t_fieldcat_alv,
       wa_fcat LIKE LINE OF it_fcat.

DATA: it_kna1 LIKE TABLE OF kna1 WITH HEADER LINE.

SELECT * from kna1 UP TO 5 ROWS
  INTO CORRESPONDING FIELDS OF TABLE it_kna1.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
  EXPORTING
    i_internal_tabname = 'IT_KNA1'
    i_structure_name   = 'KNA1'
  CHANGING
    ct_fieldcat        = it_fcat.

DELETE it_fcat WHERE fieldname = 'NAME1'.

LOOP AT it_fcat INTO wa_fcat.
  wa_fcat-col_pos = sy-tabix.
  MODIFY it_fcat FROM wa_fcat INDEX sy-tabix.
ENDLOOP.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_grid_title = 'Report for customer details'
    it_fieldcat  = it_fcat
  TABLES
    t_outtab     = it_kna1.

Best Regards,

Faisal

Former Member
0 Kudos
183

hi,

you cant to hide the name1 tab from the alv display.. rt?

NO need to delete or manipulat the internal table..this is very easy, please do the following

when you defin the field catalog for alv, please code this :

ls_field_cat-fieldname = 'NAME1'.

ls_field_cat-NO_OUT = 'X'. " hiding NAME1 fied.

" this will hide the particular filed from alv disply .you can get this field by going to layout of the alv display.

Edited by: Safel007 on May 18, 2009 9:48 AM