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

Select upper/lowercase

Former Member
0 Likes
3,557

Hi

I have a table where I got data in upper and lower case (like "TeSt".

My selection must find this entry if the selct-options contain:

TE*

te*

*ST

etc.

In my program I select all my data in an internal table.

Then the text field (TeSt) from the internal table is converted into a local field in upper-case .

But how do I get the the right data?

I have tried this, but it is not a succes...


LOOP at ITAB
    lv_firm = ITAB-company.

    lv_strln = STRLEN( lv_firm ).

    DO lv_strln TIMES.

      TRANSLATE lv_ITAB+lv_count(1) TO UPPER CASE .
      ADD 1 TO lv_count.

    ENDDO.

    IF lv_firm IN r_firm.

      CONTINUE.
    ELSE.
      DELETE ITAB.
    ENDIF.

  ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,948

Hi,

You dont have to convert the field to uppercase character by character. You can directly use the translate command on the whole field. If r_firm is the select-options, convert even those to upper case



data: v_firm(10) type c.
SELECT-OPTIONS: r_firm for v_firm.

loop at r_firm.
    TRANSLATE r_firm-low TO UPPER CASE .
modify r_firm.
endloop.

LOOP at ITAB
    TRANSLATE ITAB-company TO UPPER CASE .
    IF NOT ITAB-comapny IN r_firm.
       DELETE ITAB.
    ENDIF.
  ENDLOOP.

Regards,

Vikranth

4 REPLIES 4
Read only

Former Member
0 Likes
1,949

Hi,

You dont have to convert the field to uppercase character by character. You can directly use the translate command on the whole field. If r_firm is the select-options, convert even those to upper case



data: v_firm(10) type c.
SELECT-OPTIONS: r_firm for v_firm.

loop at r_firm.
    TRANSLATE r_firm-low TO UPPER CASE .
modify r_firm.
endloop.

LOOP at ITAB
    TRANSLATE ITAB-company TO UPPER CASE .
    IF NOT ITAB-comapny IN r_firm.
       DELETE ITAB.
    ENDIF.
  ENDLOOP.

Regards,

Vikranth

Read only

0 Likes
1,948

Thanks for the reply - My range was wrong... (the option should be CP).

Anyway I could use your optimized code thanks

Read only

0 Likes
1,948
DATA v_field(10) TYPE c.
SELECT-OPTIONS s_field FOR v_field LOWER CASE.

START-OF-SELECTION.
  SELECT FIELD1
    FROM DATA_TABLE
    INTO TABLE IT_TAB
    WHERE FIELD1 IN s_field.

the keywords 'LOWER CASE' to set select-option upper and lower sensitive.

Read only

venkat_o
Active Contributor
0 Likes
1,948

Hi, <li> I tried with the below sample program by giving matnr 100* , *100. <li>You do not need to worry about your case you mentioned TE* te* *ST. It automatically converts to capital letters. Try this way.


REPORT  ZTEST_NOTEPAD.
TABLES:MARC.
DATA: IT_MARC TYPE STANDARD TABLE OF MARC WITH HEADER LINE.
SELECT-OPTIONS: S_MATNR FOR MARC-MATNR.

START-OF-SELECTION.
SELECT * FROM MARC INTO TABLE IT_MARC WHERE MATNR IN S_MATNR.
LOOP AT IT_MARC.
  LOOP AT S_MATNR.
    IF MARC-MATNR CP S_MATNR-LOW.
      WRITE:/ IT_MARC-MATNR.
    ENDIF.
  ENDLOOP.
ENDLOOP.
Thanks Venkat.O