Skip to Content
author's profile photo Former Member
Former Member

Hi guru I want freez field in OOPS Alv

Hi Guru,

I want freez fields (contract no and matnr ) in OOPS Alv so that contract no and matnr always displayed when scrolling across bar.

Please urgent .

Points will reward.

Thanks

Ramana

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 11:44 AM

    Hi,

    In the fieldcat table for the contract no and matnr use

    fcat-FIX_COLUMN = 'X'.

    regards,

    Santosh Thorat

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      In the fieldcat table for the contract no and matnr use

      fcat-FIX_COLUMN = 'X'.

      Its not having any effect in OOPS ALV I want fix colum (Matnr) so that user can

      scroll (across) it and last he can see what is value for this matrial.

      Please urgent.

      regards,

      Ramana.

  • Posted on Nov 21, 2007 at 09:08 PM

    Hello Ramana

    The sample report <b>ZUS_SDN_ALVGRID_FIX_COLUMN</b> shows you how to fix columns in ALV lists. Obviously, the fixed columns must be on the left side of the ALV list. Crucial attributes in the fieldcatalog are:

            ls_fcat-key        = abap_true.
            ls_fcat-fix_column = abap_true.

    *&---------------------------------------------------------------------*
    *& Report  ZUS_SDN_ALVGRID_FIX_COLUMN
    *&
    *&---------------------------------------------------------------------*
    *& Description: Demonstrates how to fix columns in ALV lists
    *&
    *&---------------------------------------------------------------------*
    
    REPORT  zus_sdn_alvgrid_fix_column.
    
    
    TYPE-POOLS: abap.
    
    TABLES:  vbep.
    
    DATA:
      gd_repid         TYPE syrepid,
      gd_okcode        TYPE sy-ucomm,
    *
      gs_layout        TYPE lvc_s_layo,
      gt_fcat          TYPE lvc_t_fcat,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid          TYPE REF TO cl_gui_alv_grid.
    
    
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE vbpa.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    
    
    
    DATA:
      gs_outtab        TYPE ty_s_outtab,
      gt_outtab        TYPE ty_t_outtab.
    
    
    
    
    *---------------------------------------------------------------------*
    *       CLASS lcl_eventhandler DEFINITION
    *---------------------------------------------------------------------*
    *
    *---------------------------------------------------------------------*
    CLASS lcl_eventhandler DEFINITION.
    
      PUBLIC SECTION.
    
        CLASS-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
              e_ucomm
              sender.
    
    
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    
    
    *---------------------------------------------------------------------*
    *       CLASS lcl_eventhandler IMPLEMENTATION
    *---------------------------------------------------------------------*
    *
    *---------------------------------------------------------------------*
    CLASS lcl_eventhandler IMPLEMENTATION.
    
      METHOD handle_data_changed.
    *   define local data
    
    
    
      ENDMETHOD.                    "handle_data_changed
    
    
    
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    
    
    
    
    START-OF-SELECTION.
    
    
      SELECT * FROM  vbpa INTO TABLE gt_outtab UP TO 20 ROWS.
    
    
    
    
    * 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.
    
    
    * Create ALV grid
      CREATE OBJECT go_grid
        EXPORTING
          i_parent          = go_docking
        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.
    
    
    
    * Build fieldcatalog
      PERFORM build_fieldcatalog.
    
      PERFORM set_layout.
    
      SET HANDLER:
        lcl_eventhandler=>handle_data_changed          FOR go_grid.
    
    
    
    * Display data
      CALL METHOD go_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
        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.
    
    
      CALL METHOD go_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter
        EXCEPTIONS
          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.
    
    
    * 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.
    
    
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    * Flow logic (no elements on screen):
    *  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'.
    *  SET TITLEBAR 'xxx'.
    
      CALL METHOD go_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.
    
    ENDMODULE.                 " STATUS_0100  OUTPUT
    
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_0100  INPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE user_command_0100 INPUT.
    
      TRANSLATE gd_okcode TO UPPER CASE.
    
    * Fetch changes on ALV grid
      go_grid->check_changed_data( ).
    
      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  BUILD_FIELDCATALOG_KNB1
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM build_fieldcatalog .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat,
        lt_fcat        TYPE lvc_t_fcat.
    
    
      REFRESH: gt_fcat.
    
    
    
      REFRESH: lt_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'VBPA'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = lt_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.
    
      LOOP AT lt_fcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'KUNNR'  OR
               'VBELN'.
            ls_fcat-key        = abap_true.
            ls_fcat-fix_column = abap_true.
    
          WHEN OTHERS.
            ls_fcat-key        = abap_false.
            ls_fcat-fix_column = abap_false.
        ENDCASE.
    
        APPEND ls_fcat TO gt_fcat.
      ENDLOOP.
    
    
    
    ENDFORM.                    " BUILD_FIELDCATALOG
    
    
    *&---------------------------------------------------------------------*
    *&      Form  SET_LAYOUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM set_layout .
    
      CLEAR: gs_layout.
    
      gs_layout-cwidth_opt = abap_true.
      gs_layout-zebra      = abap_true.
    
    **  gs_layout-stylefname = 'CELLTAB'.
    
    ENDFORM.                    " SET_LAYOUT

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.