LIST BOX 联动的实现

有两种方式实现联动:
1、 USER-COMMAND
2、AT SELECTION-SCREEN ON VALUE-REQUEST FOR listbox名称

例一:
REPORT  zlm_listbox_02.

*&---------------------------------------------------------------------*
*&宏定义,填充下拉框
*&---------------------------------------------------------------------*
DEFINE fill_list.
  value-key   &1                        "个就是变量下拉框的值
  value-text  &2                        "这个是text
  append value to &3.
END-OF-DEFINITION.

*&---------------------------------------------------------------------*
*&LIST-BOX 变量定义
*&---------------------------------------------------------------------*
TYPE-POOLSvrm                                               "存放combobox内容的type pool
DATAname       TYPE vrm_id                                  list box的名称
      list_ctry  TYPE vrm_values                              list box的值
      list_city  TYPE vrm_values                              list box的值
      value      LIKE LINE OF list_ctry                       list box的结构
*&---------------------------------------------------------------------*
*&屏幕定义
*&---------------------------------------------------------------------*
PARAMETERSp_ctry TYPE char10 AS LISTBOX VISIBLE LENGTH 15 USER-COMMAND zctry.
PARAMETERSp_city TYPE char10 AS LISTBOX VISIBLE LENGTH 15 USER-COMMAND zcity.


*&---------------------------------------------------------------------*
*&初始化
*&---------------------------------------------------------------------*
INITIALIZATION.
  PERFORM zform_fill_ctry.

*&---------------------------------------------------------------------*
*&根据所选国家,显示城市
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN.
  CASE sy-ucomm.
    WHEN 'ZCTRY'.
      PERFORM zform_fill_city.
    WHEN 'ZCITY'.
      MESSAGE p_city TYPE 'I'.
    WHEN OTHERS.
  ENDCASE.


*&---------------------------------------------------------------------*
*&      Form  zform_fill_city
*&---------------------------------------------------------------------*
      text
*----------------------------------------------------------------------*
FORM zform_fill_city.
  DATA:value LIKE LINE OF list_ctry                       list box的结构
  READ TABLE list_ctry INTO value  WITH KEY key p_ctry.

  REFRESH  list_city.

  IF value-key 'CH'.
    fill_list 'BJ' '北京' list_city.
    fill_list 'TJ' '天津' list_city.
  ENDIF.
  IF value-key 'EN'.
    fill_list 'LD' '伦敦' list_city.
  ENDIF.
  IF value-key 'US'.
    fill_list 'LSJ' '洛杉矶' list_city.
    fill_list 'HSD' '华盛顿' list_city.
  ENDIF.
  "调用函数显示listbox里面的值
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     'P_CITY'                                        PARAMETERS's Name
      values list_city.
ENDFORM                   "zform_fill_city

*&---------------------------------------------------------------------*
*&      Form  zform_fill_ctry
*&---------------------------------------------------------------------*
      text  填充国家
*----------------------------------------------------------------------*
FORM zform_fill_ctry.

  REFRESH  list_ctry.

  fill_list 'CH' '中国' list_ctry.
  fill_list 'EN' '英国' list_ctry.
  fill_list 'US' '美国' list_ctry.

  "调用函数显示listbox里面的值
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     'P_CTRY'                                       PARAMETERS's Name
      values list_ctry.
ENDFORM                   "zform_fill_ctry


例二:
变动很小
 INITIALIZATION.
   PERFORM zform_fill_ctry.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ctry.
  PERFORM zform_fill_city.

或者
AT SELECTION-SCREEN OUTPUT .
  PERFORM zform_fill_ctry.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ctry.
  PERFORM zform_fill_city.

或者直接

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ctry.
  PERFORM zform_fill_ctry.
  PERFORM zform_fill_city.


但是出现了个问题,
就是在我变动国家后,城市框还显示上传选择的城市的key值
LIST <wbr>BOX <wbr>联动的实现

一直没解决,哪位知道怎样解决,请留言,谢谢
posted @ 2014-01-22 09:19  胡来  阅读(99)  评论(0编辑  收藏  举报