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

Upper and lower case conversion

Former Member
0 Likes
5,170

Hi,

I need small help on conversions.

I need to convert the data in database tables to lower case.

Like i need to pick some data from a database table. The data stored in the database table is in uppercase. Here i need to convert the data to lowercase through the select statement. Is there any way to do this.

Regards,

Ram

Hi ANurag,

Even after changing the range field as you said its giving the data which is in UPPER case for the name1 field. I need all the data for name1 with lower and upper case as well.

Regards,

Ram

27 REPLIES 27
Read only

Former Member
0 Likes
3,307

U can read the data from the table...convert to lower case and modify the table again.

TRANSLATE lchr TO LOWER CASE.

--> I hope you dont have to translate the key fields even in that case u would need to delete the record and insert.

Message was edited by: Anurag Bankley

Read only

0 Likes
3,307

Hi,

Before i execute the select statement i need the data to be converted to lowercase.

The thing is i can do the conversion after the select statement. Here i need to get some data from select statement and from the data we get here i need to write one more select statement which also to be displayed lowercase data.

Regards,

Ram

Read only

0 Likes
3,307

Hi,

just write 2 select statements in that case.

After the first select you modify the data in the

table then select the changed data.

Read only

0 Likes
3,307

Hi,

Here is my code..

SELECT addrnumber name1 city1 FROM adrc INTO TABLE i_adrc

WHERE name1 IN r_name1 AND city1 IN r_city1.

IF i_adrc IS NOT INITIAL.

SELECT kunnr adrnr brsch bran1 land1 INTO TABLE i_kna1

FROM kna1 FOR ALL ENTRIES IN i_adrc

WHERE adrnr = i_adrc-addrnumber AND

brsch IN r_brsch AND

bran1 IN r_braco AND

land1 IN r_land1.

Here after the first select statement i am not getting the required data as name1 is maintained in Uppercase in the database. SO i need to change the data to lowercase before the select statement itself.

regards,

Ram

Read only

0 Likes
3,307

I think the best way is to convert the data in your range r_name1 to uppercase and fetch the date from adrc table.

loop at r_name1.

translate r_name1-low to upper case.

translate r_name1-high to upper case.

modify r_name1.

endloop.

Read only

0 Likes
3,307

Hi,

It not peoblem with the ranges. The data in the database should be made nto lowercase before my select statement so that i will get all the data.

regards,

Ram

Read only

0 Likes
3,307

Is your problem that you need to convert the data in ADRC table into lower case OR fetching the data from ADRC ??

Read only

0 Likes
3,307

ADRC-Name1 data should be converted to lowercase and need to get the requred data based on the select statement.

Regards,

Ram

Read only

0 Likes
3,307

The only way is to do the below before your code...

<b>select name1 into lname1 from adrc.

translate lname1 to lower case.

adrc-name1 = lname1.

modify adrc.

endselect.</b>

Message was edited by: Anurag Bankley

Read only

0 Likes
3,307

HI Anurag,

select name1 from adrc.

translate adrc-name1 to lower case.

update adrc.

endselect.

The above statement is giving error as

"Field list without into clause is not allowed. Itab or into(f1....fn) is not allowed..Can you pls correct me.

Regards,

Ram

Read only

0 Likes
3,307

Hi,

As far as I understood, Ur problem is getting all the data be it lower case or uppercase in ADRC table for the range...

I think you can try...

Select <fields> from ADRC

where name1 LIKE <range field>.

Thanks,

Rashmi.

Read only

0 Likes
3,307

Hi Anurag,

Thanks for the reply.

But its taking much time to execute the select statement. Is there any other simple way of doing this.

Regards,

Ram

Read only

0 Likes
3,307

Actually it would as you want to update all the records in ADRC table...I am not sure why you wish to update all the database table records in lower case...you can easily fetch your data if you change the range to use upper case and manipulate the same in report when required.

To change the range check my earlier code and you would be able to get the data.

Read only

0 Likes
3,307

Hi ANurag,

Even after changing the range field as you said its giving the data which is in UPPER case for the name1 field. I need all the data for name1 with lower and upper case as well.

Regards,

Ram

Read only

0 Likes
3,307

Yes, it would give you in upper case but once you have fetched the data you can convert it into lower case using the TRANSLATE statement.

Second option is when you are updating ADRC do it for the required records only.

