Application Development 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: 

how do i get the index of data from itab without using read and loop with condition number = 6?

former_member835368
Discoverer
0 Kudos
438
Hallo folks, how do i get the index of data from sorted itab (initial_data) without using read and loop with condition number = 6?

TYPES group TYPE c LENGTH 1.
  
TYPES: BEGIN OF initial_type,
group TYPE group,
number TYPE i,
description TYPE string,
END OF initial_type,
itab_data_type TYPE STANDARD TABLE OF initial_type WITH EMPTY KEY.
DATA: initial_data TYPE itab_data_type.
initial_data = VALUE itab_data_type(
( group = 'A' number = 10 description = 'Group A-2' )
( group = 'B' number = 5 description = 'Group B' )
( group = 'A' number = 6 description = 'Group A-1' )
( group = 'C' number = 22 description = 'Group C-1' )
( group = 'A' number = 13 description = 'Group A-3' )
( group = 'C' number = 500 description = 'Group C-2' )
( group = 'A' number = 19 description = 'Group A-4' )
).
SORT initial_data BY group ASCENDING number DESCENDING.

cl_demo_output=>display_data( initial_data[] ).

Thanks ini advance,

Jalskyyy

2 REPLIES 2

Former Member
0 Kudos
399

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with: https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.

For example, you can:

- only use the "insert code" feature for code
- outline what steps you took to find answers (and why they weren't helpful)

- share screenshots of what you've seen/done

- make sure you've applied the appropriate tags

- use a more descriptive subject line

The more details you provide, the more likely it is that members will be able to respond. Feel free to also take our Q&A tutorial at: https://developers.sap.com/tutorials/community-qa.html

Should you wish, you can revise your question by selecting Actions, then Edit.

By adding a picture to your profile you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html

Questions on how to draw responses from members? Check out this discussion on how to improve questions. https://groups.community.sap.com/t5/welcome-corner-discussions/advice-from-sap-champions-questions-a...

Sandra_Rossi
Active Contributor
399

Not sure how it's related to the manual "sort" you did, but without any sort consideration, I guess the below code must be the answer you are looking for:

data(index) = line_index( initial_data[ number = 6 ] ).