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

Nested sorted/hashed table

Former Member
0 Likes
821

Hi everyone

Could any body give right solution for my doubt below

1)I would like to create a nested sorted /hashed table

This is what i tried

TYPES : BEGIN OF tt_sflight,

carrid TYPE sflight-carrid,

connid TYPE sflight-connid,

fldate TYPE sflight-fldate,

price TYPE sflight-price,

END OF tt_sflight.

DATA it_sflight TYPE STANDARD TABLE OF tt_sflight INITIAL SIZE 2 WITH KEY carrid connid fldate .

DATA jt_sflight LIKE SORTED TABLE OF it_sflight WITH NON-UNIQUE KEY carrid connid fldate

This gives an error

A table without a header line has no components and therefore no component called "CARRID".

I understand while using "with header line" line type cant be a table type.

So does that means a nested sorted table/hashed table is out of question?U cant create one???

please answer this

1 ACCEPTED SOLUTION
Read only

vinod_vemuru2
Active Contributor
0 Likes
691

Hi,

When you use LIKE you should refer to the line TYPE (When your internal table doesn't have header line, system can't recognize the fields). Below are different solutions.

Solution 1: Create line type and refer to that.

DATA it_sflight TYPE STANDARD TABLE OF tt_sflight INITIAL SIZE 2 WITH KEY carrid connid fldate .
DATA: lwa_sflight TYPE tt_sflight.  "Line type/work area
DATA jt_sflight LIKE SORTED TABLE OF lwa_sflight WITH NON-UNIQUE KEY carrid connid fldate.

Solution 2: Use TYPE and refer to TYPEs definition

DATA it_sflight TYPE STANDARD TABLE OF tt_sflight INITIAL SIZE 2 WITH KEY carrid connid fldate .
DATA jt_sflight TYPE SORTED TABLE OF tt_sflight WITH NON-UNIQUE KEY carrid connid fldate.

Check F1 help for more details.

Thanks,

Vinod.

4 REPLIES 4
Read only

Former Member
0 Likes
691

You should use WITH key and INITIAL SIZE satementst with types, while declaring your structure.

For example

TYPES dtype { {TYPE tabkind OF [REF TO] type}

| {LIKE tabkind OF dobj} }

[WITH key] [INITIAL SIZE n].

For more details read F1 help of DATA and TYPES statement.

Read only

vinod_vemuru2
Active Contributor
0 Likes
692

Hi,

When you use LIKE you should refer to the line TYPE (When your internal table doesn't have header line, system can't recognize the fields). Below are different solutions.

Solution 1: Create line type and refer to that.

DATA it_sflight TYPE STANDARD TABLE OF tt_sflight INITIAL SIZE 2 WITH KEY carrid connid fldate .
DATA: lwa_sflight TYPE tt_sflight.  "Line type/work area
DATA jt_sflight LIKE SORTED TABLE OF lwa_sflight WITH NON-UNIQUE KEY carrid connid fldate.

Solution 2: Use TYPE and refer to TYPEs definition

DATA it_sflight TYPE STANDARD TABLE OF tt_sflight INITIAL SIZE 2 WITH KEY carrid connid fldate .
DATA jt_sflight TYPE SORTED TABLE OF tt_sflight WITH NON-UNIQUE KEY carrid connid fldate.

Check F1 help for more details.

Thanks,

Vinod.

Read only

0 Likes
691

Thanks Vinod...

Read only

Former Member
0 Likes
691

..