2013 Jan 09 2:33 PM
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
2013 Jan 09 3:10 PM
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.
2013 Jan 09 3:01 PM
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.
2013 Jan 09 3:07 PM
2013 Jan 09 3:10 PM
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.
2013 Jan 09 3:45 PM
@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
2013 Jan 09 3:11 PM
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