Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Best practice for selection-screen in global classes

alejiandro_sensejl
Active Participant
0 Likes
4,366

Hello everyone,

I have build several selection screens (overall 150+ select options / parameters) some time ago and want to reuse some of them within a global class encapsulating a ALV grid. Is there an easy way to forward the values of a selection screen into my class?

I have thought of a function module (in the function group which contains the dynpros) to extract the values. Is this a state-of-the-art approach?

Thanks in advance,

Alej

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,077

Hello Alej

I would use the approach as implemented in class CL_DBSEL_CATS, e.g.:

Regards

Uwe

4 REPLIES 4
Read only

uwe_schieferstein
Active Contributor
0 Likes
2,078

Hello Alej

I would use the approach as implemented in class CL_DBSEL_CATS, e.g.:

Regards

Uwe

Read only

0 Likes
2,077

Hi Uwe,

correct me if I'm wrong: I remember RS_REFRESH_FROM_SELECTOPTIONS not doing the job perfectly, what ever it was, maybe

'RS_REFRESH_FROM_SELECTOPTIONS' reads only the main selection screen of a report; it will not give you SELECTION-SCREEN BEGIN OF SCREEN ... contents.

At least it is good for extracting the names of all SELECT-OPTIONS and PARAMETERS. Then use a dynamic assign like

data:
  lv_assign type string
field-symbols:
  <selopt> type table.
CONCATENATE '('IM_CALLING_PROGRAM')' SELNAME INTO lv_assign.
assign (lv_assign) to <selopt>.

This not only enables you to use but also to modify the select-options on the screen as you want or need.

I know since 10 or more years SAP warns to use the dynamic ASSIGN. But it works perfectly and will probably never be changed.

Regards,

Clemens

Read only

Former Member
0 Likes
2,077

Hi Alej

If you're only after the definition of the selection screen then function module RS_ISOLATE_1_SELSCREEN might be useful. It will not give you the values but will give you the full selection screen definition, including any subscreens and blocks. Maybe you could use a combination of RS_ISOLATE_1_SELSCREEN and RS_REFRESH_FROM_SELECTOPTIONS to achieve what you want.

Let us know how you go...

Regards

Glen

Read only

Former Member
0 Likes
2,077

The approach recommended by SAP (read: Horst Keller) is to build a function group which would contain selection screens defined in a main program. There should be one function module for each selection screen. Function modules should have exporting parameters for all the fields of the screen it contains. Then you are able to call such a function module in a global class. You should implement an exception or some return flag which would say that screen has been left using back, exit, cancel buttons.

METHOD method_a.
  ...
  CALL FUNCTION 'MY_SELECTION_SCREEN'
    IMPORTING
      e_so_vbeln = l_rng_vbeln
    EXCEPTIONS ex_screen_left = 4.
  IF sy-subrc = 4.
    ...
  ELSE.
    ...
  ENDIF.
ENDMETHOD.

FUNCTION.   "MY_SELECTION_SCREEN
  CALL SELECTION-SCREEN 1001.
  IF sy-subrc NE 0.
    RAISE ex_screen_left.
  ENDIF.
  e_so_vbeln = so_vbeln.
ENDFUNCTION.

SELECTION-SCREEN BEGIN OF SCREEN 1001.
SELECT-OPTIONS so_vbeln FOR ...
...

Edited by: Krzysztof Usowicz on Sep 14, 2010 2:59 PM

Edited by: Krzysztof Usowicz on Sep 14, 2010 3:04 PM