Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7202702
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2008-02-22 11:29:28

 
 
alicice  发表时间:2008-02-22 09:00:54    

老白,请问如何在屏幕中的tablecontrl 中实现按回车自动光标跳到下一行,麻烦给个例子!

Blog作者的回复:
参考程序:
DEMO_DYNPRO_TABCONT_LOOP

 
 
 
复制一个程序,然后修改。
注意红色字体的部分:
REPORT demo_dynpro_tabcont_loop.
CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
DATA: ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.
DATA: itab TYPE TABLE OF demo_conn,
      fill TYPE i.
TABLES demo_conn.
DATA: lines TYPE i,
      limit TYPE i.
DATA:l_linno TYPE i.
SELECT * FROM spfli INTO TABLE itab.
CALL SCREEN 100.
*---------------------------------------------------------------------*
*       MODULE status_0100 OUTPUT                                     *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
  DESCRIBE TABLE itab LINES fill.
  flights-lines = fill.
  SET CURSOR FIELD 'DEMO_CONN-CITYFROM' LINE l_linno .
ENDMODULE.
*---------------------------------------------------------------------*
*       MODULE fill_table_control OUTPUT                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
MODULE fill_table_control OUTPUT.
  READ TABLE itab INTO demo_conn INDEX flights-current_line.
ENDMODULE.
*---------------------------------------------------------------------*
*       MODULE cancel INPUT                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.
*---------------------------------------------------------------------*
*       MODULE read_table_control INPUT                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
MODULE read_table_control INPUT.
  lines = sy-loopc.
  MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.
*---------------------------------------------------------------------*
*       MODULE user_command_0100 INPUT                                *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'NEXT_LINE'.
      flights-top_line = flights-top_line + 1.
      limit = fill - lines + 1.
      IF flights-top_line > limit.
        flights-top_line = limit.
      ENDIF.
    WHEN 'PREV_LINE'.
      flights-top_line = flights-top_line - 1.
      IF flights-top_line < 0.
        flights-top_line = 0.
      ENDIF.
    WHEN 'NEXT_PAGE'.
      flights-top_line = flights-top_line + lines.
      limit = fill - lines + 1.
      IF flights-top_line > limit.
        flights-top_line = limit.
      ENDIF.
    WHEN 'PREV_PAGE'.
      flights-top_line = flights-top_line - lines.
      IF flights-top_line < 0.
        flights-top_line = 0.
      ENDIF.
    WHEN 'LAST_PAGE'.
      flights-top_line =  fill - lines + 1.
    WHEN 'FIRST_PAGE'.
      flights-top_line = 0.
    WHEN ''.
      GET CURSOR LINE l_linno .
      l_linno = l_linno + 1.

  ENDCASE.
ENDMODULE.
 
 
2008年3月6日添加TableControl的ListBox方法:

 

REPORT zdemo_dynpro_tabcont_loop.
TYPE-POOLS vrm.
CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
DATA: ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.
DATA: itab TYPE TABLE OF demo_conn,
      fill TYPE i.
TABLES demo_conn.
DATA: lines TYPE i,
      limit TYPE i.
DATA: l_field(20) ,
      l_linno TYPE i.
DATA: vid  TYPE vrm_id,
      vlist TYPE vrm_values,
      value LIKE LINE OF vlist.
SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.
CALL SCREEN 100.
*----------------------------------------------------------------------*
*  MODULE status_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
  DESCRIBE TABLE itab LINES fill.
  flights-lines = fill.
  IF L_FIELD = 'DEMO_CONN-CITYFROM'.
    SET CURSOR FIELD 'DEMO_CONN-CITYFROM' LINE l_linno .
  ELSE.
    SET CURSOR FIELD 'DEMO_CONN-CITYTO' LINE l_linno .
  ENDIF.
ENDMODULE.                    "status_0100 OUTPUT
*----------------------------------------------------------------------*
*  MODULE fill_table_control OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE fill_table_control OUTPUT.
  READ TABLE itab INTO demo_conn INDEX flights-current_line.
ENDMODULE.                    "fill_table_control OUTPUT
*----------------------------------------------------------------------*
*  MODULE cancel INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.                    "cancel INPUT
*----------------------------------------------------------------------*
*  MODULE read_table_control INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE read_table_control INPUT.
  lines = sy-loopc.
  MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.                    "read_table_control INPUT
