4 Replies Latest reply: Feb 29, 2012 11:16 AM by Consultant Danisco Cutltor RSS

Remove / set focus on ALV using objects

Consultant Danisco Cutltor
Currently Being Moderated

I have a screen with 6 subscreen and 6 customercontainers with each 1 ALV, I have 6 ALV's on the same screen, some of the ALV's are only display, and some are for input, my problem is that each alv have fokus on the first cell I want to remove the fokus in all display alv's, I am using the method "set_current_cell_via_id" to place the fokus in edit cell for the alv's with editable cell's, but how to remove fokus in alv, where only display ?

 

Best regards Jørgen Jensen INIT A/S

 

  • Re: Remove / set focus on ALV using objects
    Aleem Mohiuddin
    Currently Being Moderated

    Hi,

     

    Focus is set to the first cell by default.

    CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->set_current_cell_via_id
    
       EXPORTING 
          IS_ROW_ID    =   <structure of type LVC_S_ROW > 
          IS_COLUMN_ID =   <structure of type LVC_S_COL > .

     

    Try keeping passing empty structures to the same method.

     

    Reward points if useful,

    Aleem.

  • Re: Remove / set focus on ALV using objects
    minal nampalliwar
    Currently Being Moderated

    CALL METHOD <b>set_current_cell_via_id</b>

        

     

     

    check for EDIT ALV

     

    &----


    *& Report  ZKB_EDIT_ALV

    &----


     

    REPORT  zkb_edit_alv.

     

    DATA: i_zkb_test TYPE TABLE OF zkb_test,

          w_zkb_test TYPE zkb_test.

     

    DATA: o_grid      TYPE REF TO cl_gui_alv_grid,

          o_container TYPE REF TO cl_gui_custom_container.

     

    DATA: lt_fcat     TYPE lvc_t_fcat,

          ls_layo     TYPE lvc_s_layo,

          ls_sort     TYPE lvc_s_sort,

          lt_sort     TYPE lvc_t_sort,

          ls_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

     

    START-OF-SELECTION.

     

      CALL SCREEN 9000.

     

    &----


    *&      Module  STATUS_9000  OUTPUT

    &----


    •       text

    ----


    MODULE status_9000 OUTPUT.

      SET PF-STATUS '9000'.

    • SET TITLEBAR 'xxx'.

     

    ENDMODULE.                 " STATUS_9000  OUTPUT

    &----


    *&      Module  display_alv_9000  OUTPUT

    &----


    •       text

    ----


    MODULE display_alv_9000 OUTPUT.

     

      IF o_container IS INITIAL.

     

        SELECT * FROM zkb_test INTO TABLE i_zkb_test.

     

        IF cl_gui_alv_grid=>offline( ) IS INITIAL.

     

    • Create a custom container control for ALV Control

          CREATE OBJECT o_container

              EXPORTING

                  container_name = 'CONTAINER'.

     

    • Create a ALV Control

          CREATE OBJECT o_grid

              EXPORTING i_parent = o_container.

     

          PERFORM build_field_catalgue.

     

          CALL METHOD o_grid->set_table_for_first_display

            EXPORTING

              i_save          = 'A'

              i_default       = 'X'

              is_layout       = ls_layo

            CHANGING

              it_outtab       = i_zkb_test

              it_fieldcatalog = lt_fcat

              it_sort         = lt_sort[].

     

        ENDIF.

      ENDIF.

     

    ENDMODULE.                 " display_alv_9000  OUTPUT

    &----


    *&      Module  user_command_9000  INPUT

    &----


    •       text

    ----


    MODULE user_command_9000 INPUT.

      CASE sy-ucomm .

        WHEN 'BACK' OR 'EXIT'.

          SET SCREEN 0.

          LEAVE SCREEN.

        WHEN 'UPDATE'.

          CALL METHOD o_grid->check_changed_data.

          MODIFY  zkb_test FROM TABLE i_zkb_test.

          IF sy-subrc EQ 0.

            COMMIT WORK AND WAIT.

            MESSAGE 'Data updated' TYPE 'I'.

          ENDIF.

    • Refresh the same in ALV

          CALL METHOD o_grid->refresh_table_display.

      ENDCASE.

     

    ENDMODULE.                 " user_command_9000  INPUT

    &----


    *&      Form  build_field_catalgue

    &----


    •       text

    ----


    • -->  p1        text

    • <--  p2        text

    ----


    FORM build_field_catalgue .

     

      DATA: ls_fcat TYPE lvc_s_fcat.

     

      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

        EXPORTING

          i_program_name         = sy-cprog

          i_internal_tabname     = 'I_ZKB_TEST'

          i_structure_name       = 'ZKB_TEST'

          i_client_never_display = 'X'

        CHANGING

          ct_fieldcat            = ls_fieldcat[]

        EXCEPTIONS

          inconsistent_interface = 1

          program_error          = 2

          OTHERS                 = 3.

      IF sy-subrc <> 0.

        MESSAGE 'FCAT Error' TYPE 'I'.

        EXIT.

      ENDIF.

     

      LOOP AT  ls_fieldcat.

        CLEAR ls_fcat.

        ls_fcat-fieldname = ls_fieldcat-fieldname.     "Fieldname

        ls_fcat-ref_table = ls_fieldcat-tabname.       "DDIC ref struct

        ls_fcat-inttype   = ls_fieldcat-inttype.       "Data type

        ls_fcat-outputlen = ls_fieldcat-outputlen.     "Column width

        ls_fcat-coltext   = ls_fieldcat-seltext_m.     "Column Header

        ls_fcat-seltext   = ls_fieldcat-seltext_m.     "Column Desc

        ls_fcat-ref_field = ls_fieldcat-ref_fieldname. "Reference field

        ls_fcat-ref_table = ls_fieldcat-ref_tabname.   "Reference table

        CASE  ls_fieldcat-fieldname.

          WHEN 'MANDT' OR 'SNO'.

            ls_fcat-edit      = ' '.

          WHEN OTHERS.

            ls_fcat-edit      = 'X'.

        ENDCASE.

        APPEND ls_fcat TO lt_fcat.

      ENDLOOP.

     

    ENDFORM.                    " build_field_catalgue

     

    Rewards if useful..........

            Minal Nampalliwar

  • Re: Remove / set focus on ALV using objects
    Uwe Schieferstein
    Currently Being Moderated

    Hello Jørgen

     

    This is one of the rare occasion where I believe that something is NOT possible with SAP.

     

    You may have a look at my sample report

    ZUS_SDN_SPLITTER_CONTAINER

    and play around with various methods yet I doubt you will be successful.

     

    *&---------------------------------------------------------------------*
    *& Report  ZUS_SDN_SPLITTER_CONTAINER
    *&
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*
    
    REPORT  zus_sdn_splitter_container.
    
    **type-pools:  abap.
    
    TYPES: ty_t_knb1    TYPE STANDARD TABLE OF knb1
                        WITH DEFAULT KEY.
    
    TYPES: BEGIN OF ty_s_control.
    TYPES: cell    TYPE REF TO cl_gui_container.
    TYPES: grid    TYPE REF TO cl_gui_alv_grid.
    TYPES: data    TYPE ty_t_knb1.
    TYPES: row     TYPE lvc_s_row.
    TYPES: layout  TYPE lvc_s_layo.
    TYPES: variant TYPE disvariant.
    TYPES: END OF ty_s_control.
    TYPES: ty_t_control  TYPE STANDARD TABLE OF ty_s_control
                         WITH DEFAULT KEY.
    
    DATA:
      gs_control       TYPE ty_s_control,
      gt_controls      TYPE ty_t_control.
    
    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          TYPE REF TO cl_gui_container,
    **  go_grid          TYPE REF TO cl_gui_alv_grid,
      gs_layout        TYPE lvc_s_layo.
    
    
    DATA:
      gd_msg           TYPE bapi_msg,
      gd_perc          TYPE i,
      gd_lines         TYPE i,
      gd_idx           TYPE i,
      gd_cnt           TYPE i,
      gt_knb1          TYPE STANDARD TABLE OF knb1.
    
    
    PARAMETERS:
      p_row    TYPE i  DEFAULT '3',
      p_col    TYPE i  DEFAULT '3'.
    
    START-OF-SELECTION.
    
      PERFORM init_controls.
    
    
    
      DESCRIBE TABLE gt_controls.
      gd_lines = syst-tfill.
    
    
      SELECT * FROM knb1 INTO TABLE gt_knb1 UP TO 100 ROWS
        WHERE bukrs = '1000'.
    
      LOOP AT gt_controls INTO gs_control.
        gd_idx = syst-tabix.
        gd_cnt = syst-tabix * 5.
    
        gd_perc = ( syst-tabix * 100 ) / gd_lines.
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
          EXPORTING
            percentage       = gd_perc
    *       TEXT             = ' '
                  .
    
        gs_control-data = gt_knb1.
        DELETE gt_knb1 INDEX 1.
    
        "   Set individual layout and variant
        gs_control-layout-cwidth_opt = abap_true.
        gs_control-layout-zebra      = abap_true.
        gs_control-layout-no_toolbar = abap_true.
        gs_control-layout-smalltitle = abap_true.
    
        gs_control-row-index = gd_idx.
    
        WRITE gd_idx TO gs_control-layout-grid_title NO-ZERO.
        CONDENSE gs_control-layout-grid_title NO-GAPS.
        CONCATENATE gs_control-layout-grid_title
                    '. Customer'
          INTO gs_control-layout-grid_title.
    
        CALL METHOD gs_control-grid->set_table_for_first_display
          EXPORTING
            i_structure_name = 'KNB1'
            is_layout        = gs_control-layout
            i_save           = 'A'
            is_variant       = gs_control-variant
          CHANGING
            it_outtab        = gs_control-data
          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.
    
        IF ( gd_idx > 1 ).
          CALL METHOD gs_control-grid->set_current_cell_via_id
            EXPORTING
              is_row_id = gs_control-row.
    
          CALL METHOD gs_control-grid->refresh_table_display
    *        EXPORTING
    *          IS_STABLE      =
    *          I_SOFT_REFRESH =
    *        EXCEPTIONS
    *          FINISHED       = 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.
    
        ENDIF.
    
        MODIFY gt_controls FROM gs_control INDEX gd_idx.
      ENDLOOP.
    
      gd_msg = gd_lines.
      CONDENSE gd_msg NO-GAPS.
      CONCATENATE gd_msg 'grids displayed on single screen.'
        INTO gd_msg
        SEPARATED BY space.
      MESSAGE gd_msg  TYPE 'S'.
    
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      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'.
    
    
    
    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.
    
    
        WHEN OTHERS.
      ENDCASE.
    
      CLEAR: gd_okcode.
    
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    
    
    *&---------------------------------------------------------------------*
    *&      Form  INIT_CONTROLS
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM init_controls .
    * define local data
      DATA:
        ld_column  TYPE i,
        ls_control TYPE ty_s_control.
    
      REFRESH: gt_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( 99999 ).
    
    
    * Create splitter container
      CREATE OBJECT go_splitter
        EXPORTING
          parent            = go_docking
          rows              = p_row
          columns           = p_col
    *      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.
    
    
      DO p_col TIMES.
        ld_column = syst-index.
    
        DO p_row TIMES.
    
    * Get cell container
          CLEAR: ls_control.
          CALL METHOD go_splitter->get_container
            EXPORTING
              row       = syst-index
              column    = ld_column
            RECEIVING
              container = ls_control-cell.
    
    *   Create ALV grid
          CREATE OBJECT ls_control-grid
            EXPORTING
              i_parent          = ls_control-cell
            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.
    
          APPEND ls_control TO gt_controls.
        ENDDO.  " rows
    
      ENDDO.  " columns
    
    ENDFORM.                    " INIT_CONTROLS

     

    Regards

      Uwe

     

  • Re: Remove / set focus on ALV using objects
    Consultant Danisco Cutltor
    Currently Being Moderated

    Hello again,

     

    Have tried try use

    CALL METHOD  .

    with empty structure with out any changes the first cell is still in focus...

     

    I also found out if I use the select All tool in standard alv to select all linens and the deselect all again the focus is removed ? but this is not an option as I have no selection in the alv and the alv is display only...

     

    Best Regards Jørgen Jensen

     

Actions