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

problem in select

Former Member
0 Likes
1,341

Hi,

i have question:

what is the problem with this select.

select * from hrp1000

if sy-subrc is initial.

write'....'

endif.

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,309

U have to write select statement:

Either:

select * from hrp1000

if sy-subrc is initial.

write'....'

endif.

endselect.

OR:

select single * from hrp1000

if sy-subrc is initial.

write'....'

endif.

13 REPLIES 13
Read only

Former Member
0 Likes
1,309

HI,

Ricardo has written-


select * from hrp1000
if sy-subrc is initial.
write'....'
endif.

In this case you are selecting the records from table but not mentioning where to store that records, Thats why the problem occur.

You have to mention INTO Clause and the internal table name to store selected data.

like below-



data: itab type table of hrp1000.

select * from hrp1000 into table itab.
if sy-subrc = 0.
write'....'.
endif.

Here itab is the internal table of the type hrp1000.

Regards,

Sujit

Read only

0 Likes
1,309

Hi ,

Thanks ,

u think that into is the problem ,

what about sy-subrc it can be initial or just get 0 4 8 .?

Regards

Read only

naveen_inuganti2
Active Contributor
0 Likes
1,309

Hi....

There is no target area...

Declare one target variable.

or

use open cursor statement.

The correct similer statements are...

>select * from hrp1000 into corresponding fields of table itab.

>(here iatb with some fields of hrp1000)

&

>open cursor znav for select * from hrp1000.

>(here znav type cursor)

Thanks,

Naveen Inuganti.

Read only

Former Member
0 Likes
1,310

U have to write select statement:

Either:

select * from hrp1000

if sy-subrc is initial.

write'....'

endif.

endselect.

OR:

select single * from hrp1000

if sy-subrc is initial.

write'....'

endif.

Read only

0 Likes
1,309

Hi.. Chandra...

What about the target area.??

Thanks,

Naveen Inuganti.

Read only

0 Likes
1,309

hi chandra madapati ,

sorry but the select is like that:

select * from hrp1000
if sy-subrc is initial.
write'....'
endif.
endselect.

Regards

Read only

0 Likes
1,309

Hi

select * from hrp1000

if sy-subrc is initial.

write'....'

endif.

endselect.

in this condition.

sy-subrc value won't be ZERO.

that means it failed to get that data.

always SY-SUBRC is equal to ZERO only when above statement is correct other wise it will give 1 or 4 or 8 values

any thing you want from this.

Read only

0 Likes
1,309

hi,

it wont be infinite loop?

Regards

Read only

Former Member
0 Likes
1,309

Hello Ricardo,

If you don't use into clause then you should write ENDSELECT

after select.

or

Use select single.

These two are allowed only if work area hrp1000 is available.

Regards,

Subbu

Read only

Former Member
0 Likes
1,309

Hi,

U can do like this also.


Tables hrp1000.

select * from hrp1000.
  if sy-subrc is initial.
    write'....'
  endif.
endselect.

Regards,

Sunil Kumar M

Read only

former_member787646
Contributor
0 Likes
1,309

Hi

In your SQL the INTO clause is missing.

i.e, Where you want to save the fetched data which is a variable or work area or internal table?

Eg

select * from hrp1000 into wa.

if sy-subrc <> 0.

write'....'

endif.

or

select * from hrp1000 into table itab.

if sy-subrc <> 0.

write'....'

endif.

Hope it helps.

Murthy

select * from hrp1000

if sy-subrc is initial.

write'....'

endif.

Read only

former_member206439
Contributor
0 Likes
1,309

Hi

The main problem is you need to use INTO some internal table or work area.

you write a select statment with out where condition but needs a target location to store that results.

like this

select * from HRP1001 into table itab1.

in this case the total table values will be stored at itab1.

Regards

Naresh

Read only

Former Member
0 Likes
1,309

solved