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

alv display

Former Member
0 Likes
2,581

I've made a table and I want to display the table in alv where it'll show additional column , if the age is less than 5 it should display a5 in the field or if the age is between 5 to 10 it should display a10 and so on. do I have to write loop and where condition?

1 ACCEPTED SOLUTION
Read only

former_member288834
Participant
2,413

Hi Bhavana,

Refer below basic logic, also attached output.

TYPES :
BEGIN OF ty_age,
age TYPE i,
text TYPE char4,
END OF ty_age.

DATA :
it_age TYPE TABLE OF ty_age,
wa_age TYPE ty_age.

wa_age-age = 4.
APPEND wa_age TO it_age.

wa_age-age = 10.
APPEND wa_age TO it_age.

wa_age-age = 12.
APPEND wa_age TO it_age.


LOOP AT it_age INTO wa_age.
IF wa_age-age BETWEEN 0 AND 4.
CONCATENATE 'a' '4' INTO wa_age-text.
ELSEIF wa_age-age BETWEEN 5 AND 10.
CONCATENATE 'a' '5' INTO wa_age-text.
ELSEIF wa_age-age BETWEEN 11 AND 15.
CONCATENATE 'a' '10' INTO wa_age-text.
ENDIF.
MODIFY it_age FROM wa_age TRANSPORTING text.

ENDLOOP.

LOOP AT it_age INTO wa_age.
WRITE : / , wa_age-age, space, wa_age-text.
ENDLOOP.

Regards

Guru Prasad.output.png

I've made a table and I want to display the table in alv where it'll show additional column , if the age is less than 5 it should display a5 in the field or if the age is between 5 to 10 it should display a10 and so on. do I have to write loop and where condition?

8 REPLIES 8
Read only

former_member288834
Participant
0 Likes
2,413

Hi Bhavana,

You need to have one extra field in your output internal table which will be used to display ALV, and write the logic inside LOOP.. END LOOP and update the extra field.

Regards

Guru Prasad.

Read only

0 Likes
2,413

Thank you for your response.

I tried writing logic inside the loop but it is not displaying anything in the added field.

Can you please share the logic? I also tried to use modify statement but it is still not working.

I am still a beginner and I googled it but I am still confused.

Read only

former_member288834
Participant
2,414

Hi Bhavana,

Refer below basic logic, also attached output.

TYPES :
BEGIN OF ty_age,
age TYPE i,
text TYPE char4,
END OF ty_age.

DATA :
it_age TYPE TABLE OF ty_age,
wa_age TYPE ty_age.

wa_age-age = 4.
APPEND wa_age TO it_age.

wa_age-age = 10.
APPEND wa_age TO it_age.

wa_age-age = 12.
APPEND wa_age TO it_age.


LOOP AT it_age INTO wa_age.
IF wa_age-age BETWEEN 0 AND 4.
CONCATENATE 'a' '4' INTO wa_age-text.
ELSEIF wa_age-age BETWEEN 5 AND 10.
CONCATENATE 'a' '5' INTO wa_age-text.
ELSEIF wa_age-age BETWEEN 11 AND 15.
CONCATENATE 'a' '10' INTO wa_age-text.
ENDIF.
MODIFY it_age FROM wa_age TRANSPORTING text.

ENDLOOP.

LOOP AT it_age INTO wa_age.
WRITE : / , wa_age-age, space, wa_age-text.
ENDLOOP.

Regards

Guru Prasad.output.png

Read only

0 Likes
2,413

Thankyou this was helpful.

Read only

Jelena_Perfiljeva
Active Contributor
2,413

Could you possibly change the font in the question? I almost had a heart attack when the tab opened...

Read only

Former Member
0 Likes
2,413

I'm sorry about the font. I am not sure how I should change it.

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,413

I had to de-zoom at 33% to be able to read your question !

Read only

claudiapacheco
Product and Topic Expert
Product and Topic Expert
2,413

Sorry for the inconvenience. I was able to remove the format of your text by using a plain text editor. I'll bring this up with IT.