*----------------------------------------------------------------------*
*  MODULE user_command_0100 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'NEXT_LINE'.
      flights-top_line = flights-top_line + 1.
      limit = fill - lines + 1.
      IF flights-top_line > limit.
        flights-top_line = limit.
      ENDIF.
    WHEN 'PREV_LINE'.
      flights-top_line = flights-top_line - 1.
      IF flights-top_line < 0.
        flights-top_line = 0.
      ENDIF.
    WHEN 'NEXT_PAGE'.
      flights-top_line = flights-top_line + lines.
      limit = fill - lines + 1.
      IF flights-top_line > limit.
        flights-top_line = limit.
      ENDIF.
    WHEN 'PREV_PAGE'.
      flights-top_line = flights-top_line - lines.
      IF flights-top_line < 0.
        flights-top_line = 0.
      ENDIF.
    WHEN 'LAST_PAGE'.
      flights-top_line =  fill - lines + 1.
    WHEN 'FIRST_PAGE'.
      flights-top_line = 0.
    WHEN ''.
      GET CURSOR FIELD l_field LINE l_linno .
      IF l_field = 'DEMO_CONN-CITYFROM'.
        l_linno = l_linno + 1.
      ELSE.
      ENDIF.
  ENDCASE.
ENDMODULE.                    "user_command_0100 INPUT
*&---------------------------------------------------------------------*
*&      Module  INIT_LISTBOX  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE init_listbox OUTPUT.
  CLEAR vid.
  CLEAR value.
  CLEAR vlist.
  vid = 'DEMO_CONN-CITYTO'.
  value-key = 'Key1'.
  value-text = 'Text1'.
  APPEND value TO vlist.
  value-key = 'Key2'.
  value-text = 'Text2'.
  APPEND value TO vlist.
  CLEAR value.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = vid
      values = vlist.
ENDMODULE.                 " INIT_LISTBOX  OUTPUT
 
 
*******
PROCESS BEFORE OUTPUT.
  MODULE status_0100.
  LOOP WITH CONTROL flights.
    MODULE fill_table_control.
    MODULE init_listbox.
  ENDLOOP.
PROCESS AFTER INPUT.
  MODULE cancel AT EXIT-COMMAND.
  LOOP WITH CONTROL flights.
    MODULE read_table_control.
  ENDLOOP.
  MODULE user_command_0100.
 
 
 
2008年4月19日添加Docking和Split的使用方法:

REPORT zdemo_dynpro_tabcont_loop.

TYPE-POOLS vrm.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

DATA: ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.
DATA: c_docking TYPE REF TO cl_gui_docking_container ,
      c_spliter TYPE REF TO cl_gui_splitter_container ,
      c_grid1   TYPE REF TO cl_gui_alv_grid,
      c_editor  TYPE REF TO cl_gui_textedit.
DATA: v_repid   TYPE syrepid.
DATA: g_container1 TYPE REF TO cl_gui_container,
      g_container2 TYPE REF TO cl_gui_container.

DATA: itab TYPE TABLE OF demo_conn,
      fill TYPE i.
TABLES demo_conn.

DATA: lines TYPE i,
      limit TYPE i.
DATA: l_field(20) ,
      l_linno TYPE i.

DATA: vid  TYPE vrm_id,
      vlist TYPE vrm_values,
      value LIKE LINE OF vlist.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

CALL SCREEN 100.

