0

我有一个 Z 表,它现在有一定数量的记录,比如 15 条记录。使用这 15 条记录并基于 2 个字段说组和位置,我必须在选择屏幕中动态创建 15 个复选框。如果将来 Z 表记录更新为 25 或 30 条记录。我需要动态选择屏幕中的 25-30 个复选框,而无需更改代码。请帮助解决这个问题...

4

2 回答 2

1

这是一个建议。除了从表格行生成复选框之外,您还可以轻松地使用表格中的值填充下拉菜单或更好的 ALV 网格,然后用户可以依次选择这些值。以编程方式评估用户选择将很容易。此外,随着桌子的进一步增长,您不必担心不同的 dynpro 尺寸。

于 2015-04-01T11:51:28.263 回答
0

这是一个在选择屏幕上具有 10 个动态复选框上限的解决方案,其中包含动态描述和值分配。

REPORT ztest_check_boxes.

DATA: g_num_check_boxes TYPE i,
      g_num_cb_shown    TYPE i,
      g_first_time      TYPE abap_bool VALUE abap_true.

FIELD-SYMBOLS: <cb>   TYPE flag,
               <text> TYPE any.

PARAMETERS: px_01 AS CHECKBOX MODIF ID cb,
            px_02 AS CHECKBOX MODIF ID cb,
            px_03 AS CHECKBOX MODIF ID cb,
            px_04 AS CHECKBOX MODIF ID cb,
            px_05 AS CHECKBOX MODIF ID cb,
            px_06 AS CHECKBOX MODIF ID cb,
            px_07 AS CHECKBOX MODIF ID cb,
            px_08 AS CHECKBOX MODIF ID cb,
            px_09 AS CHECKBOX MODIF ID cb,
            px_10 AS CHECKBOX MODIF ID cb.

INITIALIZATION.

  " Determine the number of checkboxes to show,
  " for simplicity I just hard coded this
  g_num_check_boxes = 3.


AT SELECTION-SCREEN OUTPUT.

  g_num_cb_shown = 0.

  LOOP AT SCREEN.

    IF screen-group1 EQ 'CB'.
      " This will trigger on the check box
      " as well as their descriptions

      IF g_num_cb_shown LT g_num_check_boxes.
        " Need to display this check box
        CASE screen-group3.
          WHEN 'PAR'.
            " This is the check box
            " you can set the value here dynamically.
            " Should only be done once
            IF g_first_time EQ abap_true.
              ASSIGN (screen-name) TO <cb>.
              IF ( g_num_cb_shown MOD 2 ) EQ 0.
                <cb> = 'X'.
              ENDIF.
            ENDIF.

          WHEN 'TXT'.
            " This is the text, you could set this with
            " data from your database table
            ASSIGN (screen-name) TO <text>.
            <text> = `Checkbox ` && g_num_cb_shown.

            " TXT comes after PAR, so we should do this here
            ADD 1 TO g_num_cb_shown.

        ENDCASE.

      ELSE.
        " Need to hide this check box
        screen-active = '0'.
        MODIFY SCREEN.

      ENDIF. " Display?

    ENDIF. " Check box?

  ENDLOOP. " SCREEN

  g_first_time = abap_false.

START-OF-SELECTION.

  ...
于 2015-04-01T14:27:31.997 回答