Read modified ALV Cell Data - REUSE_ALV_LIST_DISPLAY

Hi,
I am using REUSE_ALV_LIST_DISPLAY to display my ALV List. There is one editable field in this ALV output.
When user changes any value, In the ALV User Command, the updated value is not reflected.
I know, we use 'GET_GLOBALS_FROM_SLVC_FULLSCR' Function Module to get the updated data.
However its not working for me, as I am not using ALV Grid , but ALV List.
Please let me know, how to read the modified data while using ALV List.

This is old post but i put this info just in case some people have the same issue:
In user command routine i pass two parameters: the command what the user intro and the info of the row was selected. In the info of the row you must update the field refresh with 'X' value and you must update your internal table was referenced in your alv function. this work just if you was set the hotspot and input field setting in the catalog of the ALV (in this example the field "marca")
FORM user_command USING p_ucomm     LIKE sy-ucomm
                                             lw_selfield TYPE slis_selfield.
CASE p_ucomm .
     WHEN '&M_ALL'.
*       mark field "marca" with 'X' value in all rows in it_totales_wf table
       LOOP AT it_totales_wf.
         lw_selfield-refresh = 'X'.
         it_totales_wf-marca = 'X'.
         MODIFY it_totales_wf INDEX sy-tabix.
       ENDLOOP.
     WHEN '&D_ALL'.
       LOOP AT it_totales_wf.
*       unmark field "marca" in all rows in it_totales_wf table        
         lw_selfield-refresh = 'X'.
         CLEAR it_totales_wf-marca.
         MODIFY it_totales_wf INDEX sy-tabix.
       ENDLOOP.
     WHEN '&IC1'.
       lw_selfield-refresh = 'X'.
*       mark field "marca" with in the row selected by the user in it_totales_wf table
       IF lw_selfield-tabindex NE 0 AND lw_selfield-fieldname = 'MARCA'.
         READ TABLE it_totales_wf INDEX lw_selfield-tabindex.
         IF it_totales_wf-marca = 'X'.
           CLEAR it_totales_wf-marca.
         ELSE.
           it_totales_wf-marca = 'X'.
         ENDIF.
         MODIFY it_totales_wf INDEX lw_selfield-tabindex.
       ELSE.
         LOOP AT it_totales_wf.
           it_totales_wf-marca = 'X'.
           MODIFY it_totales_wf.
         ENDLOOP.
       ENDIF.
ENDCASE.

