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

Internal table query

Former Member
0 Likes
629

Hi All

Can you tell me how I can check whether an internal table is defined as Sorted. Is it possible to mention every internal table as sorted or there is some criterion that has to be met.

Thanks for the info

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
609

You can define as many sorted table as want. No restrcition.

Regards,

Naimesh Patel

6 REPLIES 6
Read only

Former Member
0 Likes
609

<b>Sorted tables</b>

This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.

Check this link for more details.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm

http://www.sap-img.com/abap/what-are-different-types-of-internal-tables-and-their-usage.htm

hope this Helps.

A

Read only

naimesh_patel
Active Contributor
0 Likes
610

You can define as many sorted table as want. No restrcition.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
609

To determine the type of table, use the DESCRIBE statement. From the Help:

TYPE-POOLS: SYDES. 
... 
FORM GENERIC_FORM USING ITAB TYPE ANY TABLE. 
  DATA: K TYPE C. 
  DESCRIBE TABLE ITAB KIND K. 
  CASE K. 
    WHEN SYDES_KIND-STANDARD. 
      ... 
    WHEN SYDES_KIND-SORTED. 
      ... 
    WHEN SYDES_KIND-HASHED. 
      ... 
  ENDCASE. 
ENDFORM. 

Rob

Read only

Former Member
0 Likes
609

Hi

Thanks for the help.

also can you please tell me how to define an internal table which is sorted.

Deb

Read only

0 Likes
609
DATA: BEGIN OF line,
        land(3)  TYPE c,
        name(10) TYPE c,
        age      TYPE i,
        weight   TYPE p DECIMALS 2,
      END OF line.

DATA itab LIKE SORTED TABLE OF line WITH NON-UNIQUE KEY land.

OR

TYPES: spfli_sort TYPE SORTED TABLE OF spfli 
       WITH UNIQUE KEY carrid connid.
Read only

0 Likes
609
TYPES: BEGIN OF TY_MARA,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
END OF TY_MARA.

DATA: IT_MARA TYPE SORTED TABLE OF TY_MARA.

Regards,

Naimesh Patel