SAP ABAP中的动态选择选项

时间:2017-04-24 10:33:21

标签: sap abap

我正在寻找一个选择屏幕,我必须在其中输入表格名称,然后根据选择的表格,我必须要求一些参数。
我尝试使用GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; ,但它无济于事,因为我需要使用select选项而不仅仅是value。

1 个答案:

答案 0 :(得分:1)

对于动态选择选项,您可以使用自由选择。写了一个示例程序来演示用法。您可以查看FM的文档和FM的参数,以获得更多自定义行为。

TYPE-POOLS: rsds.

DATA: ls_field  TYPE rsdsfields,
      lt_field  TYPE STANDARD TABLE OF rsdsfields,
      l_selid   TYPE dynselid,
      l_repid   TYPE sy-repid,
      ls_pfkey  TYPE rsdspfkey,
      lt_trange TYPE rsds_trange.

START-OF-SELECTION.

  ls_field-tablename = 'T001'.
  ls_field-fieldname = 'BUKRS'.
  ls_field-type = 'S'.
  APPEND ls_field TO lt_field.

  CALL FUNCTION 'FREE_SELECTIONS_INIT'
    EXPORTING
      kind         = 'F'
    IMPORTING
      selection_id = l_selid
    TABLES
      fields_tab   = lt_field[].

  ls_pfkey-program = sy-repid.

  CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
    EXPORTING
      selection_id    = l_selid
      title           = 'Select Company'
      as_window       = 'X'
      pfkey           = ls_pfkey
      tree_visible    = ''
    IMPORTING
      field_ranges    = lt_trange
    TABLES
      fields_tab      = lt_field[]
    EXCEPTIONS
      internal_error  = 1
      no_action       = 2
      selid_not_found = 3
      illegal_status  = 4
      OTHERS          = 5.

用户选择可在lt_trange

中找到