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: 

subtotal Text

Former Member
0 Kudos

Hi Experts,

I written ALV Prg with subtotal and Grand Total with Isort

I need to display text for both sub total and Grand Total,

Can anyone help on this ? Pls send a sample code for understanding

Thanks in advance

karthik

2 REPLIES 2

Former Member
0 Kudos

hi,

try like this

&----


*& Report ZALV_LIST

*&

&----


*&

*&

&----


REPORT zalv_list.

TABLES : mseg.

TYPE-POOLS : slis.

DATA : BEGIN OF itab OCCURS 0,

mblnr LIKE mseg-mblnr,

matnr LIKE mseg-matnr,

werks LIKE mseg-werks,

menge LIKE mseg-menge,

line_color(4) TYPE c,

END OF itab.

DATA : BEGIN OF itab1 OCCURS 0,

mblnr LIKE mseg-mblnr,

matnr LIKE mseg-matnr,

werks LIKE mseg-werks,

menge LIKE mseg-menge,

line_color(4) TYPE c,

END OF itab1.

DATA : t_fcat TYPE slis_t_fieldcat_alv,

t_eve TYPE slis_t_event,

t_subtot TYPE slis_t_sortinfo_alv,

subtot LIKE LINE OF t_subtot,

wa_fcat LIKE LINE OF t_fcat,

gd_layout TYPE slis_layout_alv.

DATA : gt_menge LIKE mseg-menge,

st_menge LIKE mseg-menge.

SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : doc FOR mseg-mblnr.

SELECTION-SCREEN : END OF BLOCK blk1.

INITIALIZATION.

PERFORM build_cat USING t_fcat.

PERFORM build_eve.

PERFORM build_layout.

START-OF-SELECTION.

PERFORM get_data.

PERFORM display.

&----


*& Form build_cat

&----


  • text

----


  • -->TEMP_FCAT text

----


FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.

wa_fcat-tabname = 'ITAB'.

wa_fcat-fieldname = 'MBLNR'.

wa_fcat-seltext_m = 'Material Doc.'.

APPEND wa_fcat TO temp_fcat.

CLEAR wa_fcat.

wa_fcat-tabname = 'ITAB'.

wa_fcat-fieldname = 'MATNR'.

wa_fcat-seltext_m = 'Material'.

APPEND wa_fcat TO temp_fcat.

CLEAR wa_fcat.

wa_fcat-tabname = 'ITAB'.

wa_fcat-fieldname = 'WERKS'.

wa_fcat-seltext_m = 'Plant'.

APPEND wa_fcat TO temp_fcat.

CLEAR wa_fcat.

wa_fcat-tabname = 'ITAB'.

wa_fcat-fieldname = 'MENGE'.

wa_fcat-seltext_m = 'Quantity'.

APPEND wa_fcat TO temp_fcat.

CLEAR wa_fcat.

ENDFORM. "build_cat

&----


*& Form build_eve

&----


  • text

----


FORM build_eve.

DATA : wa_eve TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = t_eve

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ TABLE t_eve WITH KEY name = slis_ev_top_of_page

INTO wa_eve.

IF sy-subrc = 0.

MOVE 'TOP_OF_PAGE' TO wa_eve-form.

APPEND wa_eve TO t_eve.

ENDIF.

ENDFORM. "build_eve

&----


*& Form build_layout

&----


  • text

----


FORM build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-info_fieldname = 'LINE_COLOR'.

gd_layout-subtotals_text = 'SUBTOTAL'.

gd_layout-totals_text = 'TOTAL'.

ENDFORM. " BUILD_LAYOUT

&----


*& Form get_data

&----


  • text

----


FORM get_data.

SELECT mblnr matnr werks menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab

WHERE mblnr IN doc.

SORT itab BY mblnr.

LOOP AT itab.

AT NEW mblnr.

LOOP AT itab WHERE mblnr = itab-mblnr.

st_menge = st_menge + itab-menge.

itab1-mblnr = itab-mblnr.

itab1-matnr = itab-matnr.

itab1-werks = itab-werks.

itab1-menge = itab-menge.

APPEND itab1.

ENDLOOP.

itab1-mblnr = 'Sub_Total'.

itab1-matnr = ''.

itab1-werks = ''.

itab1-menge = st_menge.

