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

Code error!!

Former Member
0 Likes
815

Hi All,

Can Anybody let me know what this code is supposed to do and it shows me an error with the INDEX, so please help me out.

DATA: BEGIN OF T_KNVV OCCURS 0.

INCLUDE STRUCTURE KNVV.

DATA: END OF T_KNVV.

DATA: BEGIN OF T_KNC1 OCCURS 0.

INCLUDE STRUCTURE KNC1.

DATA: END OF T_KNC1.

LOOP AT T_KNVV.

SELECT * FROM KNC1

INTO T_KNC1

ORDER BY GJAHR DESCENDING.

READ table T_KNC1 INDEX = 1.

IF T_KNC1-GJAHR GT SO_GJAHR.

EXIT.

ELSE.

ENDIF.

ENDLOOP.

Thanks!!

6 REPLIES 6
Read only

Former Member
0 Likes
789

<b>READ table T_KNC1 INDEX 1.</b>

Don't mention as INDEX = 1.

Reward if its useful.

Regards,

Sail

Read only

0 Likes
789

It says that the SELECT SINGLE statement cannot contain the clause ORDER BY.

Read only

0 Likes
789

If there is any SELECT SINGLE statement it will fetch only 1 record so there is no need to mention ORDER BY . If it throws an syntax error it is correct.

ORDER BY is nothing but SORT. If there is only 1 record then no need to sort it right

Read only

0 Likes
789

but waht i need is to select all the records and read the ones which meet the select criteria...

so how do i write it

Read only

0 Likes
789

1)Better put all the conditons in where conditon of select single statement.

2)Otherwise put all data into internal table & then filter it.

1st option is good.

Reward for useful answers.

Regards,

Sail

Read only

Former Member
0 Likes
789

Hi,

DATA: BEGIN OF T_KNVV OCCURS 0.

INCLUDE STRUCTURE KNVV.

DATA: END OF T_KNVV.

DATA: BEGIN OF T_KNC1 OCCURS 0.

INCLUDE STRUCTURE KNC1.

DATA: END OF T_KNC1.

SELECT * FROM KNC1 INTO TABLE T_KNC1 for all entries in T_KNVV

where GJAHR GT SO_GJAHR

Regards

Sudheer