Read only

0 Likes
3,307

Hi Anurag,

My question is, I have both upper case and Lower case data in ADRC-name1 field. I am searching for some records with string 'good'. Once i execute the select statement its fetching only the Uppercase data. Here i need all the records with upper as well as lower case for 'good' as the string.

I am writing this in function mofdule and so it takes only uppercase search even if we give that in lower case.

Hope you understood my question.

Regards,

Ram

Read only

0 Likes
3,307

Hi Ram mohan,

Try by appending * at the begining and end of text like good , this will fetch the data in both the cases.

Hope this helps.

Read only

0 Likes
3,307

My question is, I have both upper case and Lower case data in ADRC-name1 field. I am searching for some records with string 'good'. <b>Once i execute the select statement its fetching only the Uppercase data. Here i need all the records with upper as well as lower case for 'good' as the string.</b>

<i>I am writing this in function mofdule and so it takes only uppercase search even if we give that in lower case.</i>

The statements highlighted sought of contradict each other..The best would be to paste the relevant part of code + examples with clear mention as to the data x should be fetched and not y etc...it would help to understand the requirement in a better way !!

Read only

0 Likes
3,307

Do like this.

data: ws_name1 like adrc-name1.

select name1 from adrc into ws_name1.

translate adrc-name1 to lower case.

update adrc.

endselect.

Regards,

PRakash.

Read only

0 Likes
3,307

Hi Anurag,

Let me eaplain this clearly.

I am building a function module to get the customer names. I have input field as Customer name and if i pass any search name here i need to get all the records form ADRC table which suits this match. For example i am giving search string as 'good'. But as the function module takes all the input parameters in Uppercase its giving only the uppercase data which suits the serach string 'good'. Here i need to fetch all the records(upper case and lower case) which contains 'good' in the customer name. Hope its clear now.

Regards,

Ram

Read only

0 Likes
3,307

Hi ram,

1. in r/3,

working with upper/lower case,

with database tables, is very tricky.

<b>(SIMPLY USING SQL WILL NOT

FETCH BOTH KIND OF DATA - UPPERCASE/lowercase/MIXED)</b>

2. For your requirement,

3.

a) just get ALL data from vendor master

(without any filteration of name)

in ITAB

b) LOOP AT ITAB.

IF ITAB-VENDORNAME CS 'GOOD'.

ELSE.

DELETE ITAB.

ENDLOOP.

4. After the step (b),

<b> itab will contain only GOOD vendors.

(irrespective of capital / lowercase) / mixedCASE</b>

regards,

amit m.

Read only

0 Likes
3,307

Hi Ram Mohan,

Try this, it is working for me.

1. Declare a range to hold the value.

2. Populate the range as follows. name1 is the function module parameter name

IF NOT name1 IS INITIAL.

rt_ernam-sign = 'I'.

rt_ernam-option = 'CP'.

rt_ernam-low = name1.

APPEND rt_ernam.

ENDIF.

Hope this helps.

Read only

0 Likes
3,307

Hi Imtiaz,

I am using the same but getting only Uppercase match. I need all the lower and uppercase records which match the pattern specified.

Regards,

Ram

Read only

anversha_s
Active Contributor
0 Likes
3,307

hi,

us this.

transalate <field> to lower case.

similarly u can convert to upper case.

rgds

anver

pls mark hlpful answers

Read only

0 Likes
3,307
loop at <internal_table> into <work_area>.
  TRANSLATE <work_area-field_name> to LOWER CASE.
  MODIFY <table> from <work_area>.
endloop.
Read only

anversha_s
Active Contributor
0 Likes
3,307

hi ram,

one way.

before inserting to db, u can convert the data to lower case.

rgds

anver

Read only

sridhar_k1
Active Contributor
0 Likes
3,307

Use field MC_NAME1 instead of NAME1 in where condition.

NAME1 is converted to upper case and stored in MC_NAME1, but only first 25 chanracters of NAME1.

so convert user entered value to upper case and select fro adrc using MC_NAME1.

Try this code:

tables: adrc.

data: tadrc like adrc occurs 0 with header line.

select-options: s_mc1 for adrc-mc_name1.

select * from adrc into table tadrc where mc_name1 in s_mc1.

loop at tadrc.
  write:/ tadrc-name1.
endloop.

Regards

Sridhar