2019 May 29 12:39 PM
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?
2019 May 30 10:19 AM
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?
2019 May 29 5:22 PM
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.
2019 May 30 8:39 AM
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.
2019 May 30 10:19 AM
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
2019 May 30 10:55 AM
2019 May 30 7:15 PM
Could you possibly change the font in the question? I almost had a heart attack when the tab opened...
2019 May 31 8:20 AM
I'm sorry about the font. I am not sure how I should change it.
2019 May 31 8:25 AM
2019 May 31 4:05 PM
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.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |