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: 

select statement

Former Member
0 Kudos

wresult is the internal table which i have uploaded from local file,

wresult has some records in it.

i have to compare the records in it with the standard table say draw.

but it doesnt work.....

LOOP AT wresult .

SELECT single * FROM draw

WHERE dokar EQ wresult-dokar

and doknr EQ wresult-doknr

and dokvr EQ wresult-dokvr.

IF sy-subrc EQ 0.

write: / 'Success'.

endif.

endloop.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Check for the below two conditions.

1)The fields in the internal table should of same type that you are using for fetching the data from the table draw by using select query.

2)Whether the data is present in the table draw for the records in the internal table

write the code as follows and check again

LOOP AT wresult .

SELECT single * FROM draw

WHERE dokar EQ wresult-dokar

and doknr EQ wresult-doknr

and dokvr EQ wresult-dokvr.

IF sy-subrc EQ 0.

write: / 'Success'.

else.

write:/ 'Failure'.

endif.

endloop.

10 REPLIES 10

Former Member
0 Kudos

Database table DRAW can have multiple records for entered conditions. Please check.

Regards,

Aparna Gaikwad

0 Kudos

no aparna it has single record for the primary key like doknr

Former Member
0 Kudos

Hi,

Go with for all entries. So your select query would be as follows :


Data :
  t_draw like standard table of DRAW.
SELECT * FROM draw
    into t_draw
  for all entries in wresult
WHERE dokar EQ wresult-dokar
and doknr EQ wresult-doknr
and dokvr EQ wresult-dokvr.

Regards,

Swapna.

Former Member
0 Kudos

Hi,

What Error message are you getting?

Place an into addition to the Select Query.

Check the Internal table if it has fileds which you are comparing.

Regards

Sumit Agarwal

Former Member
0 Kudos

Hi,

Can you please throw some light on how you declared the internal table? is it with header line?

Regards,

Surinder

Former Member
0 Kudos

Hi,

Remove one or more conditions to check which condition is getting failed..

Regards

Mudit

Former Member
0 Kudos

Hi,

Check for the below two conditions.

1)The fields in the internal table should of same type that you are using for fetching the data from the table draw by using select query.

2)Whether the data is present in the table draw for the records in the internal table

write the code as follows and check again

LOOP AT wresult .

SELECT single * FROM draw

WHERE dokar EQ wresult-dokar

and doknr EQ wresult-doknr

and dokvr EQ wresult-dokvr.

IF sy-subrc EQ 0.

write: / 'Success'.

else.

write:/ 'Failure'.

endif.

endloop.

Former Member
0 Kudos

Hi,

Use another internal table and use for all entries.

TABLES:
  draw.
DATA:
  ITAB like table of draw.
SELECT  * 
   FROM draw
     INTO itab
for all entries in wresult
WHERE dokar EQ wresult-dokar
and doknr EQ wresult-doknr
and dokvr EQ wresult-dokvr.

With luck,

Pritam.

Former Member
0 Kudos

To use the default workarea you need to use the below statement.

Tables : Draw.

Former Member
0 Kudos

Hi,

First, You should not use select statement in a loop because of performance issues, you can do like that,

select * DRAW into it_draw from DREW

for all entries in wresult

WHERE dokar EQ wresult-dokar

AND doknr EQ wresult-doknr

AND dokvr EQ wresult-dokvr.

loop at wresult into wa_result,

read table it_drew into wa_drew with key dokar EQ wa_drew-dokar

AND doknr EQ wresult-doknr

AND dokvr EQ wresult-dokvr.

IF sy-subrc EQ 0.

write: / 'Success'.

endif.

endloop.