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

SQL query syntax error .......

Former Member
0 Likes
1,942

I am using following query

SELECT PERNR VORNA NACHN GBDAT FROM PA0002

INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE UPPER( VORNA ) = UPPER( STRU_USERIP-VORNA )

AND ENDDA >= SY-DATUM

AND BEGDA <= SY-DATUM .

and I am geting syntax error as --

vorna is not valid comparison operator .

can anyone plz suggest me solution over this problem .

17 REPLIES 17
Read only

former_member217544
Active Contributor
0 Likes
1,889

Hi,

Use this way:

SELECT PERNR VORNA NACHN GBDAT FROM PA0002

INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE VORNA = STRU_USERIP-VORNA

AND ENDDA >= SY-DATUM

AND BEGDA <= SY-DATUM .

Regards,

Swarna Munukoti

Read only

0 Likes
1,889

Thanks for Replying ,

Query u replied works but I want ignore the case while compairing so I i cant remove the upper function

Is there any other solution for this ?

Edited by: RUSHI123 on Nov 2, 2009 10:06 AM

Edited by: RUSHI123 on Nov 2, 2009 10:07 AM

Read only

former_member222860
Active Contributor
0 Likes
1,889

You can't use UPPER in the Select Statement.

Read only

Former Member
0 Likes
1,889

Hi,

Remove the UPPER statement and check.

Regards,

Ginu

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,889

Hi this keyword is not possible in open sql ABAP query.

Possibilites to make it happen

Native Sql


tables:pa0002.

EXEC SQL.


  SELECT PERNR VORNA NACHN GBDA
  INTO :PA0002
  FROM  PA0002
  WHERE UPPER(VORNA)  =  :STRU_USERIP-VORNA

ENDEXEC.

or

You have to write a conversion exit for that field at database level.

or

Uncheck the lowercase checkbox in domain.

Read only

Former Member
0 Likes
1,889

This message was moderated.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,889

Hi this keyword is not possible in open sql ABAP query.

Possibilites to make it happen

Native Sql


tables:pa0002.

EXEC SQL.


  SELECT PERNR VORNA NACHN GBDA
  INTO :PA0002
  FROM  PA0002
  WHERE UPPER(VORNA)  =  :STRU_USERIP-VORNA

ENDEXEC.

or

You have to write a conversion exit for that field at database level.

or

Uncheck the lowercase checkbox in domain.

since its a std db field only native sql you can try

Read only

0 Likes
1,889

I am writing this query in controllers method of webdynpro abap application for retriving pernr of all records whose first name matches with inputed name .

Does above code lines will give internal table containing matching records ?

Your help will be highely appericiated .

Thks ,

Rushi

Read only

0 Likes
1,889

>

> Does above code lines will give internal table containing matching records ?

Hello,

No it wont give you an internal table in return.

BR,

Suhas

Read only

0 Likes
1,889

hi,

Just try it once. It might work.

Since im not aware of concepts in webdynpro i cant assure you.

Read only

0 Likes
1,889

Hello Keshu,

Please read the SAP documention for EXEC SQL ... ENDEXEC.

To populate the internal table, you have to write it in a separate subroutine.

EXEC SQL PERFORMING SUBR. 
" Your SELECt stmt
ENDEXEC. 

FORM SUBR. 
" Append the work area to Internal Table 
ENDFORM.

I am not sure if you can use Native SQL in webdynpro.

BR,

Suhas

Read only

0 Likes
1,889

Thks Keshu ,

Code u provided is just fine . It works in wdabap . It retrives only one matching record and put it into structutre variable :pa0002 .

In my case if there are more than one matching records then i want all of them in internal table so i can use them for further processesing .

can u suggest any solution over this .

Read only

0 Likes
1,889

Hello Rushi,

Do an F1 on EXEC SQL, read the SAP documentation. You get only one row for every EXEC SQL...ENDEXEC loop.

You have to populate the internal table in a separate subroutine.

BR,

Suhas

Read only

0 Likes
1,889

Hello Suhas ,

suggestion u provided wont work in webdynpro abap . I closing this thres and similar in webdynpro abap categeory .

thks ,

Rushi

Read only

0 Likes
1,889

Hi just try this

You can build combinations of the name like

name = fra.

Fra

fRa

frA

FRa

fRA

FrA ....

the append it to ranges

and then use it in select query

Read only

0 Likes
1,889

HI KESHU ,

How to get these combinations . is there any std method or i hv to implement some logic .

if you can elaborate , it would be really helpful .

thks ,

rushi

Read only

0 Likes
1,889

Logic must be written,

The below logic is incomplete

Break your head and modify it


TABLES:pa0002.
DATA:itab TYPE TABLE OF pa0002.
DATA:wa TYPE pa0002.
DATA:lv_vorna TYPE pa0002-vorna.
DATA:ra_vorna TYPE RANGE OF pa0002-vorna.
DATA:wa_vorna LIKE LINE OF ra_vorna .
DATA:lv_index TYPE i.
DATA:offset TYPE i.

DATA:pa_vorna TYPE pa0002-vorna VALUE 'Frank'.

DATA:len TYPE i.
len = STRLEN( pa_vorna ).
MOVE pa_vorna TO lv_vorna.
TRANSLATE lv_vorna TO LOWER CASE.
wa_vorna-low = lv_vorna.
APPEND wa_vorna TO ra_vorna.
MOVE pa_vorna TO lv_vorna.
TRANSLATE lv_vorna TO UPPER CASE.
wa_vorna-low = lv_vorna.
APPEND wa_vorna TO ra_vorna.
wa_vorna-low = PA_VORNA.
APPEND wa_vorna TO ra_vorna.

TRANSLATE PA_VORNA TO LOWER CASE.

DO len TIMES.
  lv_index = sy-index - 1.
  offset = lv_index + 1.
  DO len TIMES.
    MOVE pa_vorna TO lv_vorna.
    TRANSLATE lv_vorna+lv_index(offset) TO UPPER CASE.
    wa_vorna-low = lv_vorna.
    APPEND wa_vorna TO ra_vorna.
    ADD 1 TO lv_index.
  ENDDO.
ENDDO.