Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

alv using cl_salv_table

former_member842213
Participant
0 Kudos

hi,

I need to create a alv using cl_salv* class, how could i make the outlength of a field

as 20

in reuse_alv:

wa_fcat-outputen = 20.

thanks a lot...........................

1 ACCEPTED SOLUTION

athavanraja
Active Contributor
0 Kudos
4 REPLIES 4

athavanraja
Active Contributor
0 Kudos

0 Kudos

Im not able to access the page.im getting page can not be displayed

uwe_schieferstein
Active Contributor
0 Kudos

Hello Santhiya

The following sample report <b>ZUS_SDN_CL_SALV_TABLE_COLUMN</b> shows how to modify the output length of columns. Additionally, the report demonstrates <i>event handling</i>.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_CL_SALV_TABLE_COLUMN
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZUS_SDN_CL_SALV_TABLE_COLUMN.

TYPE-POOLS: abap.


DATA:
  gt_knb1        TYPE STANDARD TABLE OF knb1.


DATA:
  go_table       TYPE REF TO cl_salv_table,
  go_events      TYPE REF TO cl_salv_events_table,
  go_columns     TYPE REF TO cl_salv_columns_table,
  go_column      TYPE REF TO cl_salv_column.


PARAMETERS:
  p_outlen       TYPE lvc_outlen  DEFAULT '20'.

*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler DEFINITION.

  PUBLIC SECTION.

    CLASS-METHODS:
      handle_double_click FOR EVENT
          if_salv_events_actions_table~double_click
          OF cl_salv_events_table
          IMPORTING
            row
            column.

ENDCLASS.                    "lcl_eventhandler DEFINITION

*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.

  METHOD handle_double_click.
*   define local data
    DATA:
      ls_knb1    TYPE knb1.


    READ TABLE gt_knb1 INTO ls_knb1 INDEX row.
    IF ( syst-subrc = 0 ).
      SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
      SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.

      CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
    ENDIF.

  ENDMETHOD.                    "handle_double_click

ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION


START-OF-SELECTION.

  SELECT        * FROM  knb1 INTO TABLE gt_knb1
         WHERE  bukrs  = '1000'.


* Create ALV grid instance
  TRY.
      CALL METHOD cl_salv_table=>factory
*    EXPORTING
*      LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
*      R_CONTAINER    =
*      CONTAINER_NAME =
        IMPORTING
          r_salv_table   = go_table
        CHANGING
          t_table        = gt_knb1.
    CATCH cx_salv_msg .
  ENDTRY.

* Create event instance
  go_events = go_table->get_event( ).

* Set event handler
  SET HANDLER:
    lcl_eventhandler=>handle_double_click FOR go_events.




  PERFORM adjust_column.

  go_table->display( ).

END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Form  ADJUST_COLUMN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM adjust_column .


  CHECK ( p_outlen > 0 ).  " In this case use default output length


* Get columns instance
  go_columns = go_table->get_columns( ).

* Get single column instance
  TRY.
      go_column  = go_columns->get_column( 'LOEVM' ). " delete flag
      go_column->set_output_length( p_outlen ).
    CATCH cx_root.
  ENDTRY.


ENDFORM.                    " ADJUST_COLUMN

Regards

Uwe