‎2007 Nov 26 3:51 PM
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
‎2007 Nov 26 3:55 PM
You can define as many sorted table as want. No restrcition.
Regards,
Naimesh Patel
‎2007 Nov 26 3:54 PM
<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
‎2007 Nov 26 3:55 PM
You can define as many sorted table as want. No restrcition.
Regards,
Naimesh Patel
‎2007 Nov 26 4:06 PM
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
‎2007 Nov 26 4:08 PM
Hi
Thanks for the help.
also can you please tell me how to define an internal table which is sorted.
Deb
‎2007 Nov 26 4:10 PM
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.
‎2007 Nov 26 4:11 PM
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