itab1-line_color = 'C710'.

APPEND itab1.

itab1-line_color = ''.

CLEAR st_menge.

ENDAT.

ENDLOOP.

LOOP AT itab.

gt_menge = gt_menge + itab-menge.

ENDLOOP.

itab1-mblnr = 'Total'.

itab1-matnr = ''.

itab1-werks = ''.

itab1-menge = gt_menge.

itab1-line_color = 'C310'.

APPEND itab1.

ENDFORM. "get_data

&----


*& Form display

&----


  • text

----


FORM display.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = 'ZALV_LIST'

is_layout = gd_layout

it_fieldcat = t_fcat

  • it_sort = t_subtot

it_events = t_eve

TABLES

t_outtab = itab1

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "display

&----


*& Form top_of_page

&----


  • text

----


FORM top_of_page.

WRITE:/ 'Data'.

ENDFORM. "top_of_page

here in layout there are two fields like,

gd_layout-subtotals_text = 'SUBTOTAL'.

gd_layout-totals_text = 'TOTAL'.

but subtotal text not working.....

so i did it manually

reward if useful..

Former Member
0 Kudos

Hi,

Reprots

http://www.sapgenie.com/abap/reports.htm

http://www.allsaplinks.com/material.html

http://www.sapdevelopment.co.uk/reporting/reportinghome.htm

ALV

1. Please give me general info on ALV.

http://www.sapfans.com/forums/viewtopic.php?t=58286

http://www.sapfans.com/forums/viewtopic.php?t=76490

http://www.sapfans.com/forums/viewtopic.php?t=20591

http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.

2. How do I program double click in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=11601

http://www.sapfans.com/forums/viewtopic.php?t=23010

3. How do I add subtotals (I have problem to add them)...

http://www.sapfans.com/forums/viewtopic.php?t=20386

http://www.sapfans.com/forums/viewtopic.php?t=85191

http://www.sapfans.com/forums/viewtopic.php?t=88401

http://www.sapfans.com/forums/viewtopic.php?t=17335

4. How to add list heading like top-of-page in ABAP lists?

http://www.sapfans.com/forums/viewtopic.php?t=58775

http://www.sapfans.com/forums/viewtopic.php?t=60550

http://www.sapfans.com/forums/viewtopic.php?t=16629

5. How to print page number / total number of pages X/XX in ALV? http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)

6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.

http://www.sapfans.com/forums/viewtopic.php?t=64320

http://www.sapfans.com/forums/viewtopic.php?t=44477

7. How can I set the cell color in ALV? http://www.sapfans.com/forums/viewtopic.php?t=52107

8. How do I print a logo/graphics in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=81149

http://www.sapfans.com/forums/viewtopic.php?t=35498

http://www.sapfans.com/forums/viewtopic.php?t=5013

9. How do I create and use input-enabled fields in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=84933

http://www.sapfans.com/forums/viewtopic.php?t=69878

10. How can I use ALV for reports that are going to be run in background?

http://www.sapfans.com/forums/viewtopic.php?t=83243

http://www.sapfans.com/forums/viewtopic.php?t=19224

11. How can I display an icon in ALV? (Common requirement is traffic light icon).

http://www.sapfans.com/forums/viewtopic.php?t=79424

http://www.sapfans.com/forums/viewtopic.php?t=24512

12. How can I display a checkbox in ALV? http://www.sapfans.com/forums/viewtopic.php?t=88376

http://www.sapfans.com/forums/viewtopic.php?t=40968

http://www.sapfans.com/forums/viewtopic.php?t=6919

Check this for basic concepts of OOPS

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20...

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20...

Tabstrip

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20...

Editable ALV

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20...

Tree

http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_usrint.htm

General Tutorial for OOPS

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an%20ea...

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

http://www.sap-img.com/abap/what-is-alv-programming.htm

http://www.sap-img.com/abap-function.htm

http://www.geocities.com/mpioud/Abap_programs.html

http://www.sapdevelopment.co.uk/reporting/alv/alvtree%5Calvtree_basic.htm

http://esnips.com/doc/ad20dca9-6182-4903-8d8f-96a66dc8590c/ALV.pdf

http://www.sap-img.com/abap-function.htm

Reward points if helpful....

Cheers,

Rakesh