Hiding empty columns in ALV

Hi all,
I want to hide some columns in ALV which are empty on display when calling
cl_gui_alv_grid->set_table_for_first_display
That is to say the internaltable will contain empty columns.
I know that using the "no_out" attribute of field catalog we can hide columns.
But the question is how to find these columns which are empty - should I have to loop through the itab to find it out OR
Can we set it in ALV LAYOUT or field catalog attributes so that it wont display empty columns.
any help is appreciated....
Thanks
P
Edited by: pazzuzu on Mar 12, 2010 5:14 PM

Hi,
If i understood your question correctly,
The you can try this
TYPE-POOLS:slis,abap.
TYPES:BEGIN OF ty,
      f1 TYPE c,
      f2 TYPE c,
      f3 TYPE c,
      f4 TYPE c,
      END OF ty.
DATA:it TYPE TABLE OF ty,
     wa TYPE ty,
     wa_field TYPE slis_fieldcat_alv,
     i_fieldcat TYPE TABLE OF slis_fieldcat_alv,
     i_details TYPE abap_compdescr_tab,
     wa_comp TYPE abap_compdescr,
     ref_descr TYPE REF TO cl_abap_structdescr,
     lv_field TYPE abap_compname.
FIELD-SYMBOLS:<fs>,
              <fs1>.
ref_descr ?= cl_abap_typedescr=>describe_by_data( wa ).
i_details[] = ref_descr->components[].
wa-f1 = 'A'.
wa-f3 = 'C'.
APPEND wa TO it.
wa-f1 = 'X'.
wa-f3 = 'Y'.
APPEND wa TO it.
if it[] is not initial.
LOOP AT i_details INTO wa_comp.
  ASSIGN wa_comp-name TO <fs>.
  SORT it BY (<fs>) DESCENDING.
  CONCATENATE 'WA' '-' <fs> INTO lv_field .
  ASSIGN (lv_field) TO <fs1>.
    READ TABLE it INTO wa INDEX 1 transporting (<fs>).
  IF sy-subrc = 0 AND <fs1> IS NOT INITIAL.
    wa_field-fieldname = wa_comp-name.
    wa_field-seltext_m = wa_comp-name.
    APPEND wa_field TO i_fieldcat.
  ENDIF.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_callback_program = sy-repid
    it_fieldcat        = i_fieldcat[]
  TABLES
    t_outtab           = it[].
endif.

