Application Development 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: 

Problem with Select statement.

Former Member
0 Kudos

DATA: wa_usr05 TYPE usr05.

The select statement always gives sy-subrc = 0

even if there is no entry with parid = 'ZRD'.

On successful it fills the structure wa_usr05 as

MANDT C 3 ACC

BNAME C 12 SCL

PARID C 20 X

PARVA C 18

but mandt is 310.

USR05 is a pool table and has mandt field.

SELECT SINGLE bname

parid

parva

FROM usr05

INTO wa_usr05

WHERE bname = sy-uname AND

parid = 'ZRD' AND

parva = 'x' OR parva = 'X'.

Let me know the reason and solution to the problem.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

SELECT SINGLE * FROM usr05

INTO wa_usr05

WHERE bname = sy-uname AND

parid = 'ZRD' AND

( parva = 'x' OR parva = 'X' ). "in brackets.

8 REPLIES 8

Former Member
0 Kudos
SELECT SINGLE * FROM usr05
INTO wa_usr05
WHERE bname = sy-uname AND
parid = 'ZRD' AND
parva = <b>'X'</b> .

Use single * as u have defined the wa+usr05 as usr05.

Else.

DATA: i_usr05 TYPE STANDARD TABLE of usr05.
SELECT * FROM USR05
         INTO TABLE usr05
         WHERE bname = sy-uname AND
         parid = 'ZRD' AND
        parva = <b>'X'</b> .

Then loop at itab and write data.

Hope this solves ur query.

Reward points if this helps.

Message was edited by:

Judith Jessie Selvi

0 Kudos

Hi Jessi,

Can you tell me what is the use of <b> and </b> ? and why the select was always successful.

Former Member
0 Kudos

SELECT SINGLE * FROM usr05

INTO wa_usr05

WHERE bname = sy-uname AND

parid = 'ZRD' AND

( parva = 'x' OR parva = 'X' ). "in brackets.

0 Kudos

what is the user of parva = <b>'X'</b> ?

0 Kudos

Hi jessi,

if you see your first reply there it is mentioned

< b > and < / b > what is this ?

0 Kudos

Hi,

Just tried to show it as bold thats y.

U can specify as 'X' that is enough no need for 'x'.

U can also specify with OR no problem with OR

U can simply specify that as

SELECT SINGLE * FROM usr05

INTO wa_usr05

WHERE bname = sy-uname AND

parid = 'ZRD' AND

parva IN ( 'X', 'x' ) .

The problem u had in ur query is with SINGLE fields and u were passing that to a work area with more number of fields, in taht case u should use INTO CORRESPONDING.

Hope u r clear now.

Reard poinst and close the thread if ur problem got solved.

Message was edited by:

Judith Jessie Selvi

0 Kudos

The problem is solved ....

The need for 'x' is required as the part of the requirement

because user may type small x.

I was also thinking to convert to single * but want to know why the select run successfully.....May be bcoz some SAP constraints ...

Thanks Jessi..

0 Kudos

Hi,

SELECT SINGLE * FROM usr05

INTO wa_usr05

WHERE bname = sy-uname AND

parid = 'ZRD' AND

parva IN ( 'X', 'x' ) .

The problem u had in ur query is with SINGLE fields and u were passing that to a work area with more number of fields, in taht case u should use <b>INTO CORRESPONDING FIELDS OF.</b>

U can reward points, u have closed the thread by your self without rewarding points. U can say thansk by rewarding points.

Click on the star against the reply which u want to reward points.

Also close the thread.

Whenever u r opening a thread reward points and close the thread. It will encourage those who are replying.