04-01-2008 10:47 AM
Hi All,
I have a field in selection screen. When I enter 10* in select options, It should select all the values of the field starting with 10* in F4 help. How can I do code this?
Thanks,
Rajani.
04-01-2008 11:10 AM
You can use like statement for your query.
For Eg.
SELECT * FROM sflight INTO CORRESPONDING
FIELDS OF TABLE it_sflight
WHERE carrid LIKE 'A%'.
It will select all the carrids starting with 'A'.
04-01-2008 10:55 AM
Try the below code:
PARAMETERS:
p_senkey TYPE zsession_key.
AT SELECTION-SCREEN .
**F4 help for
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_senkey.
PERFORM f0012_sh_on_s_session CHANGING p_senkey.
FORM f0012_sh_on_s_session CHANGING p_senkey TYPE any.
REFRESH : i_seskey, i_ddshretval.
CLEAR:wa_seskey.
SELECT template_id " #CCE No deletion Flag
version
session_key
lock_date
success
unlock_date
FROM zfact_maint_jlog INTO wa_seskey.
APPEND wa_seskey TO i_seskey.
ENDSELECT.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
retfield = 'SESSION_KEY'
PVALKEY = ' '
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_SENKEY'
STEPL = 0
window_title = 'SESSION KEY'
VALUE = ' '
value_org = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
MARK_TAB =
IMPORTING
USER_RESET =
TABLES
value_tab = i_seskey
FIELD_TAB =
return_tab = i_ddshretval.
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.
IF sy-subrc <> 0. "#EC *
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CLEAR wa_ddshretval.
READ TABLE i_ddshretval INTO wa_ddshretval INDEX 1.
IF sy-subrc EQ 0.
p_senkey = wa_ddshretval-fieldval.
ENDIF.
ENDIF.
ENDFORM. " f0013_sh_on_s_session
Reward if useful.
04-01-2008 11:10 AM
You can use like statement for your query.
For Eg.
SELECT * FROM sflight INTO CORRESPONDING
FIELDS OF TABLE it_sflight
WHERE carrid LIKE 'A%'.
It will select all the carrids starting with 'A'.
04-01-2008 1:46 PM
if the selection option field is say s_table then jus follow the below syntax it wil surely solve
CONCATENATE s_table-low '%' INTO l_var1.
*Select all the values from the Z table and put it in a internal *table. say it_tab.
{code]SELECT * FROM <dbtable> INTO CORRESPONDING
FIELDS OF TABLE it_tab
WHERE field LIKE l_var1.{code]
Surely it will work.
Award points if helpful.
Regards.
Gowri
04-03-2008 11:53 AM
Hi Gowri/Rengith,
Thanks for replies.Tried both your suggestions. The standard SQL uses % and - as wildcard chara where as the ABAP uses * and + symbols.
When I tried with 100% as input , it worked. But user will give the input with 100* . My Select code is not identifying the * as wildcard. Pls suggest.
Thanks,
Rajani.
04-03-2008 11:59 AM
Hi Rajani,
Whenever the user enters * just replace it with % and use in your select query. Surely it will work. Let me know if you have any problem with it.
Regards
Gowri
04-03-2008 12:09 PM
Gowri,
Thanks! That will solve my problem. I have anoter issue like i should display all the values with 100* in F4 help to the user and then transfer to itab for further processing.
Thanks,
Rajani.
04-03-2008 12:33 PM
04-03-2008 12:29 PM
Hi,
Check the below logic.
data v_num(2).
select-options: s_abkrs for v_num.
data: itab like t549a occurs 0 with header line.
data v_count type i.
at selection-screen on value-request for s_abkrs-low.
select * from t549a into table itab.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'ABKRS'
DYNPPROG = sy-repid
DYNPNR = sy-dynnr
DYNPROFIELD = 'S_NUM-LOW'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = itab
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.