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 Grid display

Former Member
0 Likes
475

Hi,

How do I include a text for sub total field on ALV.

I got different columns on ALV which shows count. Want to put a text at the left end of Report for field BUKRS like "State level total"

I tried creating SUBTOTAL_TEXT with events and passed it on REUSE_ALV_GRID_DISPLAY for IT_EVENTS. It doesn't works. Not sure what am I missing.

Field catalog I created:

lw_fieldcat-tabname = 't_out_val'.

lw_fieldcat-fieldname = 'BUKRS1'.

lw_fieldcat-seltext_l = 'Company Code'.

lw_fieldcat-col_Pos = lv_col_pos.

lw_fieldcat-outputlen = 15.

APPEND lw_fieldcat TO pi_fieldcat.

lv_col_pos = +1.

CLEAR lw_fieldcat.

Event for Subtotal_text:

FORM SUB_GET_EVENT .

CONSTANTS: c_formname_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.

DATA: l_s_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 4

IMPORTING

ET_EVENTS = i_event

EXCEPTIONS

LIST_TYPE_WRONG = 0

OTHERS = 0.

READ TABLE i_event INTO l_s_event WITH KEY name = slis_ev_subtotal_text.

IF sy-subrc EQ 0.

MOVE c_formname_subtotal_text TO l_s_event-form.

MODIFY i_event FROM l_s_event INDEX sy-tabix.

ENDIF.

Text for subtotal:

FORM subtotal_text CHANGING

p_total TYPE any

p_subtot_text TYPE slis_subtot_text.

IF p_subtot_text-criteria = 'BUKRS1'.

p_subtot_text-display_text_for_subtotal = 'State level total'.

ENDIF.

ENDFORM. "subtotal_text

Thanks,

Francis

Hi,

How do I include a text for sub total field on ALV.

I got different columns on ALV which shows count. Want to put a text at the left end of Report for field BUKRS like "State level total"

I tried creating SUBTOTAL_TEXT with events and passed it on REUSE_ALV_GRID_DISPLAY for IT_EVENTS. It doesn't works. Not sure what am I missing.

Field catalog I created:

lw_fieldcat-tabname = 't_out_val'.

lw_fieldcat-fieldname = 'BUKRS1'.

lw_fieldcat-seltext_l = 'Company Code'.

lw_fieldcat-col_Pos = lv_col_pos.

lw_fieldcat-outputlen = 15.

APPEND lw_fieldcat TO pi_fieldcat.

lv_col_pos = +1.

CLEAR lw_fieldcat.

Event for Subtotal_text:

FORM SUB_GET_EVENT .

CONSTANTS: c_formname_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.

DATA: l_s_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 4

IMPORTING

ET_EVENTS = i_event

EXCEPTIONS

LIST_TYPE_WRONG = 0

OTHERS = 0.

READ TABLE i_event INTO l_s_event WITH KEY name = slis_ev_subtotal_text.

IF sy-subrc EQ 0.

MOVE c_formname_subtotal_text TO l_s_event-form.

MODIFY i_event FROM l_s_event INDEX sy-tabix.

ENDIF.

Text for subtotal:

FORM subtotal_text CHANGING

p_total TYPE any

p_subtot_text TYPE slis_subtot_text.

IF p_subtot_text-criteria = 'BUKRS1'.

p_subtot_text-display_text_for_subtotal = 'State level total'.

ENDIF.

ENDFORM. "subtotal_text

Thanks,

Francis

2 REPLIES 2
Read only

former_member189779
Active Contributor
0 Likes
450

Hi

have sorted your table on BUKRS?

refer http://wiki.sdn.sap.com/wiki/display/Snippets/DisplaysubtotaltextinALV+grid

Regards

Vinit

Read only

praveen_reddy2
Active Participant
0 Likes
450

hi,

Change your Field catalog a bit and Check with this..

lw_fieldcat-fieldname = 'BUKRS'.

lw_fieldcat-seltext_l = 'Company Code'.

lw_fieldcat-no_out= 'X'.

lw_fieldcat-TECH= ' '.

APPEND lw_fieldcat TO pi_fieldcat.

Regards,

PraVeen..