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

If the following code results in a syntax error

Former Member
0 Likes
981

DATA: itab TYPE SORTED TABLE OF rec_type WITH UNIQUE KEY field1

WITH HEADER LINE.

itab-field1 = 'Company'. itab-field2 = '1234'. INSERT TABLE itab.

itab-field1 = 'Bank'. itab-field2 = 'ABC'. INSERT TABLE itab.

SORT itab.

LOOP AT itab.

write: /1 itab-field1, itab-field2.

ENDLOOP.

SELECT fld1 fld2 FROM tab1 WHERE fld3 = pfld3.

WRITE: /1 tab1-fld1, tab1-fld2.

ENDSELECT.

Message was edited by: kiran machavarapu

5 REPLIES 5
Read only

dani_mn
Active Contributor
0 Likes
845

HI,

your are trying to sort sorted table which is wrong.

you can't sort a sorted table because it is already sorted.

<b>yes it give a syntax error.</b>

delete the following line.

<b> SORT itab.</b>

REgards,

Read only

Former Member
0 Likes
845

What is your question?

REC_TYPE does not have a component called field1.

Read only

Former Member
0 Likes
845

Hi,

In your prgram field1 is not there in rec_type.

DATA: itab TYPE SORTED TABLE OF rec_type WITH UNIQUE KEY <b>field1</b>

WITH HEADER LINE.

itab-field1 = 'Company'. itab-field2 = '1234'. INSERT TABLE itab.

itab-field1 = 'Bank'. itab-field2 = 'ABC'. INSERT TABLE itab.

SORT itab.

LOOP AT itab.

write: /1 itab-field1, itab-field2.

ENDLOOP.

Thank you,

Ramu N

Read only

Former Member
0 Likes
845

for a sorted table,you no need to give SORT explicitly.by default all the records will be sorted based on the KEY you mention in the Definition.

i guess, you will get a syntax error if you SORT for a SORTED table.

Regards

srikanth

Read only

Former Member
0 Likes
845

HI,

REC_TYPE is a structure with fields RECESC TYPE.

So, it is throwing a syntax error.

Regards,

Sailaja.