*----------------------------------------------------------------------*
*  MODULE status_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
  DESCRIBE TABLE itab LINES fill.
  flights-lines = fill.
  IF l_field = 'DEMO_CONN-CITYFROM'.
    SET CURSOR FIELD 'DEMO_CONN-CITYFROM' LINE l_linno .
  ELSE.
    SET CURSOR FIELD 'DEMO_CONN-CITYTO' LINE l_linno .
  ENDIF.
  IF c_docking IS INITIAL .
    CREATE OBJECT c_docking
      EXPORTING
          repid = v_repid
          dynnr = sy-dynnr
          side = cl_gui_docking_container=>dock_at_left
          extension = '235'
      EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5.

    CREATE OBJECT c_spliter
      EXPORTING
          parent                = c_docking
          rows                  = 2
          columns               = 1.
    CALL METHOD c_spliter->get_container
      EXPORTING
        row       = 1
        column    = 1
      RECEIVING
        container = g_container1.
    CALL METHOD c_spliter->get_container
      EXPORTING
        row       = 2
        column    = 1
      RECEIVING
        container = g_container2.
    CALL METHOD c_spliter->set_visible
      EXPORTING
        visible = 'X'.
  ENDIF .
  IF c_editor IS INITIAL.
    CREATE OBJECT c_editor
      EXPORTING
          parent            = g_container2
          wordwrap_mode     = cl_gui_textedit=>wordwrap_at_fixed_position
          wordwrap_position = 72
          max_number_chars  = 100000.
  ENDIF .

  IF c_grid1 IS INITIAL.
    CREATE OBJECT c_grid1
            EXPORTING i_parent = g_container1.
    CALL METHOD c_grid1->set_visible
      EXPORTING
        visible = 'X'.
  ENDIF.
  CALL METHOD c_grid1->set_table_for_first_display
    EXPORTING
      i_structure_name              = 'DEMO_CONN'
    CHANGING
      it_outtab                     = itab[]
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
ENDMODULE.                    "status_0100 OUTPUT

*----------------------------------------------------------------------*
*  MODULE fill_table_control OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE fill_table_control OUTPUT.
  READ TABLE itab INTO demo_conn INDEX flights-current_line.
ENDMODULE.                    "fill_table_control OUTPUT

*----------------------------------------------------------------------*
*  MODULE cancel INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.                    "cancel INPUT

*----------------------------------------------------------------------*
*  MODULE read_table_control INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE read_table_control INPUT.
  lines = sy-loopc.
  MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.                    "read_table_control INPUT

*----------------------------------------------------------------------*
*  MODULE user_command_0100 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'NEXT_LINE'.
      flights-top_line = flights-top_line + 1.
      limit = fill - lines + 1.
      IF flights-top_line > limit.
        flights-top_line = limit.
      ENDIF.
    WHEN 'PREV_LINE'.
      flights-top_line = flights-top_line - 1.
      IF flights-top_line < 0.
        flights-top_line = 0.
      ENDIF.
    WHEN 'NEXT_PAGE'.
      flights-top_line = flights-top_line + lines.
      limit = fill - lines + 1.
      IF flights-top_line > limit.
        flights-top_line = limit.
      ENDIF.
    WHEN 'PREV_PAGE'.
      flights-top_line = flights-top_line - lines.
      IF flights-top_line < 0.
        flights-top_line = 0.
      ENDIF.
    WHEN 'LAST_PAGE'.
      flights-top_line =  fill - lines + 1.
    WHEN 'FIRST_PAGE'.
      flights-top_line = 0.
    WHEN ''.
      GET CURSOR FIELD l_field LINE l_linno .
      IF l_field = 'DEMO_CONN-CITYFROM'.
        l_linno = l_linno + 1.
      ELSE.
      ENDIF.
  ENDCASE.
ENDMODULE.                    "user_command_0100 INPUT
*&---------------------------------------------------------------------*
*&      Module  INIT_LISTBOX  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE init_listbox OUTPUT.
  CLEAR vid.
  CLEAR value.
  CLEAR vlist.
  vid = 'DEMO_CONN-CITYTO'.
  value-key = 'Key1'.
  value-text = 'Text1'.
  APPEND value TO vlist.
  value-key = 'Key2'.
  value-text = 'Text2'.
  APPEND value TO vlist.
  CLEAR value.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = vid
      values = vlist.
ENDMODULE.                 " INIT_LISTBOX  OUTPUT

阅读(8408) | 评论(11) | 转发(0) |
0

上一篇:ABAP中的宏

下一篇:关于XML的回答

给主人留下些什么吧!~~

chinaunix网友2009-07-29 11:55:34

demo_conn是逻辑数据库吗?怎么我的IDES上不能运行你上面的例子也?

chinaunix网友2009-07-01 22:10:08

我感觉如果不走PBO和PAI没有什么好办法,不知道白老师怎么看

chinaunix网友2009-07-01 09:16:01

您好,我想将内表中指定条件的行在tableview上显示和隐藏。 不想重新读取数据到内表中,不知有什么好的办法不。

chinaunix网友2008-05-16 17:11:32

ViewletCam

tantanfanfan2008-05-16 15:04:09

急!!!想知道你是用哪个软件录制的ABAP屏幕。