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

logic in internal table

Former Member
0 Likes
523

friends,

i have an int. table which has one col. with long text...the text's value of every row can vary, from a letter to a max of 72 characters...now, i want to find the row that has the max. length (in the below case, it's 5 th row - strlen is 13)...is there any command to retrieve the max length of a col. in int table...i don't want to compute each and every row's strlen and compare vs. the next row...any helpful answer will be rewarded...thanks all

tdname

ABCDE

ABCDEFG

ABC

ABCDEFGHI

ABCDEFGHIJKLM

cheers,

Sathish. R

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
501

Regards,

MB

Message was edited by:

M B

friends,

i have an int. table which has one col. with long text...the text's value of every row can vary, from a letter to a max of 72 characters...now, i want to find the row that has the max. length (in the below case, it's 5 th row - strlen is 13)...is there any command to retrieve the max length of a col. in int table...i don't want to compute each and every row's strlen and compare vs. the next row...any helpful answer will be rewarded...thanks all

tdname

ABCDE

ABCDEFG

ABC

ABCDEFGHI

ABCDEFGHIJKLM

cheers,

Sathish. R

3 REPLIES 3
Read only

Former Member
0 Likes
501

Hi!

You can solve it somhow like this:


DATA: gv_length TYPE i, gv_max TYPE i.
CLEAR gv_length. CLEAR gv_max.
LOOP AT itab INTO wa.
  gv_length = strlen(wa-text).
  IF gv_lenght > gv_max.
    gv_max = gv_length.
  ENDIF.
ENDLOOP.

Unfortunately there is no other way, I think it at least...

Regards

Tamá

Read only

Former Member
0 Likes
502

Regards,

MB

Message was edited by:

M B

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
501

Hi,

May be you can sort your internal table by that field where you have the text and with the option AS TEXT, and I think then the field with most number of character will be last in the but works only if there is only one field with this maximum length.

Regards,

Sesh