-2

I need to define one dynamic selection field as required.

I created a transaction code with a starting variant.

For this variant in the attributes screen assignment, there is no "required field" option on dynamic selections, only "protect field".

Any idea how to implement this?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
John
  • 39
  • 1
  • 4
  • 3
    Completely unclear on what you've already tried and what you're trying to achieve here... – vwegert Sep 19 '17 at 16:52
  • Are you using ABAP Dynpro or standard selection-screens for example? Basicly, you should decide the type of the selection field. You can do it in Process before output in Dynpro, and AT SELECTION-SCREEN OUTPUT event section in standard selection-screens. – Oguz Sep 20 '17 at 08:43
  • You are talking about the selection screen of an abap report? Maybe you are searching for the screen-required attribute, this will set a field as required. Example: LOOP AT SCREEN. CASE screen-name. WHEN 'P_PARAM'. screen-required = '1'. ENDLOOP You need to place this within the correct entry point which fits to your requirement (e.g. AT SELCTION-SCREEN OUTPUT) – Beka Sep 20 '17 at 08:53
  • Will upload screens tomorrow, so I define the issue. Thanks! – John Sep 20 '17 at 17:10

2 Answers2

1

On variant attributes screen assignment there is not required field option on dynamic selections

There is Required attribute in screen variant and it is perfectly usable for making regular field mandatory, and in dynamic selections too.

enter image description here

If you lack it, check your release or maybe your installation is corrupted. I don't believe it is tcode-dependent.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
0

If you are talking about the Dynamic Selections, then you can only protect the fields. Example with demo program DEMO_LIST_OUTPUT (which is based on the F1S Logical Database):

Dynamic selections in DEMO_LIST_OUTPUT

Program variant for dynamic selections in DEMO_LIST_OUTPUT

You can only protect those fields against input, and all other attributes are deactivated (they are not implemented as you can see in subroutine MODIFY_SCREEN of program SAPLSSEL).

The only possible workaround to simulate a mandatory field is to implement ABAP code after the user has entered selections (or not). For instance, in the program DEMO_LIST_OUTPUT, you may add this ABAP code which checks that the screen field "Connection Number" contains a value when the user executes the program:

TABLES sscrfields.
AT SELECTION-SCREEN.
  DATA dynsel TYPE rsds_trange.
  CALL FUNCTION 'RS_REFRESH_FROM_DYNAMICAL_SEL'
    EXPORTING
      curr_report        = sy-repid
      mode_write_or_move = 'W'
    IMPORTING
      p_trange           = dynsel
    EXCEPTIONS
      not_found          = 1
      wrong_type         = 2.
  DATA(connid) = VALUE spfli-connid(
    dynsel[ tablename = 'SPFLI'
        ]-frange_t[ fieldname = 'CONNID'
            ]-selopt_t[ 1 ]-low OPTIONAL ).
  IF sscrfields-ucomm = 'ONLI' AND connid IS INITIAL.
    MESSAGE 'Flight Connection number is required' TYPE 'E'.
  ENDIF.

NB: Tested with ABAP 7.52. Dynamic Selections can be implemented implicitly via Logical Databases (which are obsolete since ABAP 7.02 or 7.31) or explicitly by calling the function modules FREE_SELECTIONS_INIT and FREE_SELECTIONS_DIALOG.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48