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

select statement

Former Member
0 Likes
1,225

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
Read only

Former Member
0 Likes
1,171

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
Read only

Former Member
0 Likes
1,171

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

Regards,

Aparna Gaikwad

Read only

0 Likes
1,171

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

Read only

Former Member
0 Likes
1,171

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.

Read only

Former Member
0 Likes
1,171

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

Read only

Former Member
0 Likes
1,171

Hi,

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

Regards,

Surinder

Read only

Former Member
0 Likes
1,171

Hi,

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

Regards

Mudit

Read only

Former Member
0 Likes
1,172

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.

Read only

Former Member
0 Likes
1,171

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.

Read only

Former Member
0 Likes
1,171

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

Tables : Draw.

Read only

Former Member
0 Likes
1,171

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.