1 1 1 1 1 Rating 0% (0 Votes)
It may happen that you'll need to do select or loop on a base of the field which is kept in lower case, but you don't know exactly what's the value o field. In such case you may want to build a range of the possible values to be able to fulfill the task. Here is how to do it quite fast by doing FM:

function z_ab_prep_val_for_case_search.
*"*"Local Interface:
  field-symbols<low> type any.
  field-symbols<sign> type any.
  field-symbols<opt> type any.
  field-symbols<line> type any.
  field-symbols<linenew> type any.
  field-symbols<lownew> type any.
  field-symbols<tab> type standard table.
  dataf_times type i.
  dataf_text type string.
  dataf_textnew type string.
  dataf_insidel type i.
  dataf_insidel2 type i.
  dataft_data type ref to data.

  "create temp table and assign it to FS
  create data ft_data like er_range.
  assign ft_data->to <tab>.

  f_text i_text.

  "get lenght
  f_times strlenf_text ).
  "translate to upper case so we have always same start
  translate f_text to upper case.

  "append initial line to range and put first value into table
  append initial line to er_range assigning <line>.
  check sy-subrc eq 0.
  assign component 'LOW' of structure <line> to <low>.
  check sy-subrc eq 0.
  <low> i_text"all in uppercase
  assign component 'SIGN' of structure <line> to <sign>.
  check sy-subrc eq 0.
  <sign> i_sign.
  assign component 'OPTION' of structure <line> to <opt>.
  check sy-subrc eq 0.
  <opt> i_option.
  translate <low> to upper case.

  "create entries for each other combination of cases
  do f_times times.
    f_insidel2 sy-index 1.
    loop at er_range assigning <line>.
      assign component 'LOW' of structure <line> to <low>.
      check sy-subrc eq 0.
      if f_text+f_insidel2(1ca '*+' and i_option eq 'CP' or i_option eq 'NP' ).

        append initial line to <tab> assigning <linenew>.
        check sy-subrc eq 0.
        assign component 'LOW' of structure <linenew> to <lownew>.
        check sy-subrc eq 0.
        assign component 'SIGN' of structure <linenew> to <sign>.
        check sy-subrc eq 0.
        <sign> i_sign.
        assign component 'OPTION' of structure <linenew> to <opt>.
        check sy-subrc eq 0.
        <opt> i_option.
        <lownew> <low>.
        f_textnew <lownew>+f_insidel2(1).
        translate f_textnew to lower case.
        <lownew>+f_insidel2(1) = f_textnew.
    append lines of <tab> to er_range.
    refresh <tab>[].


Example report to use the function:

report  zab_prepare_values_for_cs.

parametersf_char40 type char40.

rangesr_char40 for f_char40 .

field-symbols<char40> like line of r_char40.


  call function 'Z_AB_PREP_VAL_FOR_CASE_SEARCH'
      i_text   f_char40
      i_option 'CP'
      er_range r_char40[].

  loop at r_char40 assigning <char40>.
    write:/ <char40>-low.

And it's sample output for f_char40 = abapblog.
Of course the number of etries in the range grows rapidly so use it with small input string only.
Have Fun!