Similar Messages

  • How Do I Open The Excel Spreadshee​t And Modify The Cell Data

    How can I change the cell content in specific excel spreadsheet with ActiveX control? I am using LabVIEW7.1

     you can open the excel file using Active X . The procedur to open the excel file, will get in the examples. There is an ready made Vi. for that.
    Then select the properties Cell in active X, and you can change the cell data by doing some modification in that vi. i hope it will help you.

  • Cell data not getting refreshed in which user enters data OO ALV(editable)

    Hi Friends,
    I am using OO ALV for editable grid display.
    I am unable to change grid data in the cell in which user enters something, using OO ALV. Did through debugging of my own program and found that some problem with system program. Then I did all system debugging. Could not find out why is the grid not getting refreshed with the new data in the cell in which user had entered some value. Rest of the cell's data are getting refreshed with the values which i am updating in the final internal table. I can see that the data in the final internal table is changed for the cell in which user enters data. But even after the call of
          CALL METHOD obj_alvgrid1->refresh_table_display
    does not refreshes the data in the cell in which user had entered data. Rest of the cells data are getting refreshed.
    Piece of code:
      SET HANDLER obj_event_receiver->handle_data_changed
                                         FOR obj_alvgrid1.
        METHODS: handle_data_changed
                       FOR EVENT data_changed OF cl_gui_alv_grid
                           IMPORTING er_data_changed
                                     e_onf4
                                     e_onf4_before
                                     e_onf4_after.
    METHOD handle_data_changed.
      DATA : v_valid    TYPE char1,
             v_refresh  TYPE char1.
    *--check mt_good_cells semantically
      CALL METHOD perform_semantic_checks( er_data_changed ).
    *--If PBO is again visited, just refresh the ALV grid.
      CALL METHOD obj_alvgrid1->refresh_table_display
        EXCEPTIONS
          finished = 1
          OTHERS   = 2.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
    ENDMETHOD.
    METHOD perform_semantic_checks.
        LOOP AT er_data_changed->mt_good_cells INTO w_good.
          v_index = sy-tabix.
          CASE w_good-fieldname.
            WHEN 'ZASCAS'.
    *Now here based on some conditions I am changing my final internal table i_zamtsmatnp
                              MODIFY i_zamtsmatnp FROM w_zamtsmatnp INDEX
                                               w_good-row_id TRANSPORTING
                                                 zascas modif.
    User enters data in zascas field. Based on the data entered, I am changing other fields which is getting refreshed. I am also changing zascas in the program even after user had already entered the value which was bit wrong and i am correcting it in the program on the even "data_changed" even.
    Please help me friends as i m strugling past hours wondering why the data is not getting refreshed for the cell in which user enter data.
    Regards,
    Surya

    Hi Surya,
       The approach you are following is correct. You need to use the comibnation of all these things:
    Event - DATA_CHANGED
    Methods - CHECK_CHANGED_DATA
                 -  GET_CHANGED_DATA.
    However, here are few standard programs which are having similar functionality.
    BCALV_EDIT_03
    BCALV_EDIT_07
    Check out these once.
    Note: If anything is helpful, dont forget to reward points
    Thanks,
    Adithya K
    SAP Practise
    [email protected]

  • Editable WD ALV - Cell Read Only

    Hi,
    Is there any way for making an individual cell read only for a column-row combination.
    My scenario is :
    I have an editable WD ALV with data. Now , in row(e.g Index 4) entry of the table, I want to make column2 and Column3 read only for that particular entry(row no.- Index) !! Please guide me through if there is any way to do the same.
    Best Regards
    Sid

    You will have to create an extra attribute for each of your column, of type boolean under the same node. Now bind  these attributes to the read only property of your column's cell editors.
    Then pass abap_true/abap_false to make the field editable/reaonly.
    Check this wiki for your reference,
    check this Wiki [https://wiki.sdn.sap.com/wiki/display/WDABAP/How%20to%20edit%20conditionally%20row%20of%20a%20ALV%20table%20in%20Web%20Dynpro%20for%20ABAP]
    Regards,
    Radhika.

  • How can I read the last cell of a JTable that a user Enters data

    I have a one column JTable with several rows that a user enters data to. Upon entering the last data, the user clicks a button to read all the data from the rows in the JTable and puts them in an arraylist. If the user does not click enter or navigates away from the last cell, then after clicking the button it does not read the last cell entered. Since the user is clicking on a button to indicate he is done entering data on the table, does he also have to hit the enter key to indicate he is done entering the data?
    The code below is my tablemodelListener:
    public class InteractiveTableModelListener implements TableModelListener {
    public void tableChanged(TableModelEvent evt) {
    if (evt.getType() == TableModelEvent.UPDATE) {
    int row = evt.getFirstRow();
    System.out.println("Update row:"+" "+row);
    jTable1.setRowSelectionInterval(row, row);
    }

    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
    In the future, Swing related questions should be posted in the Swing fourm. (This question has been asked and answered dozens of times).
    But there is not need to repost because [Table Stop Editing|http://www.camick.com/java/blog.html?name=table-stop-editing] explains whats happening and give a couple of solutions.

  • How to make specific cell(s) read-only in a data-grid

    Hi there!
    Is there a way to make an specific cell read-only in a data-grid?
    Best regards,
    Ciro

    Hi !
    After some months... here is the solution:
    Private WithEvents _gridTaste As DataGrid
    Private Sub MyScreen_Created()
    AddHandler FindControl("GridTaste").ControlAvailable,
    Sub(s, e)
    _gridTaste = CType(e.Control, DataGrid)
    End Sub
    End Sub
    Private Sub _gridTaste_BeginningEdit(sender As Object, e As DataGridBeginningEditEventArgs) Handles _gridTaste.BeginningEdit
    ' I want do set the cell (2,0) as read only:
    If e.Row.GetIndex = 2 AndAlso e.Column.DisplayIndex = 0 Then
    e.Cancel = True
    End If
    End Sub
    I hope this post help you too!
    Best regards,
    Ciro

  • Read & Modify the table view data

    Dear Experts,
    CRM 7.0
    I've added few extra custom fields to the table view through Workbench enhancment as AET does not work for my object type. Now, I would like to read the current table entries and accordingly i should fill the other columns. I am not sure how can I proceed. Please advise me asap.
    Many thanks in advance.

    Hi,
    Yes I guess you can do it in DO_PREPARE_OUTPUT.
    Use below code to read values from table:
    DATA:      lv_wrapper         TYPE REF TO cl_bsp_wd_collection_wrapper,
            lr_entity          TYPE REF TO cl_crm_bol_entity,
         lv_attribute         type string,
         LV_ATTRIBUTE_VALUE type string
      TRY.
          lv_wrapper = me->typed_context->ZCONTEXTNODENAME->get_collection_wrapper( ). " Here you will get all values from table into lv_wrapper
          CHECK lv_wrapper IS BOUND.
          lr_entity  ?= lv_wrapper->get_first( ). " Loop at table
          WHILE lr_entity IS BOUND.
            lv_attribute  ?= lr_entity->get_property_as_string( 'ATTRIBUTE NAME' ). " TO read perticular attribute
    *OR as per your requirement you can change the value. Here you can write your logic...
         lr_entity->set_property_as_string( iv_attr_name = 'ATTRIBUTE NAME' iv_value = LV_ATTRIBUTE_VALUE ).  " Change attribute property
          lr_entity  ?= lv_wrapper->get_next( ).
         ENDWHILE.
        CATCH cx_root.
          RETURN.
      ENDTRY.
    Please let me know if it helps.
    Regards,
    Bhushan

  • Web Dynpro ABAP - ALV - insert data

    hi,
    I have got the following task.
    I need to insert a new row into an alv table that shall be editable (data to be edited in the table, where
    a) the other rows of the table, that already exist must not be editable
    b) some columns of the new row are to be initialized with values when creating new row
    can you help here?
    more precise description of the task/problem
    to a) all I found is the possibility to make columns editable, if I wanted to edit new inserted fields directly in the table. This would give the possibility to also edit the rows that are already there and where the data should not be modified...
    to b) I tried with a propriarity button in wddoinit.  DATA lr_btn_new TYPE REF TO cl_salv_wd_fe_button.
      DATA lr_fct_new TYPE REF TO cl_salv_wd_function.
      CREATE OBJECT lr_btn_new.
      lr_btn_new->set_text( 'Request New').
      lr_fct_new = lo_model->if_salv_wd_function_settings~create_function( id = 'BTN_NEW' ).
      lr_fct_new->set_editor( lr_btn_new ).
    and than call an on_function event handler, but now got the problem that I do not know how to insert the row to the table....

    Hi,
    Inserting new row is very simple,just modify your internal table which is attached to the ALV table in the onFunction Event handler method like.
    data: wa_tab type wd_this->elem_flights. "work area is of type context node(structure),now this is empty
    it_flights type table of wd_this->elem_flights,
    v_lines type i.
    Now read the context node data into internal table.
    navigate from <CONTEXT> to <FLIGHTS> via lead selection
      lo_nd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).
    CALL METHOD LO_ND_FLIGHTS->GET_STATIC_ATTRIBUTES_TABLE
      IMPORTING
        TABLE  = lt_flights.
    Modify the internal table from workarea.
    describe table lt_flights lines v_lines.
    modify lt_flights from ls_flights index v_lines. This is to add empty row at the last in the table
    Now bind the internal table to context node.
    To make entire row is editable check this forum threads and articles which i already answered.
    Cell Edit/ Row Edit in ALV WDA
    How to make all columns of alv editable
    Also check this article for conditionally editable.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b71393

  • Dynamical Call of ALV - No data update

    Hi,
    I tried to use use the ALV dynamically. With dynamically I mean that I that I have diffrent data structures, depending what was selected by the user. The first call of the program is always correct. The data is displayed correctly. But when the data structure is changing, the ALV display is not updated.  For a better understanding I post a extract of my coding:
    <b>1. Creation of Container</b>
    CREATE OBJECT g_custom_container
        EXPORTING              
          container_name              = 'PARENT_CONT'
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5.
      IF sy-subrc <> 0.
        ASSERT 1 = 2.
      ENDIF.
    <b>2.Creation of splitter container</b>
      CREATE OBJECT splitter
         EXPORTING
           parent            = g_custom_container
           rows              = 2
           columns           = 2
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
        ASSERT 1 = 2.
      ENDIF.
    container_2 = splitter->get_container(
                                row       = 1
                                column    = 2 ).
    <b>3.Dynamic Creation of alv object</b>
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = container_2.
    <b>4. Get Fieldcatalogue</b>
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = lv_structure_name
        CHANGING
          ct_fieldcat            = lt_fieldcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF sy-subrc <> 0.
        ASSERT 1 = 2.
      ENDIF.
    <b>5. Set table for first display</b>
      CALL METHOD go_grid->set_table_for_first_display
    *    EXPORTING
    *      i_structure_name = lv_structure_name
        CHANGING
          it_fieldcatalog  = lt_fieldcat
          it_outtab        = <lt_out_data>.
      CALL METHOD ls_alv_ref-alv_ref->refresh_table_display.
      CALL METHOD cl_gui_cfw=>flush.
    Perhaps someone could help.....
    Best Regards, Edgar

    Hello Edgar
    The following sample report <b>ZUS_SDN_TWO_ALV_GRIDS_8</b> shows how to solve your problem. Please note that for the sake of simplicity I replaced the tree containing the structure names with an ALV list. However, the switch between the different structures is triggered by the <b>DOUBLE_CLICK</b> event.
    I like to add that the integration of the first displayed ALV list (DD02L) into GT_OUTTAB is not really elegant. In addition, with <b>$TMP</b> I marked a problematic part of the coding with respect to your requirement to have the right layout for each displayed ALV list:
    If you have a <b>fixed </b>assignment of <i>tabname -> 4-digit handle</i> then it is ok. I my sample report the layouts only work if you select the tabnames in the very same order.
    Before showing the entire coding I describe crucial parts of the coding:
    [code]TYPES: BEGIN OF ty_s_outtab.
    TYPES: tabname    TYPE tabname.
    TYPES: layout     TYPE lvc_s_layo.
    TYPES: variant    TYPE disvariant.
    TYPES: fcat       TYPE lvc_t_fcat.
    TYPES: data       TYPE REF TO data.
    TYPES: END OF ty_s_outtab.[/code]
    Every time a new structure is selected the corresponding ALV data are stored as new record in GT_OUTTAB which is of line type TY_S_OUTTAB.
    [code]  READ TABLE gt_outtab INTO gs_outtab INDEX 2.
      ASSIGN gs_outtab-fcat    TO <gt_fcat>.
      ASSIGN gs_outtab-data->* TO <gt_outtab>.[/code]
    Since the ALV list data and the fieldcatalog are fully dynamic I use global field-symbols for these data.
    [code]&----
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
    SET TITLEBAR 'xxx'.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = gs_outtab-tabname
          is_layout        = gs_outtab-layout
          is_variant       = gs_outtab-variant
          i_save           = 'A'
        CHANGING
          it_outtab        = <gt_outtab>
          it_fieldcatalog  = <gt_fcat>
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT[/code]
    The second ALV list which displays the table records is always newly displayed in the PBO module.
    In the event handler method <b>HANDLE_DOUBLE_CLICK</b> we need to do two things:
    - store the current fieldcatalog back to GT_OUTTAB
    - store the name of the new selected table/structure -> trigger PAI
    In routine <b>HANDLE_DB_CLICK</b> we create a new entry for GT_OUTTAB if it does not yet exist. Next we select this entry and display it again as second ALV list.
    [code]
    *& Report  ZUS_SDN_TWO_ALV_GRIDS_8
    *& Description: Display two ALV lists in splitter container (left/right)
    *&              Left ALV list contains DB table names,
    *& right ALV list displays entries of selected DB table
    *& SDN thread: Dynamical Call of ALV - No data update
    *&       Link: https:||Dynamical Call of ALV - No data update
    *& Screen '0100' contains no elements.
    *& ok_code -> assigned to GD_OKCODE
    *& Flow logic:
    PROCESS BEFORE OUTPUT.
       MODULE STATUS_0100.
    PROCESS AFTER INPUT.
       MODULE USER_COMMAND_0100.
    REPORT  zus_sdn_two_alv_grids_8.
    TYPE-POOLS: abap.
    DATA:
      gd_repid         TYPE syst-repid,
      gd_okcode        TYPE ui_func,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_splitter      TYPE REF TO cl_gui_splitter_container,
      go_cell_left     TYPE REF TO cl_gui_container,
      go_cell_right    TYPE REF TO cl_gui_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid,
      gs_layout        TYPE lvc_s_layo.
    TYPES: BEGIN OF ty_s_outtab.
    TYPES: tabname    TYPE tabname.
    TYPES: layout     TYPE lvc_s_layo.
    TYPES: variant    TYPE disvariant.
    TYPES: fcat       TYPE lvc_t_fcat.
    TYPES: data       TYPE REF TO data.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab  TYPE STANDARD TABLE OF ty_s_outtab
                        WITH DEFAULT KEY.
    DATA:
      gt_dd02l         TYPE STANDARD TABLE OF dd02l,
      gs_outtab        TYPE ty_s_outtab,
      gt_outtab        TYPE ty_t_outtab.
    FIELD-SYMBOLS:
      <gt_fcat>        TYPE lvc_t_fcat,
      <gt_outtab>      TYPE table.
          CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          md_tabname_selected  TYPE tabname  READ-ONLY.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
          CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_double_click.
      define local data
        DATA:
          ls_dd02l       TYPE dd02l,
          ls_outtab      TYPE ty_s_outtab.
        CHECK ( sender = go_grid1 ).
        READ TABLE gt_dd02l INTO ls_dd02l INDEX e_row-index.
        "   Store data of currently displayed ALV list (except for DD02L)
        IF ( md_tabname_selected = space ).
        ELSE.
          READ TABLE gt_outtab INTO ls_outtab
               WITH KEY tabname = md_tabname_selected.  " old
          CALL METHOD go_grid2->get_frontend_fieldcatalog
            IMPORTING
              et_fieldcatalog = ls_outtab-fcat.
          MODIFY gt_outtab FROM ls_outtab INDEX syst-tabix.
        ENDIF.
        md_tabname_selected = ls_dd02l-tabname.  " new selected DB table
      Triggers PAI of the dynpro with the specified ok-code
       cl_gui_cfw=>set_new_ok_code( 'HANDLE_DB_CLICK' ).  " not 4.6c
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'HANDLE_DB_CLICK'
         IMPORTING
           RC       =
      ENDMETHOD.                    "handle_double_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      gd_repid = syst-repid.
      SELECT        * FROM  dd02l INTO TABLE gt_dd02l
             WHERE  tabname LIKE 'KN%1'   OR
                    tabname LIKE 'LF%1'   OR
                    tabname LIKE 'VB%'   OR
                    tabname LIKE 'MAR%'   OR
                    tabname LIKE 'E07%'
             AND    tabclass = 'TRANSP'.  " transparent table
      SORT gt_dd02l BY tabname.
      PERFORM init_controls.
      PERFORM add_first_table.
    Set event handler
      SET HANDLER:
        lcl_eventhandler=>handle_double_click FOR go_grid1.
      READ TABLE gt_outtab INTO gs_outtab INDEX 1.
    Display data
      CALL METHOD go_grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = gs_outtab-tabname
          is_layout        = gs_outtab-layout
        CHANGING
          it_outtab        = gt_dd02l
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE gt_outtab INTO gs_outtab INDEX 2.
      ASSIGN gs_outtab-fcat    TO <gt_fcat>.
      ASSIGN gs_outtab-data->* TO <gt_outtab>.
    NOTE: method called in PBO module
    CALL METHOD go_grid2->set_table_for_first_display
       EXPORTING
         i_structure_name = gs_outtab-tabname
         is_layout        = gs_outtab-layout
         is_variant       = gs_outtab-variant
         i_save           = 'A'
       CHANGING
         it_outtab        = <gt_outtab>
         it_fieldcatalog  = <gt_fcat>
       EXCEPTIONS
         OTHERS           = 4.
    IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
         CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    NOTE: dynpro does not contain any elements
      CALL SCREEN '0100'.
    Flow logic of dynpro (does not contain any dynpro elements):
    *PROCESS BEFORE OUTPUT.
    MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
    SET TITLEBAR 'xxx'.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = gs_outtab-tabname
          is_layout        = gs_outtab-layout
          is_variant       = gs_outtab-variant
          i_save           = 'A'
        CHANGING
          it_outtab        = <gt_outtab>
          it_fieldcatalog  = <gt_fcat>
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
      User has pushed button "Display Details"
        WHEN 'HANDLE_DB_CLICK'.
          PERFORM handle_db_click.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  HANDLE_DB_CLICK
          text
    -->  p1        text
    <--  p2        text
    FORM handle_db_click.
    define local data
      DATA:
        ld_handle(4) TYPE n,
        ls_outtab    TYPE ty_s_outtab.
      READ TABLE gt_outtab INTO ls_outtab
           WITH KEY tabname = lcl_eventhandler=>md_tabname_selected.
      IF ( syst-subrc NE 0 ).
        CLEAR: ls_outtab.
        ls_outtab-tabname = lcl_eventhandler=>md_tabname_selected.
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
        I_BUFFER_ACTIVE              =
          i_structure_name             = ls_outtab-tabname
        I_CLIENT_NEVER_DISPLAY       = 'X'
        I_BYPASSING_BUFFER           =
        I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = ls_outtab-fcat
        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.
        CREATE DATA ls_outtab-data TYPE TABLE OF (ls_outtab-tabname).
        ASSIGN ls_outtab-data->* TO <gt_outtab>.
        SELECT * FROM (ls_outtab-tabname) UP TO 50 ROWS
          INTO TABLE <gt_outtab>.
        ls_outtab-layout-no_toolbar = abap_false.
        ls_outtab-layout-zebra      = abap_true.
        ls_outtab-layout-smalltitle = abap_true.
        CONCATENATE ls_outtab-tabname ':'
          INTO ls_outtab-layout-grid_title.
        CONCATENATE ls_outtab-layout-grid_title 'Table Records'
          INTO ls_outtab-layout-grid_title
          SEPARATED BY space.
        ls_outtab-variant-report    = gd_repid.
        DESCRIBE TABLE gt_outtab.
        ld_handle = syst-tfill + 1.
        WRITE ld_handle TO ls_outtab-variant-handle.  " $TMP: Problem!!!
        APPEND ls_outtab TO gt_outtab.
      ENDIF.
      " NOTE: read into GLOBAL variable gs_outtab !!!!
      READ TABLE gt_outtab INTO gs_outtab
            WITH KEY tabname = lcl_eventhandler=>md_tabname_selected.
      ASSIGN gs_outtab-fcat    TO <gt_fcat>.
      ASSIGN gs_outtab-data->* TO <gt_outtab>.
    ENDFORM.                    " HANDLE_DB_CLICK
    *&      Form  INIT_CONTROLS
          text
    -->  p1        text
    <--  p2        text
    FORM init_controls .
    Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_docking->set_extension
        EXPORTING
          extension  = 99999 " full-size screen
        EXCEPTIONS
          cntl_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.
    Create splitter container
      CREATE OBJECT go_splitter
        EXPORTING
          parent            = go_docking
          rows              = 1
          columns           = 2
         NO_AUTODEF_PROGID_DYNNR =
         NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_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.
    Get cell container
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_left.
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 2
        RECEIVING
          container = go_cell_right.
      CALL METHOD go_splitter->set_column_mode
        EXPORTING
          mode              = cl_gui_splitter_container=>mode_relative
       IMPORTING
         RESULT            =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_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.
      CALL METHOD go_splitter->set_column_width
        EXPORTING
          id                = 1
          width             = 25
       IMPORTING
         RESULT            =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_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.
      CALL METHOD go_splitter->set_column_sash
        EXPORTING
          id                = 1
          type              = cl_gui_splitter_container=>type_movable
          value             = cl_gui_splitter_container=>false
       IMPORTING
         RESULT            =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_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.
    Create ALV grids
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent          = go_cell_left
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid2
        EXPORTING
          i_parent          = go_cell_right
        EXCEPTIONS
          OTHERS            = 5.
      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.                    " INIT_CONTROLS
    *&      Form  ADD_FIRST_TABLE
          text
    -->  p1        text
    <--  p2        text
    FORM add_first_table .
    define local data
      DATA:
        ls_outtab    TYPE ty_s_outtab.
      ls_outtab-tabname = 'DD02L'.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
      I_BUFFER_ACTIVE              =
        i_structure_name             = ls_outtab-tabname
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           =
      I_INTERNAL_TABNAME           =
      CHANGING
        ct_fieldcat                  = ls_outtab-fcat
      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.
      GET REFERENCE OF gt_dd02l INTO ls_outtab-data.
      ls_outtab-layout-no_toolbar = abap_false.
      ls_outtab-layout-zebra      = abap_true.
      ls_outtab-layout-smalltitle = abap_true.
      CONCATENATE ls_outtab-tabname ':'
        INTO ls_outtab-layout-grid_title.
      CONCATENATE ls_outtab-layout-grid_title 'Table Records'
        INTO ls_outtab-layout-grid_title
        SEPARATED BY space.
      ls_outtab-variant-report    = gd_repid.
      ls_outtab-variant-handle    = '0002'.
      INSERT ls_outtab INTO gt_outtab INDEX 1.
      ls_outtab-layout-no_toolbar = abap_true.
    ls_outtab-layout-zebra      = abap_true.
    ls_outtab-layout-smalltitle = abap_true.
      ls_outtab-layout-grid_title = 'DB Tables'.
    ls_outtab-variant-report    = gd_repid.
      ls_outtab-variant-handle    = '0001'.
      DELETE ls_outtab-fcat WHERE ( fieldname NE 'TABNAME' ).
      INSERT ls_outtab INTO gt_outtab INDEX 1.
    ENDFORM.                    " ADD_FIRST_TABLE[/code]
    Regards,
      Uwe

  • Alv cell color with FM

    hi ,
    can one send me program for alv cell color with help of function modules
    kiran

    Hi Kiran .
    <b>1.Cell Color.</b>
    While Building Fieldcatalog ,there is one field called
    EMPHASIZE.You have to set like this .
    i_field-emphasize = 'C26'.
    <b>2.ROW COLOR.</b>
    Have a look at this example .
    <b>a</b>.Define one variable COLOR in ur main ITAB.
    <b>b</b>.Fill it .
    <b>c</b>.Pass this info.
      w_layout-info_fieldname = 'COLOR'.
    <b>d</b>. display it .
    *& Report  ZGRID_COLOR                                                 *
    REPORT  zgrid_color                             .
    TYPE-POOLS slis.
    DATA: BEGIN OF i_pa0001 OCCURS 0,
    <b>        color(3) TYPE c,</b>
            pernr TYPE pa0001-pernr,
            subty TYPE pa0001-subty,
          END OF i_pa0001.
    DATA :i_field TYPE slis_t_fieldcat_alv,
          w_field LIKE LINE OF i_field,
          w_layout TYPE slis_layout_alv.
    START-OF-SELECTION .
      PERFORM get_data.
      PERFORM fieldcat.
      PERFORM layout_build.
      PERFORM dispaly .
    *&      Form  fieldcat
    FORM fieldcat .
      CLEAR :w_field,i_field[].
      w_field-fieldname = 'PERNR'.
      w_field-tabname   = 'I_PA0001'.
      w_field-seltext_m = 'PERNR'.
      APPEND w_field TO i_field.
      CLEAR w_field.
      w_field-fieldname = 'SUBTY'.
      w_field-tabname   = 'I_PA0001'.
      w_field-seltext_m = 'SUBTY'.
      APPEND w_field TO i_field.
      CLEAR w_field.
    ENDFORM.                    " fieldcat
    *&      Form  dispaly
    FORM dispaly .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = 'ZGRID_COLOR'
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
    <b>   is_layout                         = w_layout</b>
       it_fieldcat                       = i_field
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = i_pa0001
    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.                    " dispaly
    *&      Form  get_data
    FORM get_data .
      SELECT pernr subty
      FROM pa0001
      INTO CORRESPONDING FIELDS OF TABLE i_pa0001
      UP TO 10 ROWS.
    LOOP AT i_pa0001.
        IF sy-tabix GT 5.
      <b>    i_pa0001-color = 'C51'.</b>
          MODIFY i_pa0001 INDEX sy-tabix.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " get_data
    *&      Form  layout_build
    FORM layout_build .
    <b>  w_layout-info_fieldname = 'COLOR'.</b>
    ENDFORM.                    " layout_build
    I hope it helps u .
    <b>Thanks,
    Venkat.O</b>

  • Color in alv ( cell)

    hello
    i tried to color only some cells in alv but i want just what i write will be colored and not all the row
    for exmaple:
    if i have in one row the value 500 i want just the 500 will have color and not all the row
    thanks

    Hi,
    here is another sample report..
    report zc9_alvgrid_final_now .
    *PROGRAM ON ALV-GRID.
    *TABLE DECLARATION.
    *tables:zc9_employee, zc9_empspec.
    type-pools: slis. "ALV Declarations
    data: celcol1 type slis_specialcol_alv.
    data: syprindex type i value 1.
    *INTERNAL TABLE DECLARATION.
    data: begin of itab_alv1 OCCURS 0,
    emp_id(5) TYPE C,
    emp_name(20) TYPE C,
    certified(3) TYPE C,
    celcol type slis_t_specialcol_alv,
    selected(1) type c,
    end of itab_alv1.
    data: begin of itab_alv3 OCCURS 0,
    emp_id(5) TYPE C,
    emp_name(20) TYPE C,
    certified(3) TYPE C,
    end of itab_alv3.
    data: mulrowtab1 like line of itab_alv1.
    data: mulrowtab like table of itab_alv1.
    data: wa_emp_name like zc9_employee-emp_name.
    data: mulrowindex type i value 1.
    data: maxlines type i.
    data: wa like line of itab_alv1.
    data: wa_itab like line of itab_alv1.
    data: ok-code like sy-ucomm.
    data: ok-code1 like sy-ucomm.
    data: ind type i.
    data: newvar type disvariant.
    data: tempvar type i value 0.
    data: gd_repid like sy-repid.
    *ALV-GRID DATA DECLARATION.
    data: fieldcatalog type slis_t_fieldcat_alv.
    * FIELD CATALOG.
    data: fieldcatalog1 type slis_fieldcat_alv.
    data: gd_layout type slis_layout_alv.
    * LAYOUT DECLARATION.
    data: id_color type c.
    data: eventtable type slis_t_event.
    data: wa_event type slis_alv_event.
    data: newvariant type disvariant.
    data: i_exclude type slis_t_extab, "ALV Exclusion Table
    wa_exclude type slis_extab. "ALV Exclusion Structure
    *VARIANT DECLARATION.
    data: vartype like disvariant.
    data: var_save(1) type c.
    data: w_exit(1) type c.
    data: wx_variant like disvariant.
    data: variant_para like disvariant-variant.
    data: itab_emp like table of zc9_employee.
    data: itab_emp1 like line of itab_emp.
    data: itab_spec like table of zc9_empspec.
    data: itab_spec1 like line of itab_spec.
    data: ls_sort type slis_sortinfo_alv.
    data: lt_sort type slis_t_sortinfo_alv.
    parameter: LAYOUT like disvariant-variant.
    * INITIALIZATION.
    gd_repid = sy-repid.
    *CALLING SELECTION SCREEN-SUBROUTINES.
    *AT SELECTION SCREEN
    at selection-screen output.
    perform init_variant.
    perform variant_default using LAYOUT.
    at selection-screen on value-request for LAYOUT.
    perform variant_select using LAYOUT.
    at selection-screen.
    perform variant_fill.
    newvar = vartype.
    * LAYOUT DECLARATION.
    gd_layout-zebra = 'X'.
    gd_layout-no_input = 'X'.
    gd_layout-colwidth_optimize = 'X'.
    gd_layout-box_fieldname = 'SELECTED'.
    gd_layout-box_tabname = 'ITAB_ALV1'.
    gd_layout-totals_text = 'Totals'(201).
    gd_layout-coltab_fieldname = 'CELCOL'.
    gd_layout-f2code = 'DISP'. "Sets fcode for when double
    * "click(press f2)
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
    i_program_name = gd_repid
    i_internal_tabname = 'ITAB_ALV3'
    i_inclname = gd_repid
    changing
    ct_fieldcat = fieldcatalog
    *FIELD-CATALOG DECLARATION.
    loop at fieldcatalog into fieldcatalog1.
    case fieldcatalog1-fieldname.
    when 'EMP_ID'.
    fieldcatalog1-seltext_m = 'EMP-ID'.
    fieldcatalog1-col_pos = 0.
    fieldcatalog1-outputlen = 10.
    fieldcatalog1-emphasize = 'C2'.
    fieldcatalog1-key = 'X'.
    fieldcatalog1-do_sum = 'X'.
    fieldcatalog1-sp_group = 'A'.
    when 'EMP_NAME'.
    fieldcatalog1-fieldname = 'EMP_NAME'.
    fieldcatalog1-seltext_m = 'EMPLOYEE_NAME'.
    fieldcatalog1-col_pos = 1.
    fieldcatalog1-emphasize = 'C2'.
    fieldcatalog1-hotspot = 'X'.
    fieldcatalog1-key = 'X'.
    fieldcatalog1-outputlen = 20.
    fieldcatalog1-sp_group = 'B'.
    when 'CERTIFIED'.
    fieldcatalog1-fieldname = 'CERTIFIED'.
    fieldcatalog1-seltext_m = 'CERTIFIED'.
    fieldcatalog1-col_pos = 2.
    fieldcatalog1-emphasize = 'C2'.
    fieldcatalog1-key = 'X'.
    fieldcatalog1-sp_group = 'C'.
    endcase.
    modify fieldcatalog from fieldcatalog1.
    endloop.
    *SORTING FIELD CATALOG FIELD.
    ls_sort-spos = 1.
    ls_sort-fieldname = 'EMP_ID'.
    ls_sort-up = 'X'.
    ls_sort-subtot = 'X'.
    append ls_sort to lt_sort.
    *POPULATING THE INTERNAL TABLE.
    ITAB_ALV1-EMP_ID = '15530'.
    ITAB_ALV1-EMP_NAME = 'THILAKJI'.
    ITAB_ALV1-CERTIFIED = 'YES'.
    APPEND ITAB_ALV1.
    ITAB_ALV1-EMP_ID = '15531'.
    ITAB_ALV1-EMP_NAME = 'MATHEWS'.
    ITAB_ALV1-CERTIFIED = 'NO'.
    APPEND ITAB_ALV1.
    ITAB_ALV1-EMP_ID = '15532'.
    ITAB_ALV1-EMP_NAME = 'JAISI'.
    ITAB_ALV1-CERTIFIED = 'YES'.
    APPEND ITAB_ALV1.
    ITAB_ALV1-EMP_ID = '15533'.
    ITAB_ALV1-EMP_NAME = 'ADAMS'.
    ITAB_ALV1-CERTIFIED = 'YES'.
    APPEND ITAB_ALV1.
    ITAB_ALV1-EMP_ID = '15534'.
    ITAB_ALV1-EMP_NAME = 'PAUL'.
    ITAB_ALV1-CERTIFIED = 'NO'.
    APPEND ITAB_ALV1.
    * FORM TO MAKE THE CELL CONTENTS INVISIBLE.
    PERFORM INVISIBLE_CELL_CONTENTS.
    *EXCLUDE-DECLARATION.
    clear wa_exclude.
    wa_exclude-fcode = '&VEXCEL'.
    append wa_exclude to i_exclude.
    * FUNCTION MODULE CALL-REUSE-ALV-GRID-DISPLAY.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = gd_repid
    i_callback_top_of_page = 'TOP-OF-PAGE2' "see FORM
    i_callback_user_command = 'USER_COMMAND'
    i_grid_title = 'ALV GRID-EMPLOYEE'
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    it_sort = lt_sort
    it_excluding = i_exclude
    i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM
    i_save = 'A'
    is_variant = newvar
    tables
    t_outtab = itab_alv1
    exceptions
    program_error = 1
    others = 2.
    * Form TOP-OF-PAGE *
    * ALV Report Header *
    form top-of-page2.
    data: header type slis_t_listheader,
    wa type slis_listheader,
    infield like wa-info,
    nline type i,
    nlinechar(2) type c.
    *TITLE AREA
    wa-typ = 'H'.
    wa-info = 'EMPLOYEE-DETAILS'.
    append wa to header.
    *BELOW AREA.
    wa-typ = 'S'.
    wa-key = 'DATE'.
    concatenate sy-datum+6(2) '.' sy-datum+4(2) '.' sy-datum(4) into wa-info
    append wa to header.
    *NEXT LINE.
    wa-typ = 'S'.
    describe table itab_alv1 lines nline.
    nlinechar = nline.
    wa-key = 'TABLE DETAILS'.
    concatenate 'NO.of.Lines:' nlinechar into wa-info separated by space.
    append wa to header.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = header
    i_logo = 'ALVLOGO'.
    endform.
    * FORM SET_PF_STATUS *
    form set_pf_status using rt_extab type slis_t_extab.
    set pf-status 'NEWSTATUS123'.
    endform.
    * FORM USER_COMMAND *
    * --> R_UCOMM *
    * --> RS_SELFIELD *
    form user_command using r_ucomm like sy-ucomm
    rs_selfield type slis_selfield.
    * Check function code
    case r_ucomm.
    when 'SELM'.
    loop at itab_alv1 where selected = 'X'.
    move-corresponding itab_alv1 to mulrowtab1.
    append mulrowtab1 to mulrowtab.
    endloop.
    message i029(zmc).
    clear mulrowtab1.
    when 'DISP'.
    * Check field clicked on within ALVgrid report
    if rs_selfield-fieldname = 'EMP_ID'.
    * Read data table, using index of row user clicked on
    read table itab_alv1 into wa index rs_selfield-tabindex.
    ind = rs_selfield-tabindex.
    message i025(zmc) with rs_selfield-fieldname .
    elseif rs_selfield-fieldname = 'EMP_NAME'.
    read table itab_alv1 into wa index rs_selfield-tabindex.
    ind = rs_selfield-tabindex.
    message i028(zmc) with rs_selfield-fieldname wa-emp_name .
    endif.
    when 'EXIT'.
    * MESSAGE I026(ZMC).
    leave program.
    when 'CHAN'.
    * READ TABLE itab_alv1 INTO wa INDEX rs_selfield-tabindex.
    read table itab_alv1 into wa index rs_selfield-tabindex.
    call screen 1551.
    tempvar = 1.
    *CALLING THE GRID DISPLAY FUNCTION AGAIN.
    * FUNCTION MODULE CALL-REUSE-ALV-GRID-DISPLAY.
    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 = 'ALV GRID-EMPLOYEE'
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    it_events = eventtable
    i_save = 'X'
    it_excluding = i_exclude
    i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM
    is_variant = newvar
    tables
    t_outtab = itab_alv1
    exceptions
    program_error = 1
    others = 2.
    r_ucomm = '&F03'.
    when '&F03'.
    * IF TEMPVAR = 1.
    leave program.
    endcase.
    clear r_ucomm.
    endform.
    *& Module USER_COMMAND_1551 INPUT
    * text
    module user_command_1551 input.
    data: syprtabix type i.
    case ok-code.
    when 'QUIT'.
    set screen 0.
    leave screen.
    clear itab_alv1.
    sy-tabix = 0.
    when 'UPDA'.
    loop at itab_alv1 where emp_id = wa-emp_id.
    syprtabix = sy-tabix.
    endloop.
    modify itab_alv1 from wa index syprtabix transporting emp_id emp_name
    certified.
    message i027(zmc).
    leave screen.
    endcase.
    endmodule. " USER_COMMAND_1551 INPUT
    *& Module STATUS_1551 OUTPUT
    * text
    module status_1551 output.
    set pf-status 'ZNEWSTATUS'.
    * SET TITLEBAR 'xxx'.
    endmodule. " STATUS_1551 OUTPUT
    *FORM FOR SELECTING LAYOUT.
    form variant_select using form_varpar.
    call function 'LVC_VARIANT_F4'
    exporting
    is_variant = vartype
    * IT_DEFAULT_FIELDCAT =
    i_save = var_save
    importing
    e_exit = w_exit
    es_variant = wx_variant
    exceptions
    not_found = 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.
    if w_exit is initial.
    vartype-variant = wx_variant-variant.
    form_varpar = wx_variant-variant.
    endif.
    endform.
    *& Form init_variant
    form init_variant.
    clear: vartype.
    gd_repid = sy-repid.
    vartype-report = sy-repid.
    vartype-username = sy-uname.
    var_save = 'A'. "All types
    endform.
    *& Form variant_default
    form variant_default using p_variant.
    wx_variant = vartype.
    if not p_variant is initial.
    wx_variant-variant = p_variant.
    endif.
    call function 'LVC_VARIANT_DEFAULT_GET'
    exporting
    i_save = var_save
    changing
    cs_variant = wx_variant
    exceptions
    wrong_input = 1
    not_found = 2
    program_error = 3
    others = 4.
    case sy-subrc.
    when 0.
    p_variant = wx_variant-variant.
    when 2.
    clear: p_variant.
    endcase.
    endform.
    *& Form variant_fill
    form variant_fill.
    clear: vartype.
    if LAYOUT is initial.
    vartype-variant = 'STANDARD'.
    vartype-report = sy-repid.
    else.
    vartype-variant = LAYOUT.
    vartype-report = sy-repid.
    call function 'LVC_VARIANT_EXISTENCE_CHECK'
    exporting
    i_save = var_save
    changing
    cs_variant = vartype
    exceptions
    others = 01.
    if sy-subrc ne 0.
    message i000(zz) with text-g02.
    endif.
    endif.
    endform.
    *& Module STATUS_1234 OUTPUT
    * text
    module status_1234 output.
    * SET PF-STATUS 'xxxxxxxx'.
    * SET TITLEBAR 'xxx'.
    endmodule. " STATUS_1234 OUTPUT
    *& Module USER_COMMAND_1234 INPUT
    * text
    module user_command_1234 input.
    sort mulrowtab.
    describe table mulrowtab lines maxlines.
    case ok-code1.
    when 'OUT1'.
    set screen 0.
    leave screen.
    when 'PUSH'.
    clear mulrowtab1.
    if mulrowindex <= maxlines.
    read table mulrowtab into mulrowtab1 index mulrowindex.
    mulrowindex = mulrowindex + 1.
    else.
    message i030(zmc).
    endif.
    endcase.
    endmodule. " USER_COMMAND_1234 INPUT
    * CEL COLOR TABLE POPULATION.
    FORM INVISIBLE_CELL_CONTENTS.
    loop at itab_alv1 INTO WA.
    IF WA-EMP_ID = ' '.
    EXIT.
    ENDIF.
    clear itab_alv1.
    move-corresponding WA to itab_alv1.
    clear celcol1.
    celcol1-fieldname = 'EMP_ID'.
    celcol1-color-col = syprindex.
    append celcol1 to itab_alv1-celcol.
    celcol1-fieldname = 'EMP_NAME'.
    celcol1-color-col = syprindex + 2.
    append celcol1 to itab_alv1-celcol.
    * CODE FOR MAKING THE GRID CELL CONTENTS INVISIBLE BASED ON THE VALUE OF
    *THE CELL.THE CONDITION CHECKED IS WHETHER
    * CERTIFIED FIELD HAS VALUE 'NO'.
    celcol1-fieldname = 'CERTIFIED'.
    if itab_alv1-certified = 'NO'.
    itab_alv1-emp_name = ' '.
    endif.
    celcol1-color-col = syprindex + 3.
    append celcol1 to itab_alv1-celcol.
    MODIFY ITAB_ALV1.
    syprindex = celcol1-color-col - 1.
    CLEAR ITAB_ALV1.
    endloop.
    ENDFORM.
    Regards,
    Suresh Datti

  • ALV Cell colour

    Hi,
      I want to display the cell colour based on some condition in the ALV grid. pls help me in this.
    Regards
    Rajesh.V

    Hi,
    In Function Module REUSE_ALV_GRID_DISPLAY
    types: begin of slis_specialcol_alv,
    fieldname type slis_fieldname,
    color type slis_color,
    nokeycol(1) type c,
    end of slis_specialcol_alv.
    You can mention color for the display
    and .............
    *& Report ZDEMO_ALVGRID *
    *& Example of a simple ALV Grid Report *
    *& The basic ALV grid, Enhanced to display each row in a different *
    *& colour *
    REPORT zdemo_alvgrid .
    TABLES: ekko.
    type-pools: slis. "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
    ebeln TYPE ekpo-ebeln,
    ebelp TYPE ekpo-ebelp,
    statu TYPE ekpo-statu,
    aedat TYPE ekpo-aedat,
    matnr TYPE ekpo-matnr,
    menge TYPE ekpo-menge,
    meins TYPE ekpo-meins,
    netpr TYPE ekpo-netpr,
    peinh TYPE ekpo-peinh,
    line_color(4) type c, "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
    wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
    gd_tab_group type slis_t_sp_group_alv,
    gd_layout type slis_layout_alv,
    gd_repid like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *& Form BUILD_FIELDCATALOG
    Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but can
    also allow you more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such as
    total. You may need to provide more information than if you were
    simply displaying the result
    I.e. Field type may be required in-order for
    the 'TOTAL' function to work.
    fieldcatalog-fieldname = 'EBELN'.
    fieldcatalog-seltext_m = 'Purchase Order'.
    fieldcatalog-col_pos = 0.
    fieldcatalog-outputlen = 10.
    fieldcatalog-emphasize = 'X'.
    fieldcatalog-key = 'X'.
    fieldcatalog-do_sum = 'X'.
    fieldcatalog-no_zero = 'X'.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'EBELP'.
    fieldcatalog-seltext_m = 'PO Item'.
    fieldcatalog-col_pos = 1.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'STATU'.
    fieldcatalog-seltext_m = 'Status'.
    fieldcatalog-col_pos = 2.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'AEDAT'.
    fieldcatalog-seltext_m = 'Item change date'.
    fieldcatalog-col_pos = 3.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MATNR'.
    fieldcatalog-seltext_m = 'Material Number'.
    fieldcatalog-col_pos = 4.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MENGE'.
    fieldcatalog-seltext_m = 'PO quantity'.
    fieldcatalog-col_pos = 5.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MEINS'.
    fieldcatalog-seltext_m = 'Order Unit'.
    fieldcatalog-col_pos = 6.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'NETPR'.
    fieldcatalog-seltext_m = 'Net Price'.
    fieldcatalog-col_pos = 7.
    fieldcatalog-outputlen = 15.
    fieldcatalog-datatype = 'CURR'.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'PEINH'.
    fieldcatalog-seltext_m = 'Price Unit'.
    fieldcatalog-col_pos = 8.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    endform. " BUILD_FIELDCATALOG
    *& Form BUILD_LAYOUT
    Build layout for ALV grid report
    form build_layout.
    gd_layout-no_input = 'X'.
    gd_layout-colwidth_optimize = 'X'.
    gd_layout-totals_text = 'Totals'(201).
    Set layout field for row attributes(i.e. color)
    gd_layout-info_fieldname = 'LINE_COLOR'.
    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
    is_layout = gd_layout
    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
    *& Form DATA_RETRIEVAL
    Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    data: ld_color(1) type c.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
    from ekpo
    into table it_ekko.
    *Populate field with color attributes
    loop at it_ekko into wa_ekko.
    Populate color variable with colour properties
    Char 1 = C (This is a color property)
    Char 2 = 3 (Color codes: 1 - 7)
    Char 3 = Intensified on/off ( 1 or 0 )
    Char 4 = Inverse display on/off ( 1 or 0 )
    i.e. wa_ekko-line_color = 'C410'
    ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
    if ld_color = 8.
    ld_color = 1.
    endif.
    concatenate 'C' ld_color '10' into wa_ekko-line_color.
    wa_ekko-line_color = 'C410'.
    modify it_ekko from wa_ekko.
    endloop.
    endform. " DATA_RETRIEVAL
    Hope this Helps.
    Regards ,

  • Set ALV Cell visibility property

    Hi,
    I would have 2 tables for ALV. One table consists of the data to be bound to the ALV. The other table would have the read only property(boolean) filled for each of the ALV cells.
    I would want to set the property of each ALV cell using the second table. How do i do that?
    Currently i am just testing it for few attributes statically using the below code.
    DATA lo_nd_date_table TYPE REF TO if_wd_context_node.
    DATA lo_el_date_table TYPE REF TO if_wd_context_element.
    DATA: lt_ele_set TYPE wdr_context_element_set.
    navigate from <CONTEXT> to <DATE_TABLE> via lead selection
      lo_nd_date_table = wd_context->get_child_node( name = wd_this->wdctx_date_table ).
    lt_ele_set = lo_nd_date_table->get_elements( ).
      LOOP AT lt_ele_set INTO lo_el_date_table.
          lo_el_date_table->set_attribute_property(
               attribute_name = 'WK02'                                 -
    > Attribute Name (Column Name)
               property       = if_wd_context_element=>e_property-read_only
               value          =  'X' ).
    << Similarly for other attributes>>
    ENDLOOP.
    I have inserted this code at the end. Initially few other properties were set to the cells.
    This seems to be not working.
    Regards,
    Rekha
    Edited by: Rekha Gopinath on Sep 8, 2009 10:40 AM

    Hi Lekha,
    In my case, the columns represents dates. The rows represent projects. So, only those row cells are editable where the project is valid.
    1. I have created READ_ONLY attribute for the date node (table).
    2. I am filling the READ_ONLY to abap_true or abap_false based on the following condition.
       Even if one of the projects is not valid for a date, then READ_ONLY = ABAP_TRUE. This means, even if one cell is set to abap_true, then READ_ONLY is set to abap_true.
    3. I modify the date node and bind it with the READ_ONLY set row wise.
    Loop at the data and set read only
      navigate from <CONTEXT> to <DATE_TABLE> via lead selection
      lo_nd_date_table = wd_context->get_child_node( name = wd_this->wdctx_date_table ).
      CALL METHOD lo_nd_date_table->get_static_attributes_table
        IMPORTING
          table  = lt_date_table    .
      LOOP AT lt_date_table INTO ls_date_table.
        lv_tabix = sy-tabix.
          READ TABLE wd_this->gt_prop INTO ls_prop INDEX lv_tabix.
          IF sy-subrc EQ 0.
            IF ls_prop-wk01 = abap_true OR         
              ls_prop-wk02 = abap_true OR
              ls_prop-wk03 = abap_true OR
              ls_prop-wk04 = abap_true OR
              ls_prop-wk05 = abap_true OR
              ls_prop-wk06 = abap_true OR
              ls_prop-wk07 = abap_true OR
              ls_prop-wk08 = abap_true OR
              ls_prop-wk09 = abap_true OR
              ls_prop-wk10 = abap_true OR
              ls_prop-wk11 = abap_true OR
              ls_prop-wk12 = abap_true OR
              ls_prop-wk13 = abap_true OR
              ls_prop-wk14 = abap_true OR
              ls_prop-wk15 = abap_true.
              ls_date_table-read_only = abap_true.
            ELSE.
              ls_date_table-read_only = abap_false.
            ENDIF.
          ENDIF.
        MODIFY lt_date_table FROM ls_date_table INDEX lv_tabix TRANSPORTING read_only.
      ENDLOOP.
      CALL METHOD lo_nd_date_table->bind_table
        EXPORTING
          new_items            = lt_date_table
          set_initial_elements = abap_true.
    4. I loop through the column reference and use the code mentioned earlier.
              CREATE OBJECT lr_input
                EXPORTING
                  value_fieldname = lv_id.
              lo_column->set_cell_editor( value  = lr_input ).
              lr_input->set_read_only_fieldname( value = 'READ_ONLY' ).
    The expected output is different from the input i had mentioned earlier for Row 1, row 2, Row 3 and row 4. Here, i would get all the rows as non editable except for Row 3.
    I would want to set all columns based on condition.
    Regards,
    Rekha

  • Hi iam getting the alv grid data in excel format but iam facing one problem

    hi iam getting the alv grid data in excel format but iam facing one problem ,
    i.e., i want it read only  but iam getting it in edit mode i use layout default in excel iam getting in xl directly but in edit mode but i need it in read only mode
    what i have to do for that  and bdy knows reply me i need it urgently.

    there's always edit-mode if you choose excel-inplace - but noone can modify/rewrite the data
    A.

  • How can we modify alv output list

    Hi
    this is fazil.
    Please tell me any body How can we modify alv output list.
    Thanks & Regards
    Fazil
    [email protected]

    Fazil,
    check the program,
    You can find the code in this program 'BCALV_FIELDCAT_TEST'
    *& Report  BCALV_FIELDCAT_TEST                                         *
    This report allows to modify the fieldcatalog of a corresponding
    output table and to view the effects of your changes directly.
    Note that for some changes you need to newly display the whole
    ALV Grid Control, e.g., DDIC-Fields are read only the first time
    you call SET_READY_FOR_FIRST_DISPLAY.
    Note also that not all scenarios can be tested since the output
    table does not comprise all fields to test available features
    of the fieldcatalog. Copy this program and extend the output
    table accordingly if you want to test such a special feature.
    (The field CARRNAME in 'gt_sflight' was added to test field REF_FIELD
    and TXT_FIELD of the fieldcatalog - see what happens if you
    calculate subtotals by carrier-id).
    report  bcalvt_fieldcatalog           .
    data: ok_code               type sy-ucomm,
          save_ok_code          type sy-ucomm,
    fieldcatalog for output table
          gt_fieldcat           type lvc_t_fcat,
    fieldcatalog for fieldcatalog itself:
          gt_fcatfcat           type lvc_t_fcat,
          gs_fcatlayo           type lvc_s_layo.
    Output table
    data: begin of gt_sflight occurs 0.
    data: carrname type s_carrname.
            include structure sflight.
    data: end of gt_sflight.
    data: g_max type i value 100.
    data: g_all type c value SPACE.
    Controls to display gt_sflight and corresponding fieldcatalog
    data: g_docking type ref to cl_gui_docking_container,
          g_alv     type ref to cl_gui_alv_grid.
    data: g_custom_container type ref to cl_gui_custom_container,
          g_editable_alv     type ref to cl_gui_alv_grid.
    LOCAL CLASS Definition
    class lcl_event_receiver definition.
      public section.
        methods handle_data_changed
          for event data_changed of cl_gui_alv_grid
          importing er_data_changed.
    endclass.
    class lcl_event_receiver implementation.
      method handle_data_changed.
    at the time being, no checks are made...
      endmethod.
    endclass.
    data: event_receiver type ref to lcl_event_receiver.
    end-of-selection.
      set screen 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    module status_0100 output.
      set pf-status 'BASIC'.
      set titlebar 'BASICTITLE'.
    create ALV Grid Control in the first run
      if g_docking is initial.
        perform create_and_init_controls.
      endif.
    endmodule.                             " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
      save_ok_code = ok_code.
      clear ok_code.
      case save_ok_code.
        when 'SUBMIT'.
    set the frontend fieldcatalog
    ATTENTION: DDIC-Fields are not updated using this method!
    (see 'RESTART')
          call method g_alv->set_frontend_fieldcatalog
               exporting
                 it_fieldcatalog = gt_fieldcat.
          call method g_alv->refresh_table_display.
          call method cl_gui_cfw=>flush.
        when 'RESTART'.
    Destroy the control currently visible and display it again
    using the changed fieldcatalog.
          perform restart_sflight.
        when '&ALL'.
          perform switch_visibility.
      endcase.
    endmodule.                             " USER_COMMAND_0100  INPUT
    *&      Form  CREATE_AND_INIT_CONTROLS
          text
    -->  p1        text
    <--  p2        text
    form create_and_init_controls.
      create object g_docking
          exporting
               dynnr = '100'
               extension = 150
               side = cl_gui_docking_container=>dock_at_bottom.
      create object g_alv
          exporting
               i_parent = g_docking.
      create object g_custom_container
          exporting
               container_name = 'CC_0100_FIELDCAT'.
      create object g_editable_alv
          exporting
               i_parent = g_custom_container.
    register events
      create object event_receiver.
      set handler event_receiver->handle_data_changed for g_editable_alv.
      call method g_editable_alv->register_edit_event
                    exporting
                       i_event_id = cl_gui_alv_grid=>mc_evt_modified.
      perform build_fieldcatalogs changing gt_fieldcat gt_fcatfcat.
      perform modify_fieldcatalog changing gt_fcatfcat.
      perform select_data.                 "CHANGING gt_sflight
      call method g_alv->set_table_for_first_display
              changing
                   it_outtab       = gt_sflight[]
                   it_fieldcatalog = gt_fieldcat[].
    optimize column width of grid displaying fieldcatalog
      gs_fcatlayo-cwidth_opt = 'X'.
    Get fieldcatalog of table sflight - alv might have
    modified it after passing.
      call method g_alv->get_frontend_fieldcatalog
                importing et_fieldcatalog = gt_fieldcat[].
      call method cl_gui_cfw=>flush.
    Display fieldcatalog of table sflight:
      call method g_editable_alv->set_table_for_first_display
              exporting
                   is_layout       = gs_fcatlayo
              changing
                   it_outtab       = gt_fieldcat[]
                   it_fieldcatalog = gt_fcatfcat[].
    register events
      create object event_receiver.
      set handler event_receiver->handle_data_changed for g_editable_alv.
    endform.                               " CREATE_AND_INIT_CONTROLS
    *&      Form  restart_sflight
          text
    -->  p1        text
    <--  p2        text
    form restart_sflight.
      data: ls_fieldcat type lvc_s_fcat.
    free g_docking and thus g_alv
      call method g_docking->free.
      clear g_docking.
      clear g_alv.
    create new instances
      create object g_docking
          exporting
               dynnr = '100'
               extension = 150
               side = cl_gui_docking_container=>dock_at_bottom.
      create object g_alv
          exporting
               i_parent = g_docking.
    This is an internal method to invalidate all fields in the fieldcat
      loop at gt_fieldcat into ls_fieldcat.
        clear ls_fieldcat-tech_comp.
        modify gt_fieldcat from ls_fieldcat.
      endloop.
    Newly display the list with current fieldcatalog.
      call method g_alv->set_table_for_first_display
              changing
                   it_outtab       = gt_sflight[]
                   it_fieldcatalog = gt_fieldcat.
    Get fieldcatalog - it might be changed by ALV in the last call
      call method g_alv->get_frontend_fieldcatalog
              importing
                   et_fieldcatalog = gt_fieldcat[].
      call method g_editable_alv->refresh_table_display.
      call method cl_gui_cfw=>flush.
    endform.                               " restart_sflight
    *&      Form  select_data
          text
    -->  p1        text
    <--  p2        text
    form select_data.
      data: lt_sflight type table of sflight with header line,
            ls_scarr type scarr.
    select data of sflight
      select * from sflight into table lt_sflight up to g_max rows.
    copy data to gt_sflight and update CARRNAME
      loop at lt_sflight.
        move-corresponding lt_sflight to gt_sflight.
        select single * from scarr into ls_scarr
           where carrid = gt_sflight-carrid.
        gt_sflight-carrname = ls_scarr-carrname.
        append gt_sflight.
      endloop.
    endform.                               " select_data
    *&      Form  BUILD_FIELDCATALOGS
          text
         <--P_GT_FIELDCAT  text
         <--P_GT_FCATFCAT  text
    form build_fieldcatalogs changing p_fieldcat type lvc_t_fcat
                                      p_fcatfcat type lvc_t_fcat.
      data: ls_fcat     type lvc_s_fcat.
    Fieldcatalog for table SFLIGHT: p_fieldcat
    generate fieldcatalog automatically
      call function 'LVC_FIELDCATALOG_MERGE'
          exporting
               i_structure_name       = 'SFLIGHT'
            I_CLIENT_NEVER_DISPLAY = 'X'
           changing
                ct_fieldcat            = p_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.
    shift all column positions to the right except for MANDT
      loop at p_fieldcat into ls_fcat.
        if ls_fcat-fieldname ne 'MANDT'.
          add 1 to ls_fcat-col_pos.
          if ls_fcat-fieldname = 'CARRID'.
            ls_fcat-txt_field = 'CARRNAME'."link CARRNAME to CARRID
          endif.
          modify p_fieldcat from ls_fcat.
        endif.
      endloop.
    create a new line for CARRNAME in p_fieldcat
      clear ls_fcat.
      ls_fcat-fieldname = 'CARRNAME'.
      ls_fcat-ref_table = 'SCARR'.
      ls_fcat-col_pos = 1.
    insert new line before CARRID (do not forget MANDT!).
      insert ls_fcat into p_fieldcat index 1.
    Fieldcatalog for table LVC_T_FCAT:p_fcatfcat
    Generate fieldcatalog of fieldcatalog structure.
    This fieldcatalog is used to display fieldcatalog 'p_fieldcat'
    on the top of the screen.
      call function 'LVC_FIELDCATALOG_MERGE'
          exporting
               i_structure_name       = 'LVC_S_FCAT'
            I_CLIENT_NEVER_DISPLAY = 'X'
           changing
                ct_fieldcat            = p_fcatfcat[]
       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.
    Hide all fields that are not documented (valid for release 4.6A)
      perform hide_fields changing p_fcatfcat.
    endform.                               " BUILD_FIELDCATALOGS
    *&      Module  EXIT_PROGRAM  INPUT
          text
    module exit_program input.
      leave program.
    endmodule.                             " EXIT_PROGRAM  INPUT
    *&      Form  MODIFY_FIELDCATALOG
          text
         <--P_GT_FCATFCAT  text
    form modify_fieldcatalog changing p_fcatfcat type lvc_t_fcat.
      data ls_fcat type lvc_s_fcat.
      loop at p_fcatfcat into ls_fcat.
        ls_fcat-coltext = ls_fcat-fieldname.
        ls_fcat-edit = 'X'.
        if ls_fcat-fieldname = 'COL_POS' or ls_fcat-fieldname = 'FIELDNAME'.
          ls_fcat-key = 'X'.
        endif.
        modify p_fcatfcat from ls_fcat.
      endloop.
    endform.                               " MODIFY_FIELDCATALOG
    form hide_fields changing p_fieldcat type lvc_t_fcat.
      data: ls_fcat type lvc_s_fcat.
    Only show documented fields of fieldcatalog.
    For a documentation choose "Help->Application Help" in the menu.
      loop at p_fieldcat into ls_fcat.
        if not (
             ls_fcat-fieldname eq 'CFIELDNAME'
        or   ls_fcat-fieldname eq 'COL_POS'
        or   ls_fcat-fieldname eq 'COLDDICTXT'
        or   ls_fcat-fieldname eq 'COLTEXT'
        or   ls_fcat-fieldname eq 'CURRENCY'
        or   ls_fcat-fieldname eq 'DD_OUTLEN'
        or   ls_fcat-fieldname eq 'DECIMALS_O'
        or   ls_fcat-fieldname eq 'DECMLFIELD'
        or   ls_fcat-fieldname eq 'DO_SUM'
        or   ls_fcat-fieldname eq 'DRAGDROPID'
        or   ls_fcat-fieldname eq 'EDIT_MASK'
        or   ls_fcat-fieldname eq 'EMPHASIZE'
        or   ls_fcat-fieldname eq 'EXPONENT'
        or   ls_fcat-fieldname eq 'FIELDNAME'
        or   ls_fcat-fieldname eq 'HOTSPOT'
        or   ls_fcat-fieldname eq 'ICON'
        or   ls_fcat-fieldname eq 'INTLEN'
        or   ls_fcat-fieldname eq 'INTTYPE'
        or   ls_fcat-fieldname eq 'JUST'
        or   ls_fcat-fieldname eq 'KEY'
        or   ls_fcat-fieldname eq 'LOWERCASE'
        or   ls_fcat-fieldname eq 'LZERO'
        or   ls_fcat-fieldname eq 'NO_OUT'
        or   ls_fcat-fieldname eq 'NO_SIGN'
        or   ls_fcat-fieldname eq 'NO_SUM'
        or   ls_fcat-fieldname eq 'NO_ZERO'
        or   ls_fcat-fieldname eq 'OUTPUTLEN'
        or   ls_fcat-fieldname eq 'QFIELDNAME'
        or   ls_fcat-fieldname eq 'QUANTITY'
        or   ls_fcat-fieldname eq 'REF_FIELD'
        or   ls_fcat-fieldname eq 'REF_TABLE'
        or   ls_fcat-fieldname eq 'REPREP'
        or   ls_fcat-fieldname eq 'REPTEXT'
        or   ls_fcat-fieldname eq 'ROLLNAME'
        or   ls_fcat-fieldname eq 'ROUND'
        or   ls_fcat-fieldname eq 'ROUNDFIELD'
        or   ls_fcat-fieldname eq 'SCRTEXT_L'
        or   ls_fcat-fieldname eq 'SCRTEXT_M'
        or   ls_fcat-fieldname eq 'SCRTEXT_S'
        or   ls_fcat-fieldname eq 'SELDDICTXT'
        or   ls_fcat-fieldname eq 'SELTEXT'
        or   ls_fcat-fieldname eq 'SP_GROUP'
        or   ls_fcat-fieldname eq 'SYMBOL'
        or   ls_fcat-fieldname eq 'TECH'
        or   ls_fcat-fieldname eq 'TIPDDICTXT'
        or   ls_fcat-fieldname eq 'TOOLTIP'
        or   ls_fcat-fieldname eq 'TXT_FIELD' ).
          ls_fcat-tech = 'X'.
        endif.
        modify p_fieldcat from ls_fcat.
      endloop.
    endform.
    form switch_visibility.
    data:  lt_fcatfcat type lvc_t_fcat,
            ls_fcat type lvc_s_fcat.
    call method g_editable_alv->get_frontend_fieldcatalog
                 importing ET_FIELDCATALOG = lt_fcatfcat.
    if not g_all is initial.
         perform hide_fields changing lt_fcatfcat.
         g_all = SPACE.
    else.
        loop at lt_fcatfcat into ls_fcat.
           if ls_fcat-tech eq 'X'.
               ls_fcat-tech = SPACE.
               ls_fcat-no_out = 'X'.
               modify lt_fcatfcat from ls_fcat.
           endif.
        endloop.
        g_all = 'X'.
    endif.
    call method g_editable_alv->set_frontend_fieldcatalog
                exporting it_fieldcatalog = lt_fcatfcat.
    call method g_editable_alv->refresh_table_display.
    endform.
    Don't forget to rewaard if useful..

Maybe you are looking for

  • Vertical Text in Tables

    I wonder how I can flip text in a single cell of a table to vertical orientation? Thanks for any support.

  • How to show blank as zero in Analyzer

    Hi Experts, I have a question regarding the display of empty cells as 0 . I use some selections and for some selections there are no data (empty cell) in the query. But I need to show this empty cells as 0. I Replaced  original key figure with a form

  • IMac Retina 5K Display changes tones when waking from sleep -- Is this normal?

    Every single time that I wake my Retina iMac from display or system sleep, the colors on the monitor seem to change tones twice: First the display goes from dim to slightly brighter (within first 1-3 seconds) Then the display goes from cooler (blues)

  • Custum SSIS control  commands

    Hi Guys, I have to do a few custom data and dimension synchronization packages and i would like to know if someone knows where i could get a list of commands or guide on how to go about the advanced settings of the data packages. An example would be:

  • C drive resize for DV

    please some one help me, i've a dv6 laptop with 750gb hard drive when i try to resize the c drive to 120GB and make the unallocated area another partition i find a message warning me that the recovery partition will not work, i have recovery DVDs but