ALV GRID DISPLAY USING FACTORY METHODS

Hi all
I am using factory methods for my alv grid display.
I have a list of functionalities, for which i am not able to find a correct method..
1) Header of alv(with all the values of the selection-screen)
2)How to give text to a subtotal(ed) column, i.e. if i subtotal a qty field against a sorted field, i want to display ==> Nett Wt. = 123.00 (for first header entry) and so on for each header entry.
3)how to remove the zeroes from a quantity field?
4) Displaying the cells as blanks where data is 0( for quantity fields if i have a cell with zero value, it should be blank.)
5) double click on a cell to open a transaction with the cell's value.
Any help on this would be appreciated.
Points will be rewarded for sure...
Thanks & Regards
Ravish Garg

Hello Ravish
Regarding the display of zero values as empty cells have a look at my <i>modified </i>sample report <b>ZUS_SDN_CL_SALV_TABLE_INTERACT</b>.
*& Report  ZUS_SDN_CL_SALV_TABLE_INTERACT
REPORT  zus_sdn_cl_salv_table_interact.
TYPE-POOLS: abap.
DATA:
  gt_knb1        TYPE STANDARD TABLE OF knb1.
DATA:
  go_table       TYPE REF TO cl_salv_table,
  go_events      TYPE REF TO cl_salv_events_table.
*       CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      handle_double_click FOR EVENT
          if_salv_events_actions_table~double_click
          OF cl_salv_events_table
          IMPORTING
            row
            column.
ENDCLASS.                    "lcl_eventhandler DEFINITION
*       CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
  METHOD handle_double_click.
*   define local data
    DATA:
      lo_table   TYPE REF TO cl_salv_table,
      lt_orders  TYPE STANDARD TABLE OF bapiorders,
      ls_knb1    TYPE knb1.
    READ TABLE gt_knb1 INTO ls_knb1 INDEX row.
    IF ( syst-subrc = 0 ).
      CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
        EXPORTING
          customer_number             = ls_knb1-kunnr
          sales_organization          = '1000'
*         MATERIAL                    =
*         DOCUMENT_DATE               =
*         DOCUMENT_DATE_TO            =
*         PURCHASE_ORDER              =
*         TRANSACTION_GROUP           = 0
*         PURCHASE_ORDER_NUMBER       =
*       IMPORTING
*         RETURN                      =
        TABLES
          sales_orders                = lt_orders.
*     Create ALV grid instance
      TRY.
          CALL METHOD cl_salv_table=>factory
*        EXPORTING
*          LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
*          R_CONTAINER    =
*          CONTAINER_NAME =
            IMPORTING
              r_salv_table   = lo_table
            CHANGING
              t_table        = lt_orders.
        CATCH cx_salv_msg .
      ENDTRY.
      lo_table->display( ).
**      SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
**      SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
**      CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDMETHOD.                    "handle_double_click
ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
  SELECT        * FROM  knb1 INTO TABLE gt_knb1
         WHERE  bukrs  = '1000'.
* Create ALV grid instance
  TRY.
      CALL METHOD cl_salv_table=>factory
*    EXPORTING
*      LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
*      R_CONTAINER    =
*      CONTAINER_NAME =
        IMPORTING
          r_salv_table   = go_table
        CHANGING
          t_table        = gt_knb1.
    CATCH cx_salv_msg .
  ENDTRY.
* Create event instance
  go_events = go_table->get_event( ).
* Set event handler
  SET HANDLER:
    lcl_eventhandler=>handle_double_click FOR go_events.
  PERFORM modify_columns.
  go_table->display( ).