Similar Messages

  • Hideing a Column in ALV Table which is Displaying the POWL Query data

    Hi SDNers,
    I want to hide a column of ALV Table which is displaying my POWL Query data in it and hideing should be based on the Role as well. i.e few of the role the column shoudl be hidden and few of the roles should have the Column visible.
    waiting for the Valueble Answers.
    Thanks & Regards,
    Govindu

    Hai Kris,
        I took help from ur link and i declared a global attribute request_number.
    and i created an event handler ON_ALV_INSERT and did the follwing coding for giving default value wen ever am inserting new row.
    FIELD-SYMBOLS: <wa_row> LIKE LINE OF r_param->t_inserted_rows.
      DATA bill_details TYPE REF TO zdom_bill_detail.
      LOOP AT r_param->t_inserted_rows ASSIGNING <wa_row>.
        bill_details ?= <wa_row>-r_value.
        IF bill_details->REQ_NUMBER IS INITIAL.
      DATA lo_nd_bill_detail TYPE REF TO if_wd_context_node.
      DATA lo_el_bill_detail TYPE REF TO if_wd_context_element.
      DATA ls_bill_detail TYPE wd_this->Element_bill_detail.
    navigate from <CONTEXT> to <BILL_DETAIL> via lead selection
      lo_nd_bill_detail = wd_context->get_child_node( name = wd_this->wdctx_bill_detail ).
    lo_el_bill_detail = lo_nd_bill_detail->get_element( index = <wa_row>-index ).
          lo_el_bill_detail->set_attribute(
            EXPORTING
              name  = 'REQ_NUMBER'
              value = wd_comp_controller->request_number
    Wen am  setting the value of wd_comp_controller->request_number to my context attribute am getting NULL object ref error.
    lo_el_bill_detail->set_attribute(
        name =  `REQ_NUMBER`
        value = wd_comp_controller->request_number ).
    Pls give some suggestions,
    Thanks in Advance,
    Nalla.B

  • Hiding a column in ALV GRID function module if it doesnt have data

    Hi ,
    I am using alv grid function module, in output i dont want to display the fields which dont have data

    we dont know which column has no data..... we have to do it dynamically
    This code does that dynamically, Here the field2 & Fiels4 are not displayed.
    TYPE-POOLS:slis,abap.
    TYPES:BEGIN OF ty_stru,
          field1 TYPE c,field2 TYPE c,field3 TYPE c,field4 TYPE c,
          END OF ty_stru.
    DATA:itab TYPE TABLE OF ty_stru,
         wa_stru TYPE ty_stru,
         lv_repid TYPE sy-repid,
         wa_fieldcat TYPE slis_fieldcat_alv,
         it_fieldcat TYPE TABLE OF slis_fieldcat_alv,
         it_details TYPE abap_compdescr_tab,
         wa_components TYPE abap_compdescr,
         lf_ref_descr TYPE REF TO cl_abap_structdescr,
         lv_field TYPE abap_compname.
    FIELD-SYMBOLS:<fs> TYPE ANY,
                  <fs1> TYPE ANY.
    lf_ref_descr ?= cl_abap_typedescr=>describe_by_data( wa_stru ).
    it_details[] = lf_ref_descr->components[].
    wa_stru-field1 = 'A'.wa_stru-field3 = 'C'.APPEND wa_stru TO itab.
    wa_stru-field1 = 'X'.wa_stru-field3 = 'Y'.APPEND wa_stru TO itab.
    IF NOT itab[] IS INITIAL.
      LOOP AT it_details INTO wa_components.
        ASSIGN wa_components-name TO <fs>.
        CHECK sy-subrc = 0.
        SORT itab BY (<fs>) DESCENDING.
        CONCATENATE 'WA_STRU' '-' <fs> INTO lv_field .
        ASSIGN (lv_field) TO <fs1>.
        CHECK sy-subrc = 0.
        READ TABLE itab INTO wa_stru INDEX 1 TRANSPORTING (<fs>).
        IF sy-subrc = 0 AND ( NOT <fs1> IS INITIAL ).
          wa_fieldcat-fieldname = wa_components-name.
          wa_fieldcat-seltext_m = wa_components-name.
          APPEND wa_fieldcat TO it_fieldcat.
          CLEAR wa_fieldcat.
        ENDIF.
      ENDLOOP.
      lv_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program = lv_repid
                it_fieldcat        = it_fieldcat[]
           TABLES
                t_outtab           = itab[].
    ENDIF.

  • Hiding empty columns in report builder

    Hi,
    This is my first adventure with report builder and I have
    managed to produce some custom labels which work almost perfectly.
    I say almost because there is one thing I can't seem to do.
    I have a label for addresses. The address data consists of
    data from a query including, name,
    address1,address2,address3,town,county,postcode.
    Some of these are quite often empty but the label still
    displays a line break and the ',' at the end so I might end up
    with:
    Dave Phipps
    27 Acacia Road,
    MyTown,
    MT1 4JP
    In the above address the fields address2, address3 and county
    are empty.
    How do I set this up in Report Builder to hide the missing
    lines so that I would end up with:
    Dave Phipps
    27 Acacia Road,
    MyTown,
    MT1 4JP
    Any ideas?
    Cheers,
    Dave

    Hi,
    If i understood your question correctly,
    The you can try this
    TYPE-POOLS:slis,abap.
    TYPES:BEGIN OF ty,
          f1 TYPE c,
          f2 TYPE c,
          f3 TYPE c,
          f4 TYPE c,
          END OF ty.
    DATA:it TYPE TABLE OF ty,
         wa TYPE ty,
         wa_field TYPE slis_fieldcat_alv,
         i_fieldcat TYPE TABLE OF slis_fieldcat_alv,
         i_details TYPE abap_compdescr_tab,
         wa_comp TYPE abap_compdescr,
         ref_descr TYPE REF TO cl_abap_structdescr,
         lv_field TYPE abap_compname.
    FIELD-SYMBOLS:<fs>,
                  <fs1>.
    ref_descr ?= cl_abap_typedescr=>describe_by_data( wa ).
    i_details[] = ref_descr->components[].
    wa-f1 = 'A'.
    wa-f3 = 'C'.
    APPEND wa TO it.
    wa-f1 = 'X'.
    wa-f3 = 'Y'.
    APPEND wa TO it.
    if it[] is not initial.
    LOOP AT i_details INTO wa_comp.
      ASSIGN wa_comp-name TO <fs>.
      SORT it BY (<fs>) DESCENDING.
      CONCATENATE 'WA' '-' <fs> INTO lv_field .
      ASSIGN (lv_field) TO <fs1>.
        READ TABLE it INTO wa INDEX 1 transporting (<fs>).
      IF sy-subrc = 0 AND <fs1> IS NOT INITIAL.
        wa_field-fieldname = wa_comp-name.
        wa_field-seltext_m = wa_comp-name.
        APPEND wa_field TO i_fieldcat.
      ENDIF.
    ENDLOOP.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program = sy-repid
        it_fieldcat        = i_fieldcat[]
      TABLES
        t_outtab           = it[].
    endif.

  • Hiding a column in the ALV in a webdynpro component(standrad one)

    Hi,
       i have an requirement of hiding a column inside a ALV output of a web dynpro component which is a standrad one. please help me finding the way to do the same.
    thanks,
    selvakumar M.

    data: l_ref_usage type ref to if_wd_component_usage.
    l_ref_usage = wd_this->wd_CpUse_Alv( ).
    if l_ref_usage->has_active_component( ) = abap_false.
      l_ref_usage->create_component( ).
    endif.
    DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
    l_ref_INTERFACECONTROLLER =   wd_This->wd_CpIfc_Alv( ).
      data:
        l_VALUE type ref to Cl_Salv_Wd_Config_Table.
      l_VALUE = l_ref_INTERFACECONTROLLER->Get_Model(
    data: lr_column type ref to CL_SALV_WD_COLUMN.
    lr_column =
    l_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'CARRID' ).
    lr_column->set_visible( CL_WD_UIELEMENT=>E_VISIBLE-NONE ).
    Abhi

  • Hiding few columns before displaying alv grid output

    Hi All,
    I struck up at hiding few columns before displaying alv output. I have used used FM: REUSE_ALV_GRID_DISPLAY. By using this i am displaying 29 fields to the output. But before displaying the output i want to hide few columns among them, and also those fields have to be avialable for further selection by the user by using layout.
    Kindly help me in this,
    Regards
    Srinivas K

    Hi,
    In field catalog set NO_OUT='X' for all the columns you want to hide. They will be available when changing layout for ALV, so you can show them at any time.
    Regards
    Marcin

  • Hide a Column in ALV Grid Output

    Hi,
    I want to hide a column in ALV Grid Output through program.
    I am using   lwa_fieldcat-NO_OUT = 'X'. to hide the column in output but it is not working, column in not hided in the output.
    Kindly suggest.

    It should work..
    see the code :
    d_fieldcat_wa-fieldname = 'MATNR'.
    d_fieldcat_wa-seltext_l = 'material number'.
    d_fieldcat_wa-no_out = 'X'. * hide particular field
    append d_fieldcat_wa to d_fieldcat.
    clear d_fieldcat_wa.
    if not please paste your code here.
    Thanks
    Seshu

  • 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 or Delete Empty columns in dynamic internal table

    Hi,
                                I am having an dynamic internal table which contains more than 100 columns.
             I need to delete empty column from that table, can any one help this.

    Hello,
    If you are talking about ALV then you can just the the table for empty columns before populating fieldcataloge and hide the columns.
    If your query is still not answered please provide a detail requirement.

  • Suppressing empty nodes in ALV tree grid

    Hi,  I'm writing an ALV tree report with financial data broken down by cost element hierarchy. We've determined that the maximum number of levels in our hierarchy is seven so have to build the program to accept seven node levels. Most times when it runs it will find fewer than seven nodes.  Is there an easy to to suppress empty columns in the report so that the end user does not not see a bunch of empty nodes in the report?

    Expand or Collapse Branches or Hide Areas
    You are able to expand and collapse the branches of the tree structure individually or together. Beyond that you are able to make a node or an item completely invisible.
    Methods
    Function                                       Class                                   Method
    Expand individual branch               CL_SALV_NODE                  EXPAND 
    Collapse individual branch                                                        COLLAPSE
    Expand all branches                    CL_SALV_NODES                EXPAND_ALL
    Collapse all branches                                                              COLLAPSE_ALL
    Change visibility of a node            CL_SALV_NODE                  SET_VISIBLE
    Check whether the node is visible                                             IS_VISIBLE
    Change visibility of an item             CL_SALV_ITEM                 SET_VISIBLE
    Check whether the item is visible                                             IS_VISIBLE

  • More then 90 Columns in ALV

    Hi.
    In ALV i want to add more then 90 Columns.
    is their any method to display more then 90 columns in ALV?

    HI,
    ALV is Application List viewer. Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options.
    advantages.
    Collapse multiple reports into one, drastically cutting down your report development time
    Save many hours using built-in ALV sorting, subtotaling and filtering capabilities
    Add conditional structures into your ALV report: No programming required!
    Combine ALV with display variants to meet a wide range of reporting requirements more easily
    Dynamically reorder column layouts and add/subtract fields
    Enable users and analysts to save their own personalized variants
    The keyword is flexibility. In the past I have sometimes programmed more programs that was basically the same report with minor variations - in one case i programmed 10 very similar reports for pp evaluation.
    With ALV the users can define their own display variants without changing the program.
    The display variant covers sorting, summarizing, filtering, hiding fields. The users can also make variants that show only total lines or subtotal lines or both - and by one click in the report they can expand one total line to display the underlying item lines.
    The users can also choose to let the report show directly in excel. This is a very powerful option. You can upload excel templates with predefined formulas and macros. This can make you very popular - especially with Finance people that already have a lot of excel files, they populate with SAP data to make al kind of voodoo calculations that will help them see into the future.
    With ALV you can give them an ABAP report that automatic popup with their own favorite excel book - without having to do a lot of troublesome and time consuming work to download the data and fit it into the excel sheet.
    If you are new to ALV you can very quick make a simple ALV report. Basically it has 3 steps.
    1) build an internal table with the data you want do display
    2) build a field catalog table (each record in this table describes one column in the list)
    3) call the ALV function
    Later you can make use of more complicated functions like call back routines.
    You have both functions modules and ABAP OO classes to help you with step 2 and 3. I have used the function modules for many years so its hard for me to change, but if I should start all over today I would forget about the function modules and go for the OO approach.
    Thanks,
    Sankar M

  • How can i suppress columns in ALV ?? Will reward points.

    Hello Gurus, how can i suppress column in ALV when i`m using the transparent table:
    CALL METHOD grid->set_table_for_first_display
          EXPORTING
            i_structure_name = 'ZIANEXE'
            is_layout        = wa_layout
            is_variant       = wa_variant
            i_save           = 'U'
            IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          CHANGING
            it_outtab        = itab[]
            it_fieldcatalog  = fieldcat.
    Please help.

    in the fieldcatalog you are providing there is a field NO_OUT use this.
    Loop over internal table and check fieldname. If fieldname = column you want to hide, NO_OUT = 'X'.
    Edited by: Micky Oestreich on May 8, 2008 12:06 PM

  • How to Change the position of Column in ALV report

    Hi Follks,
        Is is possible to change the position of column in ALV report?.If yes then how?
        Basically my requirement is, that user want afacility where , he should be able to change the position
        of column aftre he runs the report.
        Eg: After running the report , user felt that column 5 should be at position 2 , in that case he should   
               be able to drag column 5 at position 2 and vice versa.
        Please help me, how to solve this issue.
        Note : I am using NW 7.0 SP 9
        Regards
        PG
    Edited by: PG on Apr 13, 2009 11:10 AM

    HI PG,
    do below whie filling the filed catlog
    wa_fieldcat-fieldname        = 'Field1".
    wa_fieldcat-COL_POS = '1',
    append wa_fieldcat to it_fieldcat.
    wa_fieldcat-fieldname         = 'Field2".
    wa_fieldcat-COL_POS = '2',
    wa_fieldcat-fieldname         = 'Field3".
    wa_fieldcat-COL_POS = '3',
    Thanks!

  • How to display subtotals in separate column in alv report?

    hi,
    I am displayed the subtotals  for QUantity field BDMNG in Reuse_alv_grid_display  in the same column.
    but I want to display subtotal in separate column.
    How to display subtotals in separate column in alv report?
    thanks&regards.
    samba.k

    Hi
    As far as i know you can't do this,the option you have is to create one more column (subtotal) and populate it by manual calculation at every subtotal (not alv subtotal but yours) .
    Best Regards
    Yossi

  • Mulitple Line column headers for a column in ALV using Web Dynpro for ABAP

    Hi WD4A Gurus,
           I have requirement to display the header name in multiple lines for a single column using ALV. How to achieve this, do I need to do some custom code? Please help me with sample code.
    Example:
    existing column name :
                Name   |  Date (mm/dd/yyyy) | Amount
    required column name:
                Name   |    Date               | Amount
    (mm/dd/yyyy)
    Thanks
    Ketan

    Displaying header in multiple lines is not possible in alv
    Regards
    Tamil

Maybe you are looking for

  • Cannot restore do not have Permission in Time Machine HELP

    HI Have searched and Searched but cannot find answer so Help please - all sugestions appriciated Using Mountain Lion , fully updated , however had a Problem with Internet , stopped and could not get it working , so was time to do a Clean Install - fi

  • Default text field for cursor

    I know this has to be posted somewhere but have been able to find a solution for my problem. My form is finished and everything works great, however when I open it in adobe reader to test it, my cursor does not show in the first box which I would lik

  • WOTB condition type

    What is the use of WORB contion type I have seen this in third party sale order ( Seen in PO ) pl reply guru

  • Can Contact Sheet II work in Photoshop CS5?

    I was able to download the Contact sheet II for Photos hop CS4 64 bit. Can it work in CS5? I can't find a dow nload for it.

  • 10.2 iTunes Won't Install In My Computer?

    I have a Windows Vista and i try to install the 10.2 Itunes and it says,"There is a problem with this windows package. A program required for this install to complete could not be run. Contact your support personnel or package vendor." Any Help? Than