2009 Jul 31 8:34 AM
Hi ,
Could you please tell me how to declare a sorted internal table of type sy-uname.
Is there any different method to read sorted internal table than we normally do?
Please suggest.
Thanks,
Suchi.
2009 Jul 31 8:37 AM
Hi Suchi,
Check the below link.
http://help.sap.com/saphelp_nw70/helpdata/EN/fc/eb3800358411d1829f0000e829fbfe/content.htm
You can use Binary search on sorted internal table.
Search forum on how to use Binary search and its importance.
REPORT YSK_TEST_SORT.
TYPES: BEGIN OF T_TAB,
UNAME TYPE SY-UNAME,
END OF T_TAB.
TYPES: TT_TAB TYPE SORTED TABLE OF T_TAB WITH UNIQUE KEY UNAME.
DATA: IT_TAB TYPE TT_TAB,
WA_TAB TYPE T_TAB.
WA_TAB-UNAME = 'ZZZZ'.
INSERT WA_TAB INTO TABLE IT_TAB.
WA_TAB-UNAME = 'ABCD'.
INSERT WA_TAB INTO TABLE IT_TAB.
LOOP AT IT_TAB INTO WA_TAB.
WRITE:/ WA_TAB-UNAME.
ENDLOOP.Thanks,
Sreekanth
Hi ,
Could you please tell me how to declare a sorted internal table of type sy-uname.
Is there any different method to read sorted internal table than we normally do?
Please suggest.
Thanks,
Suchi.
2009 Jul 31 8:37 AM
Hi Suchi,
Check the below link.
http://help.sap.com/saphelp_nw70/helpdata/EN/fc/eb3800358411d1829f0000e829fbfe/content.htm
You can use Binary search on sorted internal table.
Search forum on how to use Binary search and its importance.
REPORT YSK_TEST_SORT.
TYPES: BEGIN OF T_TAB,
UNAME TYPE SY-UNAME,
END OF T_TAB.
TYPES: TT_TAB TYPE SORTED TABLE OF T_TAB WITH UNIQUE KEY UNAME.
DATA: IT_TAB TYPE TT_TAB,
WA_TAB TYPE T_TAB.
WA_TAB-UNAME = 'ZZZZ'.
INSERT WA_TAB INTO TABLE IT_TAB.
WA_TAB-UNAME = 'ABCD'.
INSERT WA_TAB INTO TABLE IT_TAB.
LOOP AT IT_TAB INTO WA_TAB.
WRITE:/ WA_TAB-UNAME.
ENDLOOP.Thanks,
Sreekanth
2009 Jul 31 8:49 AM
hi Sucharita,
try this code,
Types: begin of ty_uname,
uname type syuname,
field1 type field1,
field2 type field2,
field3 type field3,
end of ty_uname.
data itab type sorted table of ty_uname .
Also you dont need any other way to read this type of internal table.
There is no need of Binary search as it is used by default.
Regards,
Sumesh Nair
2009 Jul 31 9:42 AM
Hi,
DATA : BEGIN OF gs_uname ,
uname TYPE syuname ,
END OF gs_uname.
DATA : gt_uname LIKE SORTED TABLE OF gs_uname WITH HEADER LINE
WITH UNIQUE KEY uname.
" insert
gs_uname-uname = sy-uname.
INSERT gs_uname INTO TABLE gt_uname.
" read with key
READ TABLE gt_uname WITH TABLE KEY uname = sy-uname.Edited by: Hüseyin Dereli on Jul 31, 2009 12:00 PM
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |