ALV 用对象的方法

*&---------------------------------------------------------------------*
*& Report  Z_I00106_01_ALV
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  Z_I00106_01_ALV.
types: begin of makt_type,
        MATNR    like mara-MATNR,
        mbrsh    like mara-mbrsh,
        mtart    like mara-mtart,
        werks    like marc-werks,
        vtweg   like  mvke-vtweg,
        icon_name(30),
       end of makt_type.
data: wa_makt type makt_type.
data: itab_makt type standard table of makt_type.
data: ok_code like sy-ucomm,
      save_ok_code like sy-ucomm.

* Fieldcatalog
data:  gt_fieldcat type lvc_t_fcat,
       wa_fieldcat like line of gt_fieldcat.
* Field position
data:  pos_free  type i value 01,
       pos_free2 type i value 02,
       pos_free3 type i value 03,
       pos_free4 type i value 04,
       pos_free5 type i value 05,
       pos_icon  type i value 11,

* Save variants
       gs_variant type disvariant,
       x_save.

* Layout
data: gs_layout type lvc_s_layo.

* CONTROLS
data: g_custom_container type ref to cl_gui_custom_container,
      alv_grid type ref to cl_gui_alv_grid.
* Local class
class lcl_ils definition.
  public section.
    methods on_dblclick for event double_click of cl_gui_alv_grid
     importing e_row e_column.
endclass.

* Double Click
data: alv_dblclick type ref to lcl_ils.

 

************************************************************************
* Programlogic                                                         *
************************************************************************
start-of-selection.
select a~matnr a~mbrsh a~mtart c~werks v~vtweg into table
itab_makt from mara as a inner join marc as c on a~matnr = c~matnr inner
join mvke as v on c~matnr = v~matnr.
SORT ITAB_MAKT BY MATNR WERKS.
  call screen 100.

 

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
  set pf-status 'ZS100'.
  set titlebar 'ZT100'.

endmodule.                             " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  EXIT  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module exit input.
  leave program.
endmodule.                             " EXIT  INPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.
  move ok_code to save_ok_code.
  clear ok_code.
  case save_ok_code.
    when 'BACK'.
      call method g_custom_container->free.
      leave to screen 0.
    when 'EXIT'.
      call method g_custom_container->free.
      leave to screen 0..
  endcase.

endmodule.                             " USER_COMMAND_0100  INPUT

*&---------------------------------------------------------------------*
*&      Module  CREATE_OBJECTS  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module create_objects output.

  if g_custom_container is initial.
    create object g_custom_container
        exporting container_name = 'MY_CONTROL_AREA'.

    create object alv_grid
        exporting i_parent = g_custom_container.
  endif.

endmodule.                             " CREATE_OBJECTS  OUTPUT
*&---------------------------------------------------------------------
*
*&      Module  TRANSFER_DATA  OUTPUT
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
module transfer_data output.

  call method alv_grid->set_table_for_first_display
   exporting   i_structure_name = 'makt_type'
               is_layout        =  gs_layout

   changing    it_outtab        =  itab_makt
               it_fieldcatalog  =  gt_fieldcat.

endmodule.                             " TRANSFER_DATA  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  field_catalog  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE field_catalog OUTPUT.
* Attributes of the additional fields, which is not included
*                   in the DIC sructure SFLIGHT

  clear wa_fieldcat.
* Name and types
  wa_fieldcat-fieldname = 'MATNR'.
  wa_fieldcat-ref_table = 'mara'.
  wa_fieldcat-ref_field = 'MATNR'.
* Texts and position
  wa_fieldcat-coltext   = text-001.
  wa_fieldcat-seltext   = text-001.
  wa_fieldcat-col_pos   = pos_free.
  append wa_fieldcat to gt_fieldcat.
  clear wa_fieldcat.
* Name and types
  wa_fieldcat-fieldname = 'MBRSH'.
  wa_fieldcat-ref_table = 'MARA'.
  wa_fieldcat-ref_field = 'mbrsh'.
* Texts and position
  wa_fieldcat-coltext   = text-002.
  wa_fieldcat-seltext   = text-002.
  wa_fieldcat-col_pos   = pos_free4.
  append wa_fieldcat to gt_fieldcat.
    clear wa_fieldcat.
* Name and types
  wa_fieldcat-fieldname = 'MTART'.
  wa_fieldcat-ref_table = 'MARA'.
  wa_fieldcat-ref_field = 'mtart'.
* Texts and position
  wa_fieldcat-coltext   = text-003.
  wa_fieldcat-seltext   = text-003.
  wa_fieldcat-col_pos   = pos_free3.
  append wa_fieldcat to gt_fieldcat.
      clear wa_fieldcat.
* Name and types
  wa_fieldcat-fieldname = 'WERKS'.
  wa_fieldcat-ref_table = 'MARC'.
  wa_fieldcat-ref_field = 'WERKS'.
* Texts and position
  wa_fieldcat-coltext   = text-004.
  wa_fieldcat-seltext   = text-004.
  wa_fieldcat-col_pos   = pos_free2.
  append wa_fieldcat to gt_fieldcat.
        clear wa_fieldcat.
* Name and types
  wa_fieldcat-fieldname = 'VTWEG'.
  wa_fieldcat-ref_table = 'MVKE'.
  wa_fieldcat-ref_field = 'VTWEG'.
* Texts and position
  wa_fieldcat-coltext   = text-005.
  wa_fieldcat-seltext   = text-005.
  wa_fieldcat-col_pos   = pos_free5.
  append wa_fieldcat to gt_fieldcat.
ENDMODULE.                 " field_catalog  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  layout  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE layout OUTPUT.
  gs_layout-grid_title = 'MATERIAL FOR SD'.
  gs_layout-detailtitl = 'Detail Title FOR SAP'.
  gs_layout-zebra = 'X'.

ENDMODULE.                 " layout  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  variant  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE variant OUTPUT.
* At least the report name has to be filled
  gs_variant-report = sy-repid.

*Determine saving options.
  x_save = 'A'.   "The user may save ALL types of variants

ENDMODULE.                 " variant  OUTPUT
*---------------------------------------------------------------------*
*       CLASS lcl_ils IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class lcl_ils implementation.
  method on_dblclick.
** valid line check
*    if e_row-rowtype = space and not e_row-index is initial.
*      read table itab_makt index e_row-index into wa_outtab.
*      call screen 101.
*    else.
*      message i031(bc405).
*    endif.
  endmethod.
endclass. 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值