Application Development 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: 

ALV-Grid: How to display the number of lines that a sum consists of

Former Member
0 Kudos

Dear experts,

I'm dealing with the following user request:

in every total/subtotal line of an ALV-Grid the number of lines that went into the sum are supposed to be displayed.

In detail the question referred to a reports output, in which a currency related amount is displayed, automatically separated into the totals for every currency (generally around 10-15 different currencies). For every amount/currency combination the user would like to know how many single lines it consists of. I already tried to solve this with an artificial "counter"-field (INT4) which is initially set to "1" for every line, so that the user can do a sum on this field. In order to have those line counter sums for all the different currencies separately I added a reference to the currency field in the field catalogue (lvc_s_fcat-cfieldname). This seems to work so far, but now the linecounter value is displayed like a currency amount and apparently I cannot suppress that by setting lvs_s_fcat-NO_CONVEXT. This I cannot (respectively don't want to) offer to my customer. Does anybody know how to achieve this a bit more elegantly? Doesn't the ALV offer something for that? I couldn't find anything.

Thanks in advance

Andreas

2 REPLIES 2

Former Member
0 Kudos

*....Suppose your final internal table is like this.

Begin of itab occurs 0,

keyfield,

curr,

amt,

count,

end of itab.

data: cnt(3) type n.

sort itab1 by keyfield curr.

*......loop at source internal table where actual data lies.

loop at itab1.

cnt = cnt + 1.

at end of curr.

sum.

move-corresponding itab1 to itab.

itab-count = cnt.

clear cnt.

endat.

endloop.

*.....finally display itab using ALV.

0 Kudos

Dear Mr. Chandrasekhar,

thanks for your appreciated input !

I agreed with my customer to deliver the extra "linecounter"-field without a reference to the currency.

Thus it requires to define an appropriate sort in order to get the figures (in my example case on the currency),

but at least it is possible to get the desired information, properly formatted and without additional programming.

I granted points for your answer and will set the question as answered.

best regards

Andreas