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

Clear Select-options dynamically

Former Member
0 Likes
898

Hi all,

I’m trying to clear the content of a select option depending on a control table wich contains the select-options name.

I tried coding something like that :

SELECT-OPTIONS s_0001 FOR pernr-pernr.
SELECT-OPTIONS s_0002 FOR pernr-pernr.
SELECT-OPTIONS s_0003 FOR pernr-pernr.

DATA l_string TYPE string.

FIELD-SYMBOLS  <selectoption>.

LOOP AT clear_table.

    IF clear_table-clear = ‘X’.

        MOVE clear_table-selectoption TO l_string.  ‘’ (clear_table-selectoption = ‘s_0001’ ).

        ASSIGN l_string to <selectoption>.

        CLEAR <selectoption>.

    ENDIF.

ENDLOOP.

By this I just assign the name of my select-options but not the content.

Could you give my the method to assign the content of my select-options into a field-symbol in order to clear the content.

Thanks in advance.

David

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
786

Hi,

If the idea is to maintain the SO tables before querying, then you should use a field symbols of type table...

DATA: l_string TYPE string.

FIELD-SYMBOLS: <f> TYPE ANY TABLE.

l_string = 'S_0001[]'.     "with open and close brakets

ASSIGN (l_string) TO <f>.

CLEAR <f>.

Kr,

Manu.

5 REPLIES 5
Read only

Former Member
0 Likes
786

Hi David,

Are you trying to clear the select options values before the selection screen is displayed? If so, you need to do this in the event AT SELECTION-SCREEN OUTPUT.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
786

Select-options are internal tables with header line, so CLEAR and REFRESH are required, and field symbol type any and any table can be useful.

Regards,

Raymond

Read only

Former Member
0 Likes
787

Hi,

If the idea is to maintain the SO tables before querying, then you should use a field symbols of type table...

DATA: l_string TYPE string.

FIELD-SYMBOLS: <f> TYPE ANY TABLE.

l_string = 'S_0001[]'.     "with open and close brakets

ASSIGN (l_string) TO <f>.

CLEAR <f>.

Kr,

Manu.

Read only

0 Likes
786

@Kevin, it doesn't work if the select option is filled using a variant.

@Manu, Thanks a lot, It simply lacked the brackets [] in my code.

David

Read only

che_eky
Active Contributor
0 Likes
786

You are not using the ASSIGN statement in the correct way. Also if you wan to clear the select option you need to assign "S_0001[]" and not "S_0001".

Take a look at the reworked code below. This will clear the contents of S_0001, but will not reflect the change on the selection screen. As Kevin says you need to move to the selection-screen output event if you want that:

TABLES: pernr.

TYPES: BEGIN OF y_clear_table,
          clear TYPE c LENGTH 1,
          selectoption TYPE c LENGTH 10,
        END OF y_clear_table.
DATA: clear_table TYPE STANDARD TABLE OF y_clear_table WITH HEADER LINE.

SELECT-OPTIONS s_0001 FOR pernr-pernr.
SELECT-OPTIONS s_0002 FOR pernr-pernr.
SELECT-OPTIONS s_0003 FOR pernr-pernr.

DATA l_string TYPE string.
FIELD-SYMBOLS  <selectoption>.
clear_table-clear = 'X'.
clear_table-selectoption = 'S_0001[]'.
APPEND clear_table.

BREAK-POINT.
LOOP AT clear_table.
   IF clear_table-clear = 'X'.
     MOVE clear_table-selectoption TO l_string" (clear_table-selectoption = ‘s_0001’ ).
     ASSIGN (l_string) TO <selectoption>.
     CLEAR <selectoption>.
   ENDIF.
ENDLOOP.

Che