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 text for sub totals and grand total

Former Member
0 Kudos

Hi friends

Iam displsying a alv grid display.

now my requirement is iam displaying vendor wise subtotal and grand total for all the vendors with in a compnay code.

now i need text where ever iam displaying subtotal as

subtotal for so and so vendor.

example :

for vendor 100

subtotal for vendor 100

for vendor 200

subtotal for vendor 200

and at the last it should display text as grand total.

How can i do that.

Regards,

Priyanka.

1 ACCEPTED SOLUTION

bpawanchand
Active Contributor
0 Kudos

Hi

Check this thread

Regards

Pavan

4 REPLIES 4

Former Member
0 Kudos

Hi Priyanka,

Check the sample in this thread:

Regards,

Chandra Sekhar

bpawanchand
Active Contributor
0 Kudos

Hi

Check this thread

Regards

Pavan

Former Member
0 Kudos

Hi,

For every vendor add subtotal by using

AT NEW vendor

grandtotal = grandtotal +subtotal.

ENDAT.

You can display the grand total by using SAP script at the end.

Regards

Mudit

Former Member
0 Kudos

Hi,

In Grid Display,For printing subtotals you have to assign do_sum in fieldcat for the numeric field you are trying to get the sub-total for.

like,

IS_FCAT-FIELDNAME = Vendor_field.

IS_FCAT-DO_SUM = 'X'.

APPEND IS_FCAT TO IT_FCAT.

For printing Grand Total,use sort and enable SUBTOT.

Consider the following program,where sort level is at VKORG and GRANDTOTAL and SUBTOTAL at NETWR.

TYPE-POOLS: SLIS.

*----


DATA DECLARE

DATA: BEGIN OF IT_DATA OCCURS 1,

VBELN LIKE VBRK-VBELN,

VKORG LIKE VBRK-VKORG,

BUKRS LIKE VBRK-BUKRS,

KUNRG LIKE VBRK-KUNRG,

NETWR LIKE VBRK-NETWR,

UNITP LIKE VBRK-NETWR,

END OF IT_DATA.

*----


FIELD CAT VARIABLES DECLARE

DATA: IS_FCAT TYPE slis_fieldcat_alv,

IT_FCAT TYPE slis_t_fieldcat_alv.

*----


LAYOUT DECLARATION

DATA: IS_LAY TYPE SLIS_LAYOUT_ALV.

*----


SORT DECLARATION

DATA: IS_SORT TYPE slis_sortinfo_alv,

IT_SORT TYPE slis_t_sortinfo_alv.

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM BUILD_DATA.

PERFORM DO_SORT.

PERFORM MOD_LAYOUT.

PERFORM SHOW_ALV.

&----


*& Form GET_DATA

&----


FORM GET_DATA .

SELECT VBELN VKORG BUKRS KUNRG NETWR FROM VBRK INTO TABLE IT_DATA UP TO

15 ROWS.

LOOP AT IT_DATA.

IT_DATA-UNITP = IT_DATA-NETWR / 3.

MODIFY IT_DATA.

ENDLOOP.

ENDFORM. " GET_DATA

&----


*& Form BUILD_DATA

&----


FORM BUILD_DATA .

*----


FIELD1

IS_FCAT-FIELDNAME = 'VBELN'.

IS_FCAT-TABNAME = 'IT_DATA'.

IS_FCAT-SELTEXT_M = 'BILL DOC NO'.

APPEND IS_FCAT TO IT_FCAT.

CLEAR IS_FCAT.

*----


FIELD2

IS_FCAT-FIELDNAME = 'VKORG'.

IS_FCAT-TABNAME = 'IT_DATA'.

IS_FCAT-SELTEXT_M = 'SALES ORG'.

APPEND IS_FCAT TO IT_FCAT.

CLEAR IS_FCAT.

*----


FIELD3

IS_FCAT-FIELDNAME = 'BUKRS'.

IS_FCAT-TABNAME = 'IT_DATA'.

IS_FCAT-SELTEXT_M = 'COMPANY NO.'.

APPEND IS_FCAT TO IT_FCAT.

CLEAR IS_FCAT.

*----


FIELD4

IS_FCAT-FIELDNAME = 'KUNRG'.

IS_FCAT-TABNAME = 'IT_DATA'.

IS_FCAT-SELTEXT_M = 'PAYER'.

IS_FCAT-EMPHASIZE = 'C210'.

APPEND IS_FCAT TO IT_FCAT.

CLEAR IS_FCAT.

*----


FIELD5

IS_FCAT-FIELDNAME = 'NETWR'.

IS_FCAT-TABNAME = 'IT_DATA'.

IS_FCAT-SELTEXT_M = 'NET VALUE'.

IS_FCAT-DO_SUM = 'X'.

"SUBTOTAL2 TO ENABLE SUM OF THIS FIELD

APPEND IS_FCAT TO IT_FCAT.

CLEAR IS_FCAT.

*----


FIELD6

IS_FCAT-FIELDNAME = 'UNITP'.

IS_FCAT-TABNAME = 'IT_DATA'.

IS_FCAT-SELTEXT_M = 'UNIT PRICE'.

APPEND IS_FCAT TO IT_FCAT.

CLEAR IS_FCAT.

ENDFORM. " BUILD_DATA

&----


*& Form SHOW_ALV

&----


FORM SHOW_ALV .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

IS_LAYOUT = IS_LAY

IT_FIELDCAT = IT_FCAT

IT_SORT = IT_SORT

TABLES

T_OUTTAB = IT_DATA.

ENDFORM. " SHOW_ALV

&----


*& Form MOD_LAYOUT

&----


FORM MOD_LAYOUT .

IS_LAY-ZEBRA = 'X'. "STRIPPED LIST

ENDFORM. " MODIFYING_LAYOUT

&----


*& Form DO_SORT

&----


FORM DO_SORT .

IS_SORT-FIELDNAME = 'VKORG'.

IS_SORT-TABNAME = 'IT-DATA'.

IS_SORT-UP = 'X'.

IS_SORT-SUBTOT = 'X'.

APPEND IS_SORT TO IT_SORT.

ENDFORM. " DO_SORT