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

Sorting Dynamic Table by specific field

Former Member
0 Likes
525

Hi guys,

I need to sort a dynamic table (without header line) by a certain field in order to achieve the client requierment. I really don't have any clue about how can i do this, because, it appears that is not possible to declarate a field symbol type standar table with a headerline...

Regards,

Eric

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
420

Hi

U can use:

SORT ITAB BY (FIELD).

Max

4 REPLIES 4
Read only

Former Member
0 Likes
421

Hi

U can use:

SORT ITAB BY (FIELD).

Max

Read only

0 Likes
420

Hi Max,

That's not possible because the table doesn't have a header line.

Regards,

Eric

Read only

0 Likes
420

Try this:

TABLES T001.

DATA: T_T001 LIKE STANDARD TABLE OF T001.

FIELD-SYMBOLS: <TABLE> TYPE TABLE.

DATA: FIELD1(30),
      FIELD2(30),
      FIELD3(30).

SELECT * FROM T001 INTO TABLE T_T001.

ASSIGN T_T001[] TO <TABLE>.

FIELD1 = 'BUTXT'.

SORT <TABLE> BY (FIELD1) (FIELD2) (FIELD3).

LOOP AT <TABLE> INTO T001.
  WRITE: / T001-BUTXT, T001-BUKRS.
ENDLOOP.

U have to decide how many fields can be used to sort the table: in my example I suppose the user can use max 3 fields in the same time.

The ALV use this way to sort the table.

Max

Read only

0 Likes
420

Hi Max,

Thanks a lot.

Regards,

Eric