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

REUSE_ALV_GRID_DISPLAY - Count functionality

Former Member
0 Likes
1,978

Hello all,

I have used REUSE_ALV_GRID_DISPLAY in one of my ALV report. My requirement is to activate the Count functionality seen under


Edit -> Calculate -> Count

Right now this count is greyed out. How can we activate it?

Thanks

14 REPLIES 14
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,693

Ok, I checked in my Netweaver system, and it does appear there, but you need to turn it on. It appears that you can do so using the IS_layout parameter. Set the COUNTFNAME field to 'X' and pass the layout parameter to the function call.

Regards

Rich Heilman

Read only

0 Likes
1,693

Folks,

I am still unable to figure this out.

Could someone help me out with this.

THanks

Read only

0 Likes
1,693

Sorry, try to fille the COUNTFNAME with a valid field name from your internal table.

Regards,

Rich Heilman

Read only

aakash_neelaperumal2
Active Participant
0 Likes
1,693

do u have a PF status for the ALV

Read only

0 Likes
1,693

Aakash,

No, I do not.

Read only

0 Likes
1,693

See this example, works good in my system.



REPORT  zrich_0001.


* Global ALV Data Declarations
TYPE-POOLS: slis.

* Internal Tables
DATA: BEGIN OF ialv OCCURS 0,
      test1(10) TYPE c,
      test2(10) TYPE c,
      count TYPE i,                        "<-----  HERE
      END OF ialv.

DATA: fieldcat  TYPE slis_t_fieldcat_alv.
DATA: layout    TYPE slis_layout_alv.

START-OF-SELECTION.

  PERFORM get_data.
  PERFORM call_alv.

*********************************************************************
*      Form  GET_DATA
*********************************************************************
FORM get_data.

  ialv-test1 = 'ABC'.
  ialv-test2 = 'DEF'.
  ialv-count = '1'.                 "<-----  HERE
  APPEND ialv.

  ialv-test1 = 'GHI'.
  ialv-test2 = 'JKL'.
  ialv-count = '1'.                "<-----  HERE
  APPEND ialv.


  ialv-test1 = '123'.
  ialv-test2 = '456'.
  ialv-count = '1'.                   "<-----  HERE
  APPEND ialv.


ENDFORM.                    "GET_DATA

************************************************************************

*  CALL_ALV
************************************************************************

FORM call_alv.

  PERFORM build_field_catalog.

layout-countfname = 'COUNT'.              "<-----  HERE

* Call ABAP List Viewer (ALV)
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      is_layout    = layout
      it_fieldcat  = fieldcat
    TABLES
      t_outtab     = ialv.

ENDFORM.                    "CALL_ALV

************************************************************************

* BUILD_FIELD_CATALOG
************************************************************************

FORM build_field_catalog.


  CLEAR: fieldcat. REFRESH: fieldcat.

  DATA: tmp_fc TYPE slis_fieldcat_alv.

  tmp_fc-reptext_ddic = 'Test1'.
  tmp_fc-fieldname    = 'TEST1'.
  tmp_fc-tabname      = 'IALV'.
  tmp_fc-outputlen    = '10'.
  APPEND tmp_fc TO fieldcat.

  tmp_fc-reptext_ddic = 'Test2'.
  tmp_fc-fieldname    = 'TEST2'.
  tmp_fc-tabname      = 'IALV'.
  tmp_fc-outputlen    = '10'.
  APPEND tmp_fc TO fieldcat.


ENDFORM.                    "BUILD_FIELD_CATALOG

On the output, you can now choose the "Count" option from the menu.

Regards,

Rich HEilman

Read only

0 Likes
1,693

Even if you would not fill the COUNT field in your internal table, the total line would still show 3 as the total count of lines. So comment out the lines which fill the COUNT field when building the internal table in the sample program, and see that the count function works.

Regards,

Rich Heilman

Read only

0 Likes
1,693

I tried your sample code. Initially we would see only two columns. Thats good. When I go with Count we will get Count column as extra (we see 3 columns now) and we see the count in the count column. Makes sense.

But what I was thinking is we would select any one column and press the count in menu and we would get the count in the same coulmn at the bottom. I don't know if this is possible. What do you think Rich?

I tried something like this earlier.

I have a MENGE column in the output which has sub totals. I gave MENGE to layout-countfname and I got the count properly but subtotals were missing in this column. So I think its not good to pass columns which have totals to layout-countfname as it may disturb the totals.

Read only

0 Likes
1,693

sounds like I have answered my own question in my last reply.

bottom line is I think your idea makes sense Rich. I gotto have a seperate column for count in order to not to disturb other columns.

do you have any other ideas other than this approach Rich?

Read only

0 Likes
1,693

Not sure if that is the suggested funtionality, meaning, not sure if that is how they meant it to work, I've been playing with it, and the more I do, the less I like it. I find it a little miss leading. Why do you require this functionality?

Regards

Rich HEilman

Read only

0 Likes
1,693

I dont know I am waiting for more information from my functional guy. Earlier he just asked to activate the Count in menu. Thats how all this mess started.

Also, one more think what I observed is if you go wtih Count for the second time in your approach the count column disappears. So it is not a good idea to pass the actual internal table fields to layout-coutnfname as there is chance of them disappearing.

Your earlier approach with seperate column for Count makes more sense to me.

Read only

0 Likes
1,693

Ohhhhhh....... and a little buggy. Yikes.

Regards,

Rich Heilman

Read only

0 Likes
1,693

I have a requirement for the same functionality

I have a report which shows the employee absences for a month

so you have an alv with in every row an employee number and in the colums all the days of a month

every day can be filled with nothing, an absence or workschedule parameter

now an projectmanager sees the list and wants to know how many employees are available on a certain day and how many are absent.

If I can use count as the requirment is also above then the column would seperate all the possibilities

like

10 available

5 abscent

2 ill

still looking for a solution

kind regards

arthur de smidt

Read only

0 Likes
1,693

I followed Rich's advice above and this worked perfectly for me. It was the solution I was looking for.

Thanks for the help Rich!

Regards,

Robin.