ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 多个alv容器

多个alv容器

原创 Linux操作系统 作者:elliott_love 时间:2012-01-12 20:37:25 0 删除 编辑
要先在屏幕上定义好5个容器,有双击事件大体代码如下:
REPORT
  YY_TEST2.

**** Data declarations
DATA:
dtab TYPE REF TO data,
newstr2 TYPE REF TO cl_abap_typedescr,
tab_type1 TYPE REF TO cl_abap_tabledescr,
lref_ditab TYPE REF TO data,
lref_new_line TYPE REF TO data.
**** Field-Symbols declarations
FIELD-SYMBOLS:
 TYPE ANY TABLE,
 TYPE ANY TABLE,
 TYPE ANY TABLE,
 TYPE ANY TABLE,
 TYPE ANY TABLE,
 TYPE ANY.
**** Field Catalog declarations
DATA:
ls_fcat1 TYPE lvc_s_fcat,
lt_fcat1 TYPE lvc_t_fcat,
ls_fcat2 TYPE lvc_s_fcat,
lt_fcat2 TYPE lvc_t_fcat,
ls_fcat3 TYPE lvc_s_fcat,
lt_fcat3 TYPE lvc_t_fcat,
ls_fcat4 TYPE lvc_s_fcat,
lt_fcat4 TYPE lvc_t_fcat,
ls_fcat5 TYPE lvc_s_fcat,
lt_fcat5 TYPE lvc_t_fcat.
DATA: ls_layo TYPE lvc_s_layo.
**** Data declarations for ALV Display *
**** Object variable for ALV grid
DATA:
obj_my_alv_grid1 TYPE REF TO cl_gui_alv_grid,
obj_my_alv_grid2 TYPE REF TO cl_gui_alv_grid,
obj_my_alv_grid3 TYPE REF TO cl_gui_alv_grid,
obj_my_alv_grid4 TYPE REF TO cl_gui_alv_grid,
obj_my_alv_grid5 TYPE REF TO cl_gui_alv_grid.
**** Object variable for ALV Container
DATA:
obj_r_container1 TYPE REF TO cl_gui_custom_container,
obj_r_container2 TYPE REF TO cl_gui_custom_container,
obj_r_container3 TYPE REF TO cl_gui_custom_container,
obj_r_container4 TYPE REF TO cl_gui_custom_container,
obj_r_container5 TYPE REF TO cl_gui_custom_container.
*---------------------------------------------------------------
*       CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------
CLASS lcl_event_receiver DEFINITION."定义双击事件
  PUBLIC SECTION.
    METHODS catch_doubleclick1
      FOR EVENT double_click OF cl_gui_alv_grid
      IMPORTING e_row
                e_column
                es_row_no .
    METHODS catch_doubleclick2
      FOR EVENT double_click OF cl_gui_alv_grid
      IMPORTING e_row
                e_column
                es_row_no .
    METHODS catch_doubleclick4
      FOR EVENT double_click OF cl_gui_alv_grid
      IMPORTING e_row
                e_column
                es_row_no .
ENDCLASS.                    "lcl_event_receiver DEFINITION
*---------------------------------------------------------------
*       CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------
CLASS lcl_event_receiver IMPLEMENTATION."事件的执行调用相应的处理过程
  METHOD catch_doubleclick1."双击原料alv容器
    PERFORM atdoubleclick1 USING e_row
                                e_column
                                es_row_no.
  ENDMETHOD.
  METHOD catch_doubleclick2."双击返工品alv容器
    PERFORM atdoubleclick2 USING e_row
                                e_column
                                es_row_no.
  ENDMETHOD.
  METHOD catch_doubleclick4."双击余料alv容器
    PERFORM atdoubleclick4 USING e_row
                                e_column
                                es_row_no.
  ENDMETHOD.
ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
DATA: event_receiver TYPE REF TO lcl_event_receiver.
START-OF-SELECTION.
* Create Field Catalog
PERFORM create_field_catalog.
* Create Dynamic Table
PERFORM create_dynamic_table1.
PERFORM create_dynamic_table2.
PERFORM create_dynamic_table3.
PERFORM create_dynamic_table4.
PERFORM create_dynamic_table5.
* Fill the dynamic tables with data
PERFORM fill_dynamic_table.
* Call the screen no.100
PERFORM call_screen.

*&---------------------------------------------------------------------*
*& Form CREATE_FIELD_CATALOG
*&---------------------------------------------------------------------*
FORM create_field_catalog .
* Append fields to field catalog table
"body1
REFRESH lt_fcat1.
ls_fcat1-fieldname = ''.
ls_fcat1-ref_field = ''.
ls_fcat1-OUTPUTLEN = ''.
ls_fcat1-ref_table = ''.
APPEND ls_fcat1 TO lt_fcat1.
CLEAR ls_fcat1.
...

"body2
REFRESH lt_fcat2.
ls_fcat2-fieldname = ''.
ls_fcat2-ref_field = ''.
ls_fcat2-OUTPUTLEN = ''.
ls_fcat2-ref_table = ''.
APPEND ls_fcat2 TO lt_fcat2.
CLEAR ls_fcat2.
...


