Membuat ALV Pop Up untuk display table pada selection screen


REPORT ytest NO STANDARD PAGE HEADING.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
SELECTION-SCREEN COMMENT 3(30) text-001.
SELECTION-SCREEN PUSHBUTTON 35(20) oke1 USER-COMMAND oke1 MODIF ID aaa.
SELECTION-SCREEN END OF LINE.

DATA: BEGIN OF t_alv OCCURS 0,
      matnr LIKE makt-matnr,
      maktx LIKE makt-maktx,
      END OF t_alv.

*data declarations for ALV
DATA: s_fieldcat      TYPE slis_fieldcat_alv,
      t_fieldcat      TYPE slis_t_fieldcat_alv,
      s_layout        TYPE slis_layout_alv.

INITIALIZATION.
  MOVE: 'OK' TO oke1.

AT SELECTION-SCREEN.
  CASE sy-ucomm.
    WHEN 'OKE1'.
      SELECT matnr maktx FROM makt INTO TABLE t_alv.

*      alv layout
      s_layout-zebra = 'X'.
      s_layout-colwidth_optimize = 'X'.

*      alv field catalog
      CLEAR s_fieldcat.
      s_fieldcat-row_pos   = '1'.
      s_fieldcat-col_pos   = '1'.
      s_fieldcat-fieldname = 'MATNR'.
      s_fieldcat-tabname   = 'T_ALV'.
      s_fieldcat-seltext_m = 'Material Number'.
      s_fieldcat-outputlen = 20.
      APPEND s_fieldcat TO t_fieldcat.

      CLEAR s_fieldcat.
      s_fieldcat-row_pos   = '1'.
      s_fieldcat-col_pos   = '2'.
      s_fieldcat-fieldname = 'MAKTX'.
      s_fieldcat-tabname   = 'T_ALV'.
      s_fieldcat-seltext_m = 'Material Desc'.
      s_fieldcat-outputlen = 50.
      APPEND s_fieldcat TO t_fieldcat.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program    = sy-repid
          i_grid_title          = 'Display Table'
          is_layout             = s_layout
          it_fieldcat           = t_fieldcat
          i_screen_start_column = 50
          i_screen_start_line   = 1
          i_screen_end_column   = 90
          i_screen_end_line     = 7
        TABLES
          t_outtab              = t_alv
        EXCEPTIONS
          program_error         = 1
          OTHERS                = 2.
      IF sy-subrc  0.
      ENDIF.
  ENDCASE.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s