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

comparing string in select query

Former Member
0 Likes
578

Hi,

select single *

from mara

where <b>matnr = wa-matnr</b>.

Here matnr is char18. Can we compare string like this?

When <b>wa-matnr</b> is in <b>lower case</b> it is setting sy-subrc = 4, even though the matnr exists in mara. When converted to upper case and used it is setting sy-subrc = 0.

Is there any other solution for the problem? I have checked out with matnr's conversion routine. It is also not working.

4 REPLIES 4
Read only

Former Member
0 Likes
525

Hi ,

You can convert the string to upper case using the function module TERM_TRANSLATE_TO_UPPER_CASE, and then check for the value,

Hope this helps,

Rgds,

Read only

Former Member
0 Likes
525

Hello,

First translate the WA-matnr to UPPER case using translate to uppercase and then use it in the select query.

If useful reward points.

Vasanth

Read only

0 Likes
525

just try dat way...

<b>ex...</b>

data:wa_matnr like mara-matnr.

data:wa_matnr1 like mara-matnr.

data: gv_matnr like mara-matnr.

wa_matnr = 'comptest'.

CALL FUNCTION 'TERM_TRANSLATE_TO_UPPER_CASE'

EXPORTING

LANGU = SY-LANGU

TEXT = wa_matnr

IMPORTING

TEXT_UC = wa_matnr1

  • EXCEPTIONS

  • NO_LOCALE_AVAILABLE = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

select single matnr

from mara into gv_matnr

where matnr = wa_matnr or matnr = wa_matnr1.

write : gv_matnr.

Read only

Former Member
0 Likes
525

Hi mudhukeshwar,

1. If your field wa-matnr

a) is defined with LIKE MARA-MATNR.

b) is defined as parameter on selection-screen,

(so that the value comes from screen,

and not hardcoded into the program)

2. then automatically

a) uppercase

b) zero padding

will be taken care of , and u will get the record.

regards,

amit m.