END-OF-SELECTION.
*&      Form  MODIFY_COLUMNS
*       text
*  -->  p1        text
*  <--  p2        text
FORM modify_columns .
* define local data
  DATA:
    lt_dfies        TYPE ddfields,
    ls_dfies        TYPE dfies,
    lo_typedescr    TYPE REF TO cl_abap_typedescr,
    lo_strucdescr   TYPE REF TO cl_abap_structdescr,
    lo_tabledescr   TYPE REF TO cl_abap_tabledescr,
    lo_columns      TYPE REF TO cl_salv_columns_table,
    lo_column       TYPE REF TO cl_salv_column.
  lo_columns = go_table->get_columns( ).
  lo_typedescr = cl_abap_typedescr=>describe_by_data( gt_knb1 ).
  lo_tabledescr ?= lo_typedescr.
  lo_strucdescr ?= lo_tabledescr->get_table_line_type( ).
  lt_dfies = lo_strucdescr->get_ddic_field_list( ).
  LOOP AT lt_dfies INTO ls_dfies.
    lo_column = lo_columns->get_column( ls_dfies-fieldname ).
    IF ( ls_dfies-keyflag = abap_true ).
      CONTINUE.
    ELSEIF ( ls_dfies-fieldname = 'WEBTR' ).  " Bill of ex. limit
      lo_column->set_zero( if_salv_c_bool_sap=>true ).   " display zero
      lo_column->set_zero( if_salv_c_bool_sap=>false ).  " hide zero
    ELSE.
      lo_column->set_technical( if_salv_c_bool_sap=>true ).  " hide col
    ENDIF.
  ENDLOOP.
ENDFORM.                    " MODIFY_COLUMNS
Regards
  Uwe