"BODY3
REFRESH lt_fcat3.
ls_fcat3-fieldname = ''.
ls_fcat3-ref_field = ''.
ls_fcat3-OUTPUTLEN = ''.
ls_fcat3-ref_table = ''.
APPEND ls_fcat3 TO lt_fcat3.
CLEAR ls_fcat3.
...
"BODY4
REFRESH lt_fcat4.
ls_fcat4-fieldname = ''.
ls_fcat4-ref_field = ''.
ls_fcat4-OUTPUTLEN = ''.
ls_fcat4-ref_table = ''.
APPEND ls_fcat4 TO lt_fcat4.
CLEAR ls_fcat4.
...

"BODY5
REFRESH lt_fcat5.
ls_fcat5-fieldname = ''.
ls_fcat5-ref_field = ''.
ls_fcat5-OUTPUTLEN = ''.
ls_fcat5-ref_table = ''.
APPEND ls_fcat5 TO lt_fcat5.
CLEAR ls_fcat5.
...
ENDFORM" CREATE_FIELD_CATALOG
*&---------------------------------------------------------------------*
*& Form CREATE_DYNAMIC_TABLE
*&---------------------------------------------------------------------*
FORM create_dynamic_table1 .
** Create dynamic table1
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fcat1
IMPORTING
ep_table = lref_ditab
EXCEPTIONS
generate_subpool_dir_full = 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.
** Assign the dynamic table reference to a field-symbol
ASSIGN lref_ditab->* TO .
** Create a structure similar to the dynamic table created
CREATE DATA lref_new_line LIKE LINE OF .
ASSIGN lref_new_line->* TO .
ENDFORM" CREATE_DYNAMIC_TABLE
*&---------------------------------------------------------------------*
*& Form CREATE_DYNAMIC_TABLE
*&---------------------------------------------------------------------*
FORM create_dynamic_table2 .
** Create dynamic table2
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fcat2
IMPORTING
ep_table = lref_ditab
EXCEPTIONS
generate_subpool_dir_full = 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.
** Assign the dynamic table reference to a field-symbol
ASSIGN lref_ditab->* TO .
** Create a structure similar to the dynamic table created
CREATE DATA lref_new_line LIKE LINE OF .
ASSIGN lref_new_line->* TO .
ENDFORM" CREATE_DYNAMIC_TABLE
FORM create_dynamic_table3 .
** Create dynamic table3
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fcat3
IMPORTING
ep_table = lref_ditab
EXCEPTIONS
generate_subpool_dir_full = 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.
** Assign the dynamic table reference to a field-symbol
ASSIGN lref_ditab->* TO .
** Create a structure similar to the dynamic table created
CREATE DATA lref_new_line LIKE LINE OF .
ASSIGN lref_new_line->* TO .
ENDFORM" CREATE_DYNAMIC_TABLE
FORM create_dynamic_table4 .
** Create dynamic table4
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fcat4
IMPORTING
ep_table = lref_ditab
EXCEPTIONS
generate_subpool_dir_full = 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.
** Assign the dynamic table reference to a field-symbol
ASSIGN lref_ditab->* TO .
** Create a structure similar to the dynamic table created
CREATE DATA lref_new_line LIKE LINE OF .
ASSIGN lref_new_line->* TO .
ENDFORM" CREATE_DYNAMIC_TABLE
FORM create_dynamic_table5 .
** Create dynamic table4
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fcat5
IMPORTING
ep_table = lref_ditab
EXCEPTIONS
generate_subpool_dir_full = 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.
** Assign the dynamic table reference to a field-symbol
ASSIGN lref_ditab->* TO .
** Create a structure similar to the dynamic table created
CREATE DATA lref_new_line LIKE LINE OF .
ASSIGN lref_new_line->* TO .
ENDFORM" CREATE_DYNAMIC_TABLE
*&---------------------------------------------------------------------*
*& Form FILL_DYNAMIC_TABLE
*&---------------------------------------------------------------------*
FORM fill_dynamic_table.
** Fill the dynamic table 
SELECT *
  FROM ZZTPP_BODY1 INTO TABLE 
 WHERE .
** Fill the dynamic table 
SELECT *
FROM ZZTPP_BODY2 INTO TABLE 
WHERE .
** Fill the dynamic table 
SELECT *
FROM ZZTPP_BODY3 INTO TABLE 
WHERE .
** Fill the dynamic table 
SELECT *
FROM ZZTPP_BODY4 INTO TABLE 
WHERE .
** Fill the dynamic table 
SELECT *
FROM ZZTPP_BODY5 INTO TABLE 
WHERE .
ENDFORM" FILL_DYNAMIC_TABLE
*&---------------------------------------------------------------------*
*& Form CALL_SCREEN
*&---------------------------------------------------------------------*
FORM call_screen .
CALL SCREEN 0010.
ENDFORM" CALL_SCREEN
*&---------------------------------------------------------------------*
*&      Module  STATUS_0010  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0010 OUTPUT.
  SET PF-STATUS '0010'.
  SET TITLEBAR 'TITLE0010'.
