二维码

简单的table control小实例

Twilight发表于 2014-03-30 20:56Twilight 最后回复于 2014-03-30 20:56 [复制链接] 3719 0

执行结果:
Table control.jpg


一、主程序代码:
  1. *&---------------------------------------------------------------------*
  2. *& Report  ZLXG_013
  3. *&
  4. *&---------------------------------------------------------------------*
  5. *&
  6. *&
  7. *&---------------------------------------------------------------------*

  8. REPORT  ZLXG_013.
  9. INCLUDE ZLXG_013_DEF.
  10. INCLUDE ZLXG_013_MAIN.
  11. INCLUDE ZLXG_013_100_PBO.
  12. INCLUDE ZLXG_013_100_PAI.
复制代码
INCLUDE ZLXG_013_DEF.
  1. *&---------------------------------------------------------------------*
  2. *&  Include           ZLXG_013_DEF
  3. *&---------------------------------------------------------------------*
  4. TABLES:sdyn_conn.
  5. CONTROLS mytable TYPE TABLEVIEW USING SCREEN '100'."这里定义的control属性和100屏幕里的属性是一样的
  6. "mytable是个Deep Structure,拥有很多属性,它实现了对表格控件的所有属性的封装。
复制代码
INCLUDE ZLXG_013_MAIN.
  1. *&---------------------------------------------------------------------*
  2. *&  Include           ZLXG_013_MAIN
  3. *&---------------------------------------------------------------------*
  4. CALL SCREEN 100.
复制代码
INCLUDE ZLXG_013_100_PBO.
  1. *----------------------------------------------------------------------*
  2. ***INCLUDE ZLXG_013_100_PBO .
  3. *----------------------------------------------------------------------*
  4. *&---------------------------------------------------------------------*
  5. *&      Module  STATUS_0100  OUTPUT
  6. *&---------------------------------------------------------------------*
  7. *       text
  8. *----------------------------------------------------------------------*
  9. MODULE status_0100 OUTPUT.
  10.   SET PF-STATUS 'STATUS_100'.
  11. *  SET TITLEBAR 'xxx'.

  12. ENDMODULE.                 " STATUS_0100  OUTPUT
  13. *&---------------------------------------------------------------------*
  14. *&      Module  GET_DATA  OUTPUT
  15. *&---------------------------------------------------------------------*
  16. *       text
  17. *----------------------------------------------------------------------*
  18. MODULE get_data OUTPUT.
  19.   IF loaded IS INITIAL.
  20.     SELECT *
  21.       FROM spfli
  22.       INTO CORRESPONDING FIELDS OF TABLE it_spfli.
  23.     loaded = 'X'.
  24.   ENDIF.
  25. ENDMODULE.                 " GET_DATA  OUTPUT
  26. *&---------------------------------------------------------------------*
  27. *&      Module  INPUT_DATA  OUTPUT
  28. *&---------------------------------------------------------------------*
  29. *       text
  30. *----------------------------------------------------------------------*
  31. MODULE input_data OUTPUT.
  32.   MOVE-CORRESPONDING wa_spfli TO sdyn_conn.
  33. ENDMODULE.                 " INPUT_DATA  OUTPUT
  34. *&---------------------------------------------------------------------*
  35. *&      Module  CLEAR_OK_CODE  OUTPUT
  36. *&---------------------------------------------------------------------*
  37. *       text
  38. *----------------------------------------------------------------------*
  39. MODULE clear_ok_code OUTPUT.
  40.   CLEAR ok_code.
  41. ENDMODULE.                 " CLEAR_OK_CODE  OUTPUT
复制代码
INCLUDE ZLXG_013_100_PAI.
  1. *----------------------------------------------------------------------*
  2. ***INCLUDE ZLXG_013_100_PAI .
  3. *----------------------------------------------------------------------*
  4. *&---------------------------------------------------------------------*
  5. *&      Module  USER_COMMAND_0100  INPUT
  6. *&---------------------------------------------------------------------*
  7. *       text
  8. *----------------------------------------------------------------------*
  9. MODULE user_command_0100 INPUT.
  10.   CASE ok_code.
  11.     WHEN 'EXIT'  OR 'BACK' OR 'CANCEL'.
  12.       LEAVE TO SCREEN 0.
  13.   ENDCASE.
  14. ENDMODULE.                 " USER_COMMAND_0100  INPUT
  15. *&---------------------------------------------------------------------*
  16. *&      Module  CHANGE_DATA  INPUT
  17. *&---------------------------------------------------------------------*
  18. *       text
  19. *----------------------------------------------------------------------*
  20. MODULE change_data INPUT.
  21.   MOVE-CORRESPONDING sdyn_conn TO wa_spfli.
  22.   MODIFY it_spfli FROM wa_spfli INDEX mytable-current_line.
  23. ENDMODULE.                 " CHANGE_DATA  INPUT
复制代码


二、screen 100
1.attribute->normal
2.element list->ok_code
Table control1.jpg
3.flow logic
  1. PROCESS BEFORE OUTPUT.
  2.   MODULE clear_ok_code.
  3.   MODULE status_0100.
  4.   MODULE get_data.
  5.   LOOP AT it_spfli INTO wa_spfli WITH CONTROL mytable.
  6.     MODULE input_data.
  7.   ENDLOOP.

  8. PROCESS AFTER INPUT.
  9.   LOOP AT it_spfli.   "LOOP AT IT_SPFLI INTO WA_SPFLI  XXXXXX
  10.     MODULE change_data.
  11.   ENDLOOP.
  12.   MODULE user_command_0100.
复制代码
回复

使用道具 举报

快速回帖

本版积分规则
您需要登录后才可以回帖 登录 | 注册有礼

快速回复 返回顶部 返回列表