2023 Jan 03 3:48 PM
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
2023 Jan 03 3:50 PM
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...
2023 Jan 03 4:00 PM
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 ] ).