Similar Messages

  • Error in field catalog in ALV grid display using classes at do_sum = "X'.

    Hi,
    I'm using classes in ALV Grid display.
    the code for the field catalog is going to dump because of the statement in the field catalog for field 'netwr',do_sum = 'X'.
    that do_sum = 'X' is not working and going to dump when executed.with out that do_sum it is working fine. the error in dump analysys is showing sap standard incude LSLVCF01.
        assign component
               <ls_fieldcat>-fieldname of structure rt_data to <g_field>.
        if sy-subrc ne 0.
          message x000(0k).
        endif.
    sy-subrc is 4 when the program is being executed.
    CODE:
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'VBELN1'.
      ls_fcat-ref_field = 'VBELN'.
      ls_fcat-ref_table = 'VBRK'.
      ls_fcat-coltext = 'Invoice No'.
      ls_fcat-seltext = 'Invoice No'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'BUDAT'.
      ls_fcat-ref_table = 'BKPF'.
      ls_fcat-coltext = 'Invoice Date'.
      ls_fcat-seltext = 'Invoice Date'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
    ls_fcat-fieldname = 'NETWR'.
      ls_fcat-ref_field = 'NETWR'.
      ls_fcat-ref_table = 'VBRK'.
      ls_fcat-coltext = 'Value of Invoice'.
      ls_fcat-seltext = 'Value of Invoice'.
      ls_fcat-datatype = 'CURR'.
      ls_fcat-do_sum = 'X'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
    ENDFORM.
    can u please look in the code and rectify the error,
    would appeciate ur response.
    regards,
    veera.

    Hi,
    try this..
    ls_fcat-fieldname = 'NETWR'.
    ls_fcat-ref_field = 'NETWR'.
    ls_fcat-ref_table = 'VBRK'.
    ls_fcat-coltext = 'Value of Invoice'.
    ls_fcat-seltext = 'Value of Invoice'.
    ls_fcat-datatype = 'CURR'.
    ls_fcat-do_sum = 'X'.
    <b>ls_fcat-cfieldname = 'WAERS'.</b>
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    Regards
    vijay

  • ALV GRID Display using oops in sub screen in which sub screen is in tab

    Hi Mac,
    My requirement is to display an ALV Grid with data in a subscreen which is called in tab strip.
    Could you please help me the code of how actaully i can call th ALV in the tab.
    I want to display one field in editable and remaining 4 fields in display mode.
    Does any one had faced the same issue.This is standard program cloning object.
    Thanks
    Satish Raju

    what is the question? Callin grid in subscreen is the same as in other screen. Create PBO module for creating the grid, PAI to evaluate comands.
    Regards,
    Clemens

  • Sum in ALV grid display using objects

    Hi Experts,
    I have created a Report with ALV using objects and also am able to get SUM for some fields using do_sum = 'X'.
    My problem is i want to do some calculation using the total amount which i have got, how can i do that (or can it be done??).
    Thanks in Advance...
    Santosh

    Hi this may be of some help.
    ABAP List Viewer
    The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
    This helps us to implement all the features mentioned very effectively.
    Using ALV, We can have three types of reports:
    1. Simple Report
    2. Block Report
    3. Hierarchical Sequential Report
    There are some function modules which will enable to produce the above reports without much effort.
    All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
    1. SIMPLE REPORT.
    The important function modules are
    a. Reuse_alv_list_display
    b. Reuse_alv_fieldcatalog_merge
    c. Reuse_alv_events_get
    d. Reuse_alv_commentary_write
    e. Reuse_alv_grid_display
    A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
    The important parameters are :
    I. Export :
    i. I_callback_program : report id
    ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
    iii. I_callback_user_command : routine where the function codes are handled
    iv. I_structure name : name of the dictionary table
    v. Is_layout : structure to set the layout of the report
    vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
    vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
    II. Tables :
    i. t_outtab : internal table with the data to be output
    B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
    The Important Parameters are :
    I. Export :
    i. I_program_name : report id
    ii. I_internal_tabname : the internal output table
    iii. I_inclname : include or the report name where all the dynamic forms are handled.
    II Changing
    ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
    declared in the type pool SLIS.
    C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
    Parameters :
    I. Import :
    Et_Events : The event table is returned with all possible CALLBACK events
    for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
    II. Export :
    I_List_type :
    0 = simple list REUSE_ALV_LIST_DISPLAY
    1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
    2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
    3 = hierarchical-sequential block list
    REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
    Parameters :
    I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
    This internal table has three fields :
    Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action
    Key : only when typ is ‘S’.
    Info : the text to be printed
    E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
    Parameters : same as reuse_alv_list_display
    This is an example for simple list.
    2. BLOCK REPORT
    This is used to have multiple lists continuously.
    The important functions used in this report are:
    A. REUSE_ALV_BLOCK_LIST_INIT
    B. REUSE_ALV_BLOCK_LIST_APPEND
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    A. REUSE_ALV_BLOCK_LIST_INIT
    Parameters:
    I. I_CALLBACK_PROGRAM
    II. I_CALLBACK_PF_STATUS_SET
    III. I_CALLBACK_USER_COMMAND
    This function module is used to set the default gui status etc.
    B. REUSE_ALV_BLOCK_LIST_APPEND
    Parameters :
    Export :
    I. is_layout : layout settings for block
    II. it_fieldcat : field catalog
    III. i_tabname : internal table name with output data
    IV. it_events : internal table with all possible events
    Tables :
    i. t_outtab : internal table with output data.
    This function module adds the data to the block.
    Repeat this function for all the different blocks to be displayed one after the other.
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    This function module is used for hierarchical sequential blocks.
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    Parameters : All the parameters are optional.
    This function module display the list with data appended by the above function.
    Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
    3. Hierarchical reports :
    Hierarchical sequential list output.
    The function module is
    A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
    Parameters:
    I. Export:
    i. I_CALLBACK_PROGRAM
    ii. I_CALLBACK_PF_STATUS_SET
    iii. I_CALLBACK_USER_COMMAND
    iv. IS_LAYOUT
    v. IT_FIELDCAT
    vi. IT_EVENTS
    vii. i_tabname_header : Name of the internal table in the program containing the
    output data of the highest hierarchy level.
    viii. i_tabname_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    ix. is_keyinfo : This structure contains the header and item table field
    names which link the two tables (shared key).
    II. Tables
    i. t_outtab_header : Header table with data to be output
    ii. t_outtab_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.
    Important Attributes :
    A. col_pos : position of the column
    B. fieldname : internal fieldname
    C. tabname : internal table name
    D. ref_fieldname : fieldname (dictionary)
    E. ref_tabname : table (dictionary)
    F. key(1) : column with key-color
    G. icon(1) : icon
    H. symbol(1) : symbol
    I. checkbox(1) : checkbox
    J. just(1) : (R)ight (L)eft (C)ent.
    K. do_sum(1) : sum up
    L. no_out(1) : (O)blig.(X)no out
    M. outputlen : output length
    N. seltext_l : long key word
    O. seltext_m : middle key word
    P. seltext_s : short key word
    Q. reptext_ddic : heading (ddic)
    R. ddictxt(1) : (S)hort (M)iddle (L)ong
    S. datatype : datatype
    T. hotspot(1) : hotspot
    with regards,
    Hema Sundara.
    pls reward if u find it helpful.

  • LOGO required in ALV top of page using factory method

    Hi,
    I am doing an ALV using factory method of class Cl_SALV_TABLE. Can any one help me about putting a LOGO on the top of page.
    Thanks in advance.
    Amitava

    Hi,
    In START-OF-SELECTION.
    put form to display header
    like PERFORM build_header
    gr_table->display( ).
    then...
    in FORM
    FORM build_header.
    lr_grid  TYPE REF TO cl_salv_form_layout_grid,
    lr_logo  TYPE REF TO cl_salv_form_layout_logo,
    create object lr_logo.
      lr_logo->set_left_content( lr_grid ).
      lr_logo->set_right_logo( 'LOGO_NAME' ).
    * Set the element top_of_list
      gr_table->set_top_of_list( lr_logo ).
    ENDFORM.
    thanx.

  • Drill down capabilities for an alv grid display field using oops concept

    Hi All,
    could anyone help me in how to achieve the drill down capabilities for an alv grid display field using oops concept.
    Thanks & Regards,
    padmasri.

    padmasri,
    Hope your requirement is something like, when you click on a sales order number it should display that order (VA03), in a grid output displayed using set_table_for_first_display.
    you can acheive it using event double click.
    *&            L O C A L  C L A S S E S   -   D E F I N I T O N         *
    class lcl_event_receiver: local class to handle event DOUBLE_CLICK
    CLASS LCL_EVENT_RECEIVER DEFINITION.
      PUBLIC SECTION.
        METHODS:
        HANDLE_DOUBLE_CLICK
            FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                IMPORTING E_ROW E_COLUMN.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    *&    L O C A L  C L A S S E S   -   I M P L E M E N T A T I O N       *
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
      METHOD HANDLE_DOUBLE_CLICK.
        PERFORM HANDLE_DOUBLE_CLICK USING E_ROW
                                          E_COLUMN.
      ENDMETHOD.                           "handle_double_click
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    FORM HANDLE_DOUBLE_CLICK USING E_ROW    TYPE LVC_S_ROW
                                   E_COLUMN TYPE LVC_S_COL.
      DATA: LS_DETAIL LIKE LINE OF T_OUTPUT.
          WHEN 'T_OUTPUT'.
            READ TABLE T_OUTPUT   INDEX E_ROW-INDEX INTO LS_DETAIL.
    If clicked on PO Number or PO Item, call ME23
        IF E_COLUMN-FIELDNAME = 'EBELN' OR
           E_COLUMN-FIELDNAME = 'EBELP' .
          SET PARAMETER ID 'BES' FIELD LS_DETAIL-EBELN.
          SET PARAMETER ID 'BSP' FIELD LS_DETAIL-EBELP.
          CALL TRANSACTION 'ME23' AND SKIP FIRST SCREEN.
    If clicked on sales order number or item, call VA03
        ELSEIF E_COLUMN-FIELDNAME = 'VBELN' OR
               E_COLUMN-FIELDNAME = 'POSNR'.
          SET PARAMETER ID 'AUN' FIELD LS_DETAIL-VBELN.
          SET PARAMETER ID 'APO' FIELD LS_DETAIL-POSNR.
          CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    Hope this helps

  • How to add a new button in an ALV using factory method

    im using factory method to creat an ALV
    The reason why I'm doing this is because I want the ALV and the selection screen in the same screen like exemplified here http://help-abap.blogspot.com/2008/10/dispaly-alv-report-output-in-same.html
    CALL METHOD cl_salv_table=>factory
                EXPORTING
                  list_display   = if_salv_c_bool_sap=>false
                  r_container    = lo_cont
                  container_name = 'DOCK_CONT'
                IMPORTING
                  r_salv_table   = lo_alv
                CHANGING
                  t_table        = me->t_data.
    The above code already uses every parameter that method as to offer.
    Is it possible to add extra buttons to an ALV using that method?

    Hi Ann,
    The reason you are not able to see any of the new columns as a option to select in your web service block is because when you have published that block, they were not present. Add these two new objects in your block and publish it again. You will be prompted for duplication content. Select the highlighted block for duplicate and now you can see the new added objects in the filter option. Update and this will overwrite your published block. Please note, web services do appear to behave weirdly when used with dashboards so I request you to please try it in a separate test report first.
    Hope that helps.
    Regards,
    Tanisha

  • Regarding output using alv grid display

    Hi experts,
        i have a program
    FS_TAB1-A = P_T1.
    IF P_T1 = 0.
      TEMP1 = 1.
      DO TEMP1 TIMES.
        FS_TAB1-A = P_T1 * DUMMY1.
        APPEND FS_TAB1 TO T_TAB1.
        DUMMY1 = DUMMY1  + 1.
      ENDDO.
    now i have to diplay the p_t1*dummy1 using alv grid display like it goes into thew  loop for ten times then i have to show it 10 times like
    10 1  102 103 104 111 112  like that can u help me

    hi,
        you have to get the result of the multiplication at each row and then concatenate the result and the factor to show the final result in multiples value and multiplication factor...

  • Problem in displaying Alv grid output  using oops........

    hi,
    i have two problems in displaying ALV grid output Using Oops.
    1) How to modify the fieldcatalog after we getting a field catalog using general FM.
    2) initialy it is displaying 13 fields but there are 63 fields .
       eventhough we chage the layout to 63 fields it is displaying only 13 fields , these 13 fields may be different based on our selection but count  of displayed fileds are same . how can display 63 fields at a time .

    Hi,
    You can chnage using below code:
    loop at gt_fieldcat.
    if <gt_fieldcat-field_name> = 'FIELDNAME'.
    endif.
    modify gt_fieldcat.
    clear gt_fieldcat.
    endloop.
    Make sure that all the field should not have no_out = 'X' and tech = 'X'.
    Thanks,
    Sriram Ponna.

  • Want to display more than 300 charcters in a column using ALV grid display

    Hi Guru's,
    I am trying to display more than 500 charcters in a column using alv grid display but it in the output it is showing only 128 characters. Can you help me to display all the characters in particular column Or is there any limitation in maximum of no of charcters for a column?
    Thanks,
    Radha.

    Hi Paurl,
    Define a work area say
    wa_layout type slis_layout_alv.
    then fill this work area as
    wa_layout-zebra = X
    wa_layout-colwidth_optimize = X.
    wa_layout-max_linesize = 300.
    Then in FM 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    is_layout = wa_layout
    etc.
    you provided this for the field which is displayed in alv grid will have more than 128 characters.
    from this code i want,how it refers to particular field.
    when i mentioned field catalog-OUTPUTLEN = '300'.
    it is not displayed the field morethan 128 characters.
    it only displays 128 characters.
    please provide me clear and breif information with suitable code.
    i am trying what your sending but it is not displayed more than 128 characters.
    if you don't mind please spend for me some time for this and
    give me clear and breif information with suitable code.
    Thanks & Regards,
    Radhakrishna.

  • How to display field of 250 character length using ALV Grid display

    Hello Experts,
    Currently I'm using 4.6 version.
    I got to insert a new field of length 250 characters into an existing ALV grid display.
    I passed a value of length 250 chars into the field and assigned it to the itab passing to the fn module
    'REUSE_ALV_GRID_DISPLAY'.
    But in the ALV display I am able to view only 132 chars only. I increased the line-size of the report also accordingly. But I'm unable to view all the 250 chars.
    Kindly help me out in fixing this issue.

    you just can't do that
    I suggest that you put the first characters in cell and allow user to double-click on cell in order to view the full value in a popup window

  • Use of I_CALLBACK_USER_COMMAND in ALV grid display

    Hi experts,
    When i am using the parameter I_CALLBACK_USER_COMMAND in grid display and when i click on BACK button, then the Function code for BACK button is not captured i.e. it does not go in the routine which i have written. But this is not the case with SAVE button. When i click on save button, then it goes in the routine ( i have put a breakpoint in the routine) and also the value of Function code for SAVE button is fetched. Then why is it not working for BACK or CANCEL button??
    Thanks in advance

    Actually my requirement is as follows.
    I have develpoed a screen program in which i have a created a button & on the click of this button i call the reuse alv grid display FM  which displays in the alv grid format. For this I have used an internal table whose first field is checkbox.( While creating the field catalog itab to be passed to reuse alv grid display i mark the checkbox field as 'X' for the first field.) Now when i display the alv, i need to select certain records. For this i tick mark the necessary records. But then when i click on the back button and come to the previous screen, i am not able to capture these selected records. How do i proceed

  • Coloring an single field of an ALV using factory method

    how can we color just a single field in ALV using factory method.

    Hello Regi you may want to check this sample code, basically what you need is to use the lvc_s_colo structure and the  set_color method of the class cl_salv_column_table.
    METHOD set_colors.
    *.....Color for COLUMN.....
        DATA: lo_cols_tab TYPE REF TO cl_salv_columns_table,
              lo_col_tab  TYPE REF TO cl_salv_column_table.
        DATA: ls_color TYPE lvc_s_colo.    " Colors strucutre
    *   get Columns object
        lo_cols_tab = co_alv->get_columns( ).
        INCLUDE <color>.
    *   Get ERDAT column & set the yellow Color fot it
        TRY.
            lo_col_tab ?= lo_cols_tab->get_column( 'ERDAT' ).
            ls_color-col = col_total.
            lo_col_tab->set_color( ls_color ).
          CATCH cx_salv_not_found.
        ENDTRY.
    *.......Color for Specific Cell & Rows.................
    *   Applying color on the 3rd Row and Column AUART
    *   Applying color on the Entire 5th Row
        DATA: lt_s_color TYPE lvc_t_scol,
              ls_s_color TYPE lvc_s_scol,
              la_vbak    LIKE LINE OF ct_vbak,
              l_count    TYPE i.
        LOOP AT ct_vbak INTO la_vbak.
          l_count = l_count + 1.
          CASE l_count.
    *       Apply RED color to the AUART Cell of the 3rd Column
            WHEN 3.
              ls_s_color-fname     = 'AUART'.
              ls_s_color-color-col = col_negative.
              ls_s_color-color-int = 0.
              ls_s_color-color-inv = 0.
              APPEND ls_s_color TO lt_s_color.
              CLEAR  ls_s_color.
    *       Apply GREEN color to the entire row # 5
    *         For entire row, we don't pass the Fieldname
            WHEN 5.
              ls_s_color-color-col = col_positive.
              ls_s_color-color-int = 0.
              ls_s_color-color-inv = 0.
              APPEND ls_s_color TO lt_s_color.
              CLEAR  ls_s_color.
          ENDCASE.
    *     Modify that data back to the output table
          la_vbak-t_color = lt_s_color.
          MODIFY ct_vbak FROM la_vbak.
          CLEAR  la_vbak.
          CLEAR  lt_s_color.
        ENDLOOP.
    *   We will set this COLOR table field name of the internal table to
    *   COLUMNS tab reference for the specific colors
        TRY.
            lo_cols_tab->set_color_column( 'T_COLOR' ).
          CATCH cx_salv_data_error.                         "#EC NO_HANDLER
        ENDTRY.
      ENDMETHOD.                    "set_colors

  • Beginner ALV Grid question (using OO) "Possible Values" doesn't do anything

    Hi,
    I have a working ALV Grid report using the 'CL_CALV_TABLE' class, and FACTORY DISPLAY method.
    Standard Functions are working, got single-click events programmed to drill-down into documents, key columns, etc.
    So the report output seems fine.
    <i>However, some columns / cells have a "possible values" icon, but when selected nothing happens. And some columns have the icon, for example, Material, Co.Code, but then others don't. </i>
    I've looked at example report SALV_DEMO_TABLE_COLUMNS and SALV_TEST_FUNCTIONS, but I can't see any specific code in there that controls this.
    <u>Would appreciate it if anyone can confirm:</u>
    a) what triggers the icon to appear for some columns/cells but not others? Is it the TYPE of the table column?
    b) is any coding needed for the "Possible values" window to popup?
    TIA,
    James

    Seems like f4availabl field is enabled in field catalog.

  • Dump when summing up CURR field in ALV GRID display

    Hi All,
    I am getting dump when I try to sum the CURR field in my ALV Grid Display. The field is of CURR 23.  I am using classes and methods to display alv grid.
    I tried passing <fs_fieldcat>-do_sum = 'X'. When I did this, it is dumping without even displaying the alv grid.
    Here is the part it is throwing dump:
            ls_lvc_data-value = space.
            clear ls_lvc_data-style.
            loop at it_fcat_local assigning <ls_fcat>
                    where tech ne 'X' and no_out ne 'X'.
              if l_invisible eq 'X'.
                clear l_invisible.
                if <ls_fcat>-do_sum is initial.
                  continue.
                else.
                  clear ls_lvc_data-col_pos.
                endif.
              endif.
              add 1 to ls_lvc_data-col_pos.
              assign component <ls_fcat>-fieldname
                               of structure <ls_data> to <l_field_value>.
              _if sy-subrc ne 0.
                message x000(0k).
              endif._
    Regards,
    Guru

    Thomas,
    Here is the dump:
    Runtime Errors         MESSAGE_TYPE_X
    Date and Time          10/22/2010 23:30:53
    Short text
    The current application triggered a termination with a short dump.
    What happened?
    The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X).
    Error analysis
    Short text of error message:
    Long text of error message:
    Technical information about the message:
    Message class....... "0K"
    Number.............. 000
    Variable 1.......... " "
    Variable 2.......... " "
    Variable 3.......... " "
    Variable 4.......... " "
    How to correct the error
    Probably the only way to eliminate the error is to correct the program.
    If the error occures in a non-modified SAP program, you may be able to
    find an interim solution in an SAP Note.
    If you have access to SAP Notes, carry out a search with the following
    keywords:
    "MESSAGE_TYPE_X" " "
    "SAPLSLVC" or "LSLVCF36"
    "FILL_DATA_TABLE"
    If you cannot solve the problem yourself and want to send an error
    notification to SAP, include the following information:
    1. The description of the current problem (short dump)
    To save the description, choose "System->List->Save->Local File
    (Unconverted)".
    2. Corresponding system log
    Display the system log by calling transaction SM21.
    Restrict the time interval to 10 minutes before and five minutes
    after the short dump. Then choose "System->List->Save->Local File
    (Unconverted)".
    3. If the problem occurs in a problem of your own or a modified SAP
    program: The source code of the program
    In the editor, choose "Utilities->More
    Utilities->Upload/Download->Download".
    4. Details about the conditions under which the error occurred or which
    actions and input led to the error.
    Source Code Extract
    Line
    SourceCde
    2708
    is_subtottxt_info = ls_subtot_info
    2709
    ip_subtot_line    = lr_data
    2710
    changing
    2711
    c_subtottxt       = l_subtottxt.
    2712
    ls_lvc_data-value = l_subtottxt.
    2713
    2714
    append ls_lvc_data to ct_lvc_data.
    2715
    endif.
    2716
    2717
    2718
    Column per Fieldcat Entry
    2719
    2720
    ls_lvc_data-value = space.
    2721
    clear ls_lvc_data-style.
    2722
    loop at it_fcat_local assigning <ls_fcat>
    2723
    where tech ne 'X' and no_out ne 'X'.
    2724
    if l_invisible eq 'X'.
    2725
    clear l_invisible.
    2726
    if <ls_fcat>-do_sum is initial.
    2727
    continue.
    2728
    else.
    2729
    clear ls_lvc_data-col_pos.
    2730
    endif.
    2731
    endif.
    2732
    2733
    add 1 to ls_lvc_data-col_pos.
    2734
    2735
    assign component <ls_fcat>-fieldname
    2736
    of structure <ls_data> to <l_field_value>.
    2737
    if sy-subrc ne 0.
    >>>>>
    message x000(0k).
    2739
    endif.
    2740
    2741
    *... work on average
    2742
    if <ls_fcat>-do_sum eq 'C'.
    2743
              Initialize average result and entries
    2744
    <l_field_value> = 0.
    2745
    clear l_entries.
    2746
    2747
              retrive unit from fieldcatalog
    2748
    assign space to <l_unit>.
    2749
    if not <ls_fcat>-cfieldname is initial.
    2750
    assign component <ls_fcat>-cfieldname
    2751
    of structure <ls_data> to <l_unit>.
    2752
    endif.
    2753
    if not <ls_fcat>-qfieldname is initial.
    2754
    assign component <ls_fcat>-qfieldname
    2755
    of structure <ls_data> to <l_unit>.
    2756
    endif.
    2757

Maybe you are looking for