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: 

Dynamic table and Grid ALV

Former Member
0 Kudos
193

I have a problem with sum function in ALV. I'm using function REUSE_ALV_GRID_DISPLAY with dynamic created table and I can't use sum. I don't have sum sign in toolbar. 'X' on do_sum in field catalog don't working neither. Anybody help me?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
75

It's example code ! When I start this program I don't see SUM icon i toolbar! Why?

REPORT ZKM_TESTOWY no standard page heading.

type-pools: slis.

field-symbols: <dyn_table> type standard table,

<dyn_wa>.

data: alv_fldcat type slis_t_fieldcat_alv,

it_fldcat type lvc_t_fcat.

data: wa_cat like line of alv_fldcat.

data: gv_fldname(20) type c.

data: index(3) type c.

selection-screen begin of block b1 with frame title text-001.

parameters: p_check type c.

selection-screen end of block b1.

start-of-selection.

perform build_dyn_itab.

perform build_report.

do 10 times.

MOVE sy-index TO index.

clear wa_cat.

concatenate 'FIELD' index into

gv_fldname .

condense gv_fldname no-gaps.

wa_cat-fieldname = gv_fldname.

wa_cat-seltext_s = gv_fldname.

wa_cat-outputlen = '5'.

append wa_cat to alv_fldcat.

enddo.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

it_fieldcat = alv_fldcat

tables

t_outtab = <dyn_table>.

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

  • Build_dyn_itab

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

form build_dyn_itab.

data: new_table type ref to data,

new_line type ref to data,

wa_it_fldcat type lvc_s_fcat.

  • Create fields

clear index.

do 10 times.

index = sy-index.

clear wa_it_fldcat.

concatenate 'Field' index into

wa_it_fldcat-fieldname .

condense wa_it_fldcat-fieldname no-gaps.

wa_it_fldcat-datatype = 'MATNR'.

  • wa_it_fldcat-intlen = 5.

append wa_it_fldcat to it_fldcat .

enddo.

  • Create dynamic internal table and assign to FS

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = it_fldcat

importing

ep_table = new_table.

assign new_table->* to <dyn_table>.

  • Create dynamic work area and assign to FS

create data new_line like line of <dyn_table>.

assign new_line->* to <dyn_wa>.

endform.

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

  • Form build_report

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

form build_report.

data: fieldname(20) type c.

data: fieldvalue(5) type c.

data: index(3) type c.

field-symbols: <fs1>.

data: new_table type ref to data,

wa_it_fldcat type lvc_s_fcat.

do 10 times.

index = sy-index.

  • Set up fieldname

concatenate 'FIELD' index into

fieldname .

condense fieldname no-gaps.

  • Set up fieldvalue

concatenate '66' index into

fieldvalue.

condense fieldvalue no-gaps.

assign component fieldname of structure <dyn_wa> to <fs1>.

<fs1> = fieldvalue.

enddo.

  • Append to the dynamic internal table

append <dyn_wa> to <dyn_table>.

endform.

6 REPLIES 6

FredericGirod
Active Contributor
0 Kudos
75

I have used ALV Grid & dynamic table without problem (Object). Maybe if you cut past your code that will be more easy.

Regards

Frédéric

andreas_mann3
Active Contributor
0 Kudos
75

Hi,

check your fields to sum :

have they type p or dec ?

regards Andreas

0 Kudos
75

If you fields are not of a "numeric" type, then you must make it so in the field catalog.

TMP_CAT-DATATYPE = 'QUAN'.

Added this line of code to that field in the field catalog will allow you do see the sum on the total line.

Regards,

Rich Heilman

Former Member
0 Kudos
76

It's example code ! When I start this program I don't see SUM icon i toolbar! Why?

REPORT ZKM_TESTOWY no standard page heading.

type-pools: slis.

field-symbols: <dyn_table> type standard table,

<dyn_wa>.

data: alv_fldcat type slis_t_fieldcat_alv,

it_fldcat type lvc_t_fcat.

data: wa_cat like line of alv_fldcat.

data: gv_fldname(20) type c.

data: index(3) type c.

selection-screen begin of block b1 with frame title text-001.

parameters: p_check type c.

selection-screen end of block b1.

start-of-selection.

perform build_dyn_itab.

perform build_report.

do 10 times.

MOVE sy-index TO index.

clear wa_cat.

concatenate 'FIELD' index into

gv_fldname .

condense gv_fldname no-gaps.

wa_cat-fieldname = gv_fldname.

wa_cat-seltext_s = gv_fldname.

wa_cat-outputlen = '5'.

append wa_cat to alv_fldcat.

enddo.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

it_fieldcat = alv_fldcat

tables

t_outtab = <dyn_table>.

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

  • Build_dyn_itab

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

form build_dyn_itab.

data: new_table type ref to data,

new_line type ref to data,

wa_it_fldcat type lvc_s_fcat.

  • Create fields

clear index.

do 10 times.

index = sy-index.

clear wa_it_fldcat.

concatenate 'Field' index into

wa_it_fldcat-fieldname .

condense wa_it_fldcat-fieldname no-gaps.

wa_it_fldcat-datatype = 'MATNR'.

  • wa_it_fldcat-intlen = 5.

append wa_it_fldcat to it_fldcat .

enddo.

  • Create dynamic internal table and assign to FS

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = it_fldcat

importing

ep_table = new_table.

assign new_table->* to <dyn_table>.

  • Create dynamic work area and assign to FS

create data new_line like line of <dyn_table>.

assign new_line->* to <dyn_wa>.

endform.

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

  • Form build_report

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

form build_report.

data: fieldname(20) type c.

data: fieldvalue(5) type c.

data: index(3) type c.

field-symbols: <fs1>.

data: new_table type ref to data,

wa_it_fldcat type lvc_s_fcat.

do 10 times.

index = sy-index.

  • Set up fieldname

concatenate 'FIELD' index into

fieldname .

condense fieldname no-gaps.

  • Set up fieldvalue

concatenate '66' index into

fieldvalue.

condense fieldvalue no-gaps.

assign component fieldname of structure <dyn_wa> to <fs1>.

<fs1> = fieldvalue.

enddo.

  • Append to the dynamic internal table

append <dyn_wa> to <dyn_table>.

endform.

0 Kudos
75

Add this line to the code...'




wa_cat-fieldname = gv_fldname.
wa_cat-seltext_s = gv_fldname.
wa_cat-outputlen = '5'.
<b>
wa_cat-do_sum    = 'X'.
wa_cat-datatype  = 'QUAN'.
</b>
append wa_cat to alv_fldcat.

Regards,

Rich Heilman

0 Kudos
75

Thanks ! It's solved my problem!