Search code examples
dynamicabapsap-selection-screens

Dynamically declaring parameters from table


Is it possible to dynamically create parameters from table entries?

For example like this:

SELECTION-SCREEN BEGIN OF BLOCK example WITH TITLE text-01
    LOOP AT example_internal_table INTO example_workarea
        IF example_workarea-field = criteria.
            PARAMETERS: (example_workareafield) AS CHECKBOX.
        ENDIF.
     ENDLOOP.
SELECTION-SCREEN END OF BLOCK example.

The code snippet above throws the error that example-workarea-field is not a constant. Does this mean it isn't possible to dynamically declare parameters or am I just doing it wrong? Thanks


Solution

  • Correct. PARAMETERS statements compile into selection screens at compile time, not at runtime. Therefore you cannot do what you want in the way you have proposed.

    However, it is possible to have some form of dynamic screens.

    Look at the answers to this question: For the I/O fields in a normal ABAP screen, can i get them to behave like a SELECT-OPTIONS?

    This gives you two starting points: The use of subscreens, which you can call dynamically, or the use of FREE_SELECTIONS_INIT as examples.