ls_layo-info_fname = 'ROWCOLOR'.
if obj_my_alv_grid1 is INITIAL.
* Object for container1
CREATE OBJECT obj_r_container1
EXPORTING
container_name = 'ALVCN1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
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.
* Object for Alv grid1
CREATE OBJECT obj_my_alv_grid1
EXPORTING
i_parent = obj_r_container1
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
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.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->catch_doubleclick1 FOR obj_my_alv_grid1."向ALV创建双击事件
* Calling method for displaying the data
CALL METHOD obj_my_alv_grid1->set_table_for_first_display
EXPORTING
is_layout = ls_layo
CHANGING
it_outtab = 
it_fieldcatalog = lt_fcat1
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
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.
ENDIF.
*&---------------------------------------------------------------------*
* ALV Display-2nd table
*----------------------------------------------------------------------*
* Object for conatainer2
if  obj_my_alv_grid2 is INITIAL.
CREATE OBJECT obj_r_container2
EXPORTING
container_name = 'ALVCN2'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
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.
* Object for Alv grid2
CREATE OBJECT obj_my_alv_grid2
EXPORTING
i_parent = obj_r_container2
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
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.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->catch_doubleclick2 FOR obj_my_alv_grid2."向ALV创建双击事件
* Calling method for displaying the data
CALL METHOD obj_my_alv_grid2->set_table_for_first_display
EXPORTING
is_layout = ls_layo
CHANGING
it_outtab = 
it_fieldcatalog = lt_fcat2
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
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.
ENDIF.
if obj_my_alv_grid3 is INITIAL.
* Object for container3
CREATE OBJECT obj_r_container3
EXPORTING
container_name = 'ALVCN3'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
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.
* Object for Alv grid3
CREATE OBJECT obj_my_alv_grid3
EXPORTING
i_parent = obj_r_container3
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
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.
* Calling method for displaying the data
CALL METHOD obj_my_alv_grid3->set_table_for_first_display
CHANGING
it_outtab = 
it_fieldcatalog = lt_fcat3
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
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.
ENDIF.
*&---------------------------------------------------------------------*
* ALV Display-2nd table
*----------------------------------------------------------------------*
* Object for conatainer4
if obj_my_alv_grid4 is INITIAL.
CREATE OBJECT obj_r_container4
EXPORTING
container_name = 'ALVCN4'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
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.
* Object for Alv grid4
CREATE OBJECT obj_my_alv_grid4
EXPORTING
i_parent = obj_r_container4
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
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.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->catch_doubleclick4 FOR obj_my_alv_grid4."向ALV创建双击事件
* Calling method for displaying the data
CALL METHOD obj_my_alv_grid4->set_table_for_first_display
EXPORTING
is_layout = ls_layo
CHANGING
it_outtab = 
it_fieldcatalog = lt_fcat4
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
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.
ENDIF.
*&---------------------------------------------------------------------*
* ALV Display-2nd table
*----------------------------------------------------------------------*
* Object for conatainer5
if obj_my_alv_grid5 is INITIAL.
CREATE OBJECT obj_r_container5
EXPORTING
container_name = 'ALVCN5'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
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.
* Object for Alv grid4
CREATE OBJECT obj_my_alv_grid5
EXPORTING
i_parent = obj_r_container5
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
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.
* Calling method for displaying the data
CALL METHOD obj_my_alv_grid5->set_table_for_first_display
EXPORTING
is_layout = ls_layo
CHANGING
it_outtab = 
it_fieldcatalog = lt_fcat5
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
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.
ENDIF.
ENDMODULE.                 " STATUS_0010  OUTPUT



*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0010  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0010 INPUT.
  save_ok = ok_code.
  CLEAR:ok_code.
  CASE save_ok.
    WHEN ''.
...

  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0010  INPUT
*&---------------------------------------------------------------------*
*&      Module  EXIT  INPUT
*&---------------------------------------------------------------------*
*    退出界面
*----------------------------------------------------------------------*
MODULE exit INPUT.
  LEAVE TO SCREEN 0.
ENDMODULE.

......
*&--------------------------------------------------------------
*&      Form  atdoubleclick1
*&--------------------------------------------------------------
FORM atdoubleclick1 USING p_e_row
                           p_e_column
                            p_es_row_no.
DATA:  lw_dc_body1 TYPE zztpp_body1.
         REFRESH gt_body1.
         SELECT * INTO TABLE gt_body1
           FROM zztpp_body1
          WHERE .
         CLEAR lw_dc_body1.
         READ TABLE gt_body1 INTO lw_dc_body1 INDEX p_e_row.
         .......
ENDFORM" atdoubleclick1

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25465231/viewspace-714864/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 折叠屏幕
下一篇: 弹出确认窗口
请登录后发表评论 登录
全部评论

注册时间:2012-01-12

  • 博文量
    4
  • 访问量
    6106