How to hide columns in ALV? (via cl_salv_table)

Dear forumers,
Is there a way for me to hide a few columns (or data fields) from being displayed in the ALV table, using the cl_salv_table method?
FORM display_data_alv .
  TRY.
      CALL METHOD cl_salv_table=>factory
        IMPORTING
          r_salv_table = o_table
        CHANGING
          t_table      = i_ro_assets.
    CATCH cx_salv_msg.
  ENDTRY.
  o_functions = o_table->get_functions( ).
  o_functions->set_all( abap_true ).
  o_columns = o_table->get_columns( ).
  o_columns->set_optimize( abap_true ).
  PERFORM set_columns.
  o_events = o_table->get_event( ).
  CREATE OBJECT o_handle_events.
  SET HANDLER o_handle_events->on_double_click FOR o_events.
  o_table->display( ).
ENDFORM.                    " DISPLAY_DATA_ALV
FORM set_columns .
  TRY.
      o_column ?= o_columns->get_column( 'BUKRS' ).
      o_column->set_long_text( text-008 ).
    CATCH cx_salv_not_found.
  ENDTRY.
  TRY.
      o_column ?= o_columns->get_column( 'ANLN1' ).
      o_column->set_long_text( text-009 ).
    CATCH cx_salv_not_found.
  ENDTRY.
ENDFORM.                    " SET_COLUMNS
I have also tried to exclude some columns from the subroutine SET_COLUMNS, but they are still showing in the resulting ALV table. What can I do here next?
Appreciate any help here.
Thanks very much.

You can use the method SET_COLUMN_TECHNICAL of the class CL_SALV_COLUMN  to hide the Column.
data:
  ir_columns type ref to cl_salv_columns_table,
  lr_column type ref to cl_salv_column.
  try.
      lr_column = ir_columns->get_column( 'MANDT' ).
      lr_column->set_technical( if_salv_c_bool_sap=>true ).
    catch cx_salv_not_found.                            "#EC NO_HANDLER
  endtry.
Check the report SALV_DEMO_TABLE_COLUMNS to know more about the Column processing in SALV model.
Regards,
Naimesh Patel

Similar Messages

  • Hide column in  alv

    how i can make column hide in alv report

    Set the NO_OUT parameter in the field catalog as X.
    no_out(1)      type c,        " (O)blig.(X)no out
    In the case it would not show the column in ALV list
    Message was edited by: Anurag Bankley

  • Hide column in alv grid

    Hi Everyone,
    I would like to know how to hide a column in alv grid. Is there any specific field to set in the field catalog.
    Thanks in advance,
    Prabs.

    Hello friends,
    I am using the following lines of code, but invisible of my column ( message ) is not working, would be nice if some one can give me any tip.
    Field-symbols: <lfs_fieldcat> TYPE lvc_s_fcat.
      LOOP AT pt_fieldcat ASSIGNING <lfs_fieldcat>.
        CASE <lfs_fieldcat>-fieldname.
          WHEN 'DUMMY'.
            <lfs_fieldcat>-coltext = 'Message'.
            <lfs_fieldcat>-no_out = 'X'.
        ENDCASE.
      ENDLOOP.
    I have also set the field catalog to no_out = 'X'.
    PS: Do I need to append the field catalog to internal table ??
    I am using the function
    CALL METHOD lalv->SET_TABLE_FOR_FIRST_DISPLAY
             EXPORTING I_STRUCTURE_NAME =  'abc'
                       IS_LAYOUT        = ps_layout
             CHANGING  IT_OUTTAB        = xyz.
    Do I have to implicit set the field catalog in ps_layout ??

  • How to hide column of DataGrid

    I am making a web part in which I am using System.Web.UI.WebControls.DataGrid control.
    It's AutoGenerateColumns property is set to TRUE.
    I am trying to hide a column at run time. I have written the following code on this controls ItemCreated event but it only works if I e.Item.Cells[0] and it doesn't work for any other value for e.g. e.Item.Cells[1] and e.Item.Cells[6].
    There are 9 columns in my DataGrid control.
    Code
    protected void grd1_ItemCreated(object sender, DataGridItemEventArgs e)
    { e.Item.Cells[0].Visible = false; //works fine
    e.Item.Cells[1].Visible = false; //gives error e.Item.Cells[2].Visible = false; //gives error
    Error
    Specified argument was out of the range of valid values.
    Parameter name: index
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    How to hide a particular column?

    Hi Frank,
    You can try something similar to the below in 'RowCreated' event Instead
    protected void gridView_RowCreated(object sender, GridViewRowEventArgs e)
    e.Row.Cells[1].visible =false;
    OR I would say hiding column is not something that is to be done at row level, so you can hide columns outside any of the grid view event after binding.
    e.g.
    gridview1.columns[1].visible=false;
    I am using DataGrid control in which there is no RowCreated event.
    I have tried second approach but it also doesn't work.

  • How to Hide rows in ALV without affecting total sum at the end of table?

    Hi,
    I need some help in hiding particular rows in an ALV Grid without affecting the total sum at the end of the table. I am trying to hide the rows that have negative quantities, but I still need those values so that the user can still compute for the total sums. Can anyone help? Thanks.
    Joseph

    Hi,
    Hopw this way you can hide the rows in the GRID.
    DATA:
      ld_column      TYPE lvc_fname,
      ld_hide          TYPE abap_bool.
    FIELD-SYMBOLS:
      <ls_entry>     TYPE any,
      <ld_fld>         TYPE any.
      ld_column = 'COL_1'.  " column which you want to suppress if everything is zero
      ld_hide     = abap_true.  " = 'X';  default hide column
      LOOP at <gt_outtab> ASSIGNING <ls_entry>.
        ASSIGN COMPONENT (ld_column) OF STRUCTURE <ls_entry> TO <ld_fld>.
        IF ( <ld_fld>   > 0 ).
          ld_hide = abap_false.  " display column because at least single value > 0
          EXIT.  " leave LOOP
        ENDIF.
      ENDLOOP.
      READ TABLE gt_fcat INTO ls_fcat
                           WITH KEY fieldname = ld_column.
      IF ( syst-subrc = 0 ).
        ls_fcat-no_out = ld_hide.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDIF.
    hop you will get the total with for those columns too.
    Regards,
    Madhavi

  • How to Hide Column

    Hello,
    How can I hide columns within an AdvancedTable programmatically? Ex. All columns shall be shown if the value of my dept is "Dept1" while only Column1 to 2 shall be shown if my dept is "Dept2"? Pls advise. thanks

    As Kumar rightly pointed out, you need to refer the Dev guide for this. Refer the section on Partial Page Rendering.
    To summarize you would have the Rendered Property on the columns like this
    ${oa.<VoName>.<VOAttributeName>}
    Based on the conditions you would set the attribute value(which is boolean) to true or false and accordingly either the column with show or hide. The VOName is the name of the Partial View Object you create for the purpose. Do let us know if you have difficulty in understanding PPR.
    Regards
    Sumit

  • How to hide column in BEx Analyzer

    Hi gurus
    In my report I have to show 5 columns depending on a condition.
    Is it feasible?
    Regards

    Hi,
        You can use VBA Macro to execute Code to hide the columns based on the condition.
    This is in 3.5
    Sub SAPBEXonRefresh(queryID As String, resultArea As Range)
               'Check you condition
               If <condition> Then
                       'This will hide Column 3 on Sheet1 where the Query is.
                       ThisWorkbook.Sheets("Sheet1").Columns(3).Hidden = True
               End If              
    End Sub

  • How to minimize  column in alv

    i have a lot of column and i wont to minimize them , to be adjusted for the  biggest word  in the column in alv i use alv grid from se83 and it is very basic Thank you!

    hi,
    chk this sample.
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
    <b> gd_layout-colwidth_optimize = 'X'.</b>
      gd_layout-totals_text       = 'Totals'(201).
    gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
               i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
            <b>    is_layout               = gd_layout</b>
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = it_ekko
           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.
    endform.                    " DISPLAY_ALV_REPORT
    <b>for sseing the full code.
    chk this link
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm</b>
    rgds
    anver
    Message was edited by: Anversha s

  • Hi Experts, how add a column to MD04 via BADI or some other method?

    Hi Experts,
    the recommended BADI is MD_ADDD_COL_EZPS.
    I am working on a requirement about adding a column to MD04(when you input /nMD04 in the system you will see two tabs, one is Individual access and the other is Collective access), for the Individual access you input material and plant and press 'Enter', you will see a alv-like list about the material, I want to add a column next to the current last column(Available qty), so can anyone tell me how to solve this? thank you in advance!
    Kind regards
    Dawson

    Hi ,
    if u want to add a column in table control , you can not do using User exit or badi .
    for this u need developer access key , without developer access key , u can not add.
    Thanks
    Shambhu

  • How to hide columns in the output table in webdynpro based on input

    Hi Experts,
       I have 2 inputs and 1 input is optional.If both inputs are given proper table output is displayed,but if only 1 input is given a column is empty in the output table  so i want to hide this column dynamically at runtime based on my inputs.And i want to hide some empty rows also at runtime based on inputs.
    Can anyone help me out to solve this.
    Thanks in advance.
    Regards,
    Anita.

    Hi Anitha,
    What i understood from your question is,you want to control the table from your inputs.I have a one question for you what do you want to show defaultly i.e when you run the application what you want to show,either no table or table with some values.
    Any how i am giving solution in this way.
    If both inputs are given proper table output is displayed
    Write your below logic in the WDDOMODIFYVIEW )
    Here i am assuming that you already have a table element in the view.
    Get the values entered in the input fields and compare those 2 values ,if the condition is satisfied then bind the values which you want to show in the table to the context node.
    but if only 1 input is given a column is empty in the output table so i want to hide this column dynamically at runtime based on my inputs
    You are telling that you know the empty column.If so get the view element reference and use the REMOVE_COLUMN to remove the column.
    data:lr_table type ref to cl_wd_table,
           lr_column type ref to L_WD_TABLE_COLUMN.
    lr_table ?= view->get_element( 'TABLE1' ).
    CALL METHOD LR_TABLE->REMOVE_COLUMN
        EXPORTING
          ID          = 'TABLE1_color'
         INDEX      =
        RECEIVING
          THE_COLUMN = lr_column.
    i want to hide some empty rows also at runtime based on inputs.
    Removing the rows is very simple.if you know the key fields data of internal table from your input fields then do in this way.
    delete itab from wa where key1= "12" and key2="abd".
    Now bind the internal table to context node.
    LO_ND_hcm->BIND_TABLE(
          NEW_ITEMS            = it_final
          SET_INITIAL_ELEMENTS = ABAP_TRUE ).

  • How to hide columns that are getting added dynamically to UI Element 'Table

    In SRM 7.0 while displaying a RFx, click on "responses and awards" button.
    In the response comparision tab once the user selects response number and clicks on "compare all responses".
    Item details table is displayed with fields item number,internal number,item description,........,Price etc.
    Requirement is  to hide the price column from the table.
    The UI element type is 'Table'.
    But the catch is there is no column price visible at layout design level.
    This field is getting added dynamically at run time.
    When i right click and see the 'more field help' at the front end i get the field id as 'GRP_1_COL_3_TXTV'.
    lo_table ?= view->get_element( id = 'ITEMS_TABLE' ).
    lo_column = lo_table->get_column( id = 'GRP_1_COL_3_TXTV').
    ASSERT lo_column IS NOT INITIAL.
    lo_column->set_visible( EXPORTING value = '01' ).
    I had written the above code in the pre-exit of WDDOMODIFYVIEW.
    But i am getting dump as assertion failed.it says no column by name 'GRP_1_COL_3_TXTV'.
    Please help me inhow to hide fields or buttons getting generated dynmically.
    Regards,
    Venkat Raghavan.

    Hi Anitha,
    What i understood from your question is,you want to control the table from your inputs.I have a one question for you what do you want to show defaultly i.e when you run the application what you want to show,either no table or table with some values.
    Any how i am giving solution in this way.
    If both inputs are given proper table output is displayed
    Write your below logic in the WDDOMODIFYVIEW )
    Here i am assuming that you already have a table element in the view.
    Get the values entered in the input fields and compare those 2 values ,if the condition is satisfied then bind the values which you want to show in the table to the context node.
    but if only 1 input is given a column is empty in the output table so i want to hide this column dynamically at runtime based on my inputs
    You are telling that you know the empty column.If so get the view element reference and use the REMOVE_COLUMN to remove the column.
    data:lr_table type ref to cl_wd_table,
           lr_column type ref to L_WD_TABLE_COLUMN.
    lr_table ?= view->get_element( 'TABLE1' ).
    CALL METHOD LR_TABLE->REMOVE_COLUMN
        EXPORTING
          ID          = 'TABLE1_color'
         INDEX      =
        RECEIVING
          THE_COLUMN = lr_column.
    i want to hide some empty rows also at runtime based on inputs.
    Removing the rows is very simple.if you know the key fields data of internal table from your input fields then do in this way.
    delete itab from wa where key1= "12" and key2="abd".
    Now bind the internal table to context node.
    LO_ND_hcm->BIND_TABLE(
          NEW_ITEMS            = it_final
          SET_INITIAL_ELEMENTS = ABAP_TRUE ).

  • How to make XML element used in RTF PRIVATE/PUBLIC ? I know how to hide columns in RTF, but dont know how to generate the xml in below way. Please help.

    Hi
    I am following below link to hide/show my columns dynamically. See "Column Formatting"
    http://docs.oracle.com/cd/E12844_01/doc/bip.1013/e12187.pdf
    As per doc, element can be made private/public.
    <items type="PUBLIC">
    <item>
      <name>Plasma TV</name>
      <quantity>10</quantity>
      <price>4000</price>
    </item>
    <item>
    And same can be used to hide the column using condition
    <?if@column:/items/@type="PUBLIC"?>
    MY QUESTION IS HOW TO DO THIS IN MY XML BELOW?
    Below is part of my XML code which I am using in Data Definition for RTF.
    <group name="GH3" source="QH3">
    <element name="COLUMN_HEAD3" value="COLUMN_NAME" />
    </group>
    <group name="GH4" source="QH4">
    <element name="COLUMN_HEAD4" value="COLUMN_NAME" />
    </group>
    I am getting output like this.
    <LIST_GH3>
    <GH3>
    <COLUMN_HEAD3>REBILL_TO_OTHER_BUSINESS_UNIT</COLUMN_HEAD3>
    </GH3>
    </LIST_GH3>
    <LIST_GH4>
    <GH4>
    <COLUMN_HEAD4>XYZ</COLUMN_HEAD4>
    </GH4>
    </LIST_GH4>
    In order to use logic as per oracle document I want output like this.
    <LIST_GH3 type="PUBLIC">
    <GH3>
    <COLUMN_HEAD3>REBILL_TO_OTHER_BUSINESS_UNIT</COLUMN_HEAD3>
    </GH3>
    </LIST_GH3>
    <LIST_GH4 type="PRIVATE">
    <GH4>
    <COLUMN_HEAD4>BLANK</COLUMN_HEAD4>
    </GH4>
    </LIST_GH4>
    What changes I need to make in my XML code to get the runtime output as above? Please help. Where do i need to make changes in the above xml? Group name? Element name?
    I am planning to use below condition in RTF template to hide the column,  but dont know how to set the type of column as PRIVATE/PUBLIC in the XML output used to populate data in the RTF at runtime.
    <?if@column:/BTSPIEXP/LIST_GH3/@type=”PUBLIC”?>COLUMN_HEAD3<?end if?>
    Regards,
    Swapnil K.

    Hi,
    Issue has been resolved. I used the value of the element to determine to display it or not.
    Regards,
    Swapnil K.

  • Hide columns for ALV list output in SAP Query SQ01/SQ02

    Hi All,
    I have a requirement to hide the columns which are empty in sap query SQ01 alv list output.
    Please let me know this functionality available in Query (SQ01) like normal reports
    Regards,
    Venkat

    Hi,
    We just can't make changes in this case as this are all system generated programs.
    WE have to write our own reports to make things flexible to match our requirements.
    Things you are asking is not possible.
    Regards,
    Suvendu

  • Hide columns in ALV

    Hello ,
    I have a problem in the ALV usage in abap webdrn pro.
    I have implemented the ALV by reusing the component SALV_WD_TABLE.
    In the interface controller usage, i mapped the DATA node to
    component context node, say, node1.
    Node1 is has a reference to a structure from data ditionary, say Struc1.
    and Stuc1 has some 20 elements.
    But in the Node1 i mapped only 10 elements of the structure Struc1 as its attributes.
    Now, when i map 'data' node to the Node1 from controller,
    My ALV shows all teh 20 columns.
    But i want only 10 of these columns to be displayed in the ALV.
    Please let me know if.
    I already know of referring to the ALV programmatically and hiding the columns.
    But my question is taht when the Node1 has only few elements, shouldnt the alv also display the same number of coloumns..
    Please let know if there is a way out here.
    regards,
    Kiran

    Hi,
    if you want to hide a column named OBJID and OBJTYP then implement following coding
    DATA:
    lr_comp_alv TYPE REF TO if_wd_component_usage,
    lr_comp_if_alv TYPE REF TO iwci_salv_wd_table,
    lr_config TYPE REF TO cl_salv_wd_config_table,
    lr_column TYPE REF TO cl_salv_wd_column,
    ls_column TYPE salv_wd_s_column_ref,
    lt_columns TYPE salv_wd_t_column_ref.
    data: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
    *... ALV Component Usage
    lr_comp_alv = wd_this->wd_cpuse_alv( ).
    IF lr_comp_alv->has_active_component( ) IS INITIAL.
    lr_comp_alv->create_component( ).
    ENDIF.
    lr_comp_if_alv = wd_this->wd_cpifc_alv( ).
    *... Configure ALV
    lr_config = lr_comp_if_alv->get_model( ).
    lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
    lr_config->if_salv_wd_std_functions~set_edit_insert_row_allowed( ).
    lr_config->if_salv_wd_std_functions~set_view_list_allowed( abap_false ).
    lr_config->if_salv_wd_std_functions~set_export_allowed( abap_true ).
    lt_columns = lr_config->if_salv_wd_column_settings~get_columns( ).
    lr_column = lr_config->if_salv_wd_column_settings~get_column('OBJID' ).
    *To hide particular coulmn
    LOOP AT lt_columns INTO ls_column.
    CASE ls_column-id.
    when 'OBJID'.
    ls_column-r_column->set_visible( value = '99' ).
    when 'OBJTP'.
    ls_column-r_column->set_visible( value = '99' ).
    ENDCASE.
    ENDLOOP.

  • Hide columns in ALV grid?

    Hi all,
    I define a structure in the ABAP dictionary. I declare a table of that type in my program. I populate the table with records. I then display the table of data in an ALV grid. I hide three fields in the grid when I build the field catalog. When I run the program the fields are hidden. When my user runs the program the fields are not hidden...but are displayed on the end of the ALV grid. How do I correct? And why the difference in views?
    Mat

    I agree with Frisoni
    Also what you can do is , when you display your ALV, in the application tool bar of ALV you can see the option of
    Change Variant..
    check any existing variants are there or not..I am sure user might have created such varaint.
    if this is not the case , and there is no varaint , check with user whether he has created any variant..
    also check your filedcat and Layout.

Maybe you are looking for

  • How can I remove calendar alerts from my iPhone?

    My iPhone 4 (iOS 6) seems to be adding calendar alerts on its own and I cannot for the life of me figure out how to remove them. I use iCal on my Macbook Pro (running Mountain Lion 10.8.2) to sync my calendar events. None of my events on iCal have al

  • KDE shutdown/reboot issue

    I've had this issue for ages, hope I can explain it clearly enough.  Two people use my computer, when both are logged in, and the person who logged in first logs out, then the second person tries to restart or shut down, it doesn't work properly.  It

  • How can I Setup my Email Account in Mavericks?

    The existing description on Apple support is not valid. There ist no possibility to setup the account manually to e.g. IMAP. Best regards

  • Mac pro / Laserjet 4 / Os 10.6 - how do I make the printer work?

    Hi, I have a 2008 Mac Pro running 10.6.8 and an ancient yet still thriving HP Laserjet 4 that I was  using over an ethernet/Jetdirect connection with my G5 for years - how do I get them to talk to each other? I'm running the printer connection throug

  • Configure PO document type for "High sea Sale"

    Dear sir, Pl. tell me step by step how can i configure new Document type of Purchase order for "High sea Sale" business senerio without GR. Thanks/ Anurag