ALV-GRID TOTAL
Hi Experts,
i have issue were in i need to show sum of the amount. like example...
for Custmer 100 there are vendor number 10,20,30,40,50. so for all this vendor numbers..
vendor----- amount
10 -
100
20----
200
30----
300
40----
400
50-------500
so in the output i want it to be..
customer--vendornumber--
amount
1000--10--
1500
20---
30---
40---
50---
.hope u experts have undestood. so how can i add the it and show it in the output....
am forwarding my code also..
Corrects answers will be fully rewarded..
REPORT zrfi007 NO STANDARD PAGE HEADING LINE-SIZE 255 MESSAGE-ID z01.
TYPE-POOLS: slis, abap.
* TYPES Declaration
TYPES: BEGIN OF ty_lfa1,
lifnr TYPE lfa1-lifnr,
name1 TYPE lfa1-name1,
END OF ty_lfa1.
TYPES: BEGIN OF ty_bsik,
bukrs TYPE bsik-bukrs,
lifnr TYPE bsik-lifnr,
belnr TYPE bsik-belnr,
bldat TYPE bsik-bldat,
waers TYPE bsik-waers,
dmbtr TYPE bsik-dmbtr,
wrbtr TYPE bsik-wrbtr,
zfbdt TYPE bsik-zfbdt,
zbd1t TYPE bsik-zbd1t,
zbd2t TYPE bsik-zbd2t,
zbd3t TYPE bsik-zbd3t,
END OF ty_bsik.
TYPES: BEGIN OF ty_lfb1,
lifnr TYPE lfb1-lifnr,
bukrs TYPE lfb1-bukrs,
END OF ty_lfb1.
TYPES: BEGIN OF ty_final,
bukrs TYPE bsik-bukrs,
lifnr TYPE bsik-lifnr,
belnr TYPE bsik-belnr,
bldat TYPE bsik-bldat,
days TYPE sy-datum,
waers TYPE bsik-waers,
dmbtr TYPE bsik-dmbtr,
* waers type bsik-waers,
wrbtr TYPE bsik-wrbtr,
zfbdt TYPE bsik-zfbdt,
zbd1t TYPE bsik-zbd1t,
zbd2t TYPE bsik-zbd2t,
zbd3t TYPE bsik-zbd3t,
name1 TYPE lfa1-name1,
current TYPE bsik-dmbtr,
d30 TYPE bsik-dmbtr,
d60 TYPE bsik-dmbtr,
d90 TYPE bsik-dmbtr,
d120 TYPE bsik-dmbtr,
d180 TYPE bsik-dmbtr,
d240 TYPE bsik-dmbtr,
d360 TYPE bsik-dmbtr,
da365 TYPE bsik-dmbtr,
* ct_date TYPE sy-datum,
* date TYPE datum,
* days TYPE char8,
END OF ty_final.
* Data Declaration.
DATA: gt_lfa1 TYPE STANDARD TABLE OF ty_lfa1,
wa_lfa1 TYPE ty_lfa1.
DATA: gt_final TYPE STANDARD TABLE OF ty_final,
wa_final TYPE ty_final.
DATA: gt_bsik TYPE STANDARD TABLE OF ty_bsik,
wa_bsik TYPE ty_bsik.
DATA: gt_lfb1 TYPE STANDARD TABLE OF ty_lfb1,
wa_lfb1 TYPE ty_lfb1.
DATA: days TYPE sy-datum.
* ALV Components
**** ALV Internal Table
DATA : i_layout TYPE slis_layout_alv OCCURS 0 WITH HEADER LINE,
i_events TYPE slis_t_event,
i_fieldcat TYPE slis_t_fieldcat_alv,
i_print TYPE slis_print_alv,
i_list_top TYPE slis_t_listheader,
i_list_end TYPE slis_t_listheader,
i_sort TYPE slis_t_sortinfo_alv.
DATA: wa_fieldcat LIKE LINE OF i_fieldcat.
* ALV Variable.
DATA: v_top TYPE slis_formname VALUE 'TOP_OF_PAGE',
v_eop TYPE slis_formname VALUE 'END_OF_PAGE',
v_eol TYPE slis_formname VALUE 'END_OF_LIST',
v_tol TYPE slis_formname VALUE 'TOP_OF_LIST'.
**** ALV Variants
DATA: i_variant LIKE disvariant.
* Selection screen
DATA: v_bukrs TYPE bukrs,
v_lifnr TYPE kunnr,
pa_bldat TYPE bldat.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_bukrs FOR v_bukrs NO INTERVALS NO-EXTENSION OBLIGATORY,
s_lifnr FOR v_lifnr.
* bldat FOR v_bldat no-extension.
PARAMETERS: p_bldat TYPE bsik-bldat.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_detail RADIOBUTTON GROUP r1 DEFAULT 'X',
p_sumry RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b2.
* Top-Of-Page Declaration Header
DATA: lwa_list_top LIKE LINE OF i_list_top.
DATA: lv_header(70),
lv_text(50),
lv_text1(60),
lv_text2(50),
lv_text3(50) ,
lv_text4(50),
lv_date TYPE char10,
lv_time TYPE char10.
DATA: lv_butxt LIKE t001-butxt,
lv_butxt1 LIKE lfa1-name1,
lv_butxt2 LIKE lfb1-lifnr.
INITIALIZATION.
*TOP-OF-PAGE.
* Validations for Selection screen
AT SELECTION-SCREEN ON s_bukrs.
IF NOT s_bukrs[] IS INITIAL.
SELECT SINGLE bukrs FROM lfb1
INTO s_bukrs
WHERE bukrs IN s_bukrs.
ENDIF.
IF sy-subrc NE 0.
MESSAGE e003.
ENDIF.
AT SELECTION-SCREEN ON s_lifnr.
IF NOT s_lifnr[] IS INITIAL.
SELECT SINGLE lifnr FROM lfa1
INTO s_lifnr
WHERE lifnr IN s_lifnr.
IF sy-subrc NE 0.
MESSAGE e005.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON p_bldat.
IF NOT p_bldat IS INITIAL.
SELECT SINGLE bldat FROM bsid
INTO p_bldat
WHERE bldat = p_bldat.
IF sy-subrc NE 0 .
MESSAGE e004.
ENDIF.
ENDIF.
* Selection For Top-of-page.
** Get company code description
SELECT SINGLE butxt
FROM t001 INTO lv_butxt
WHERE bukrs IN s_bukrs.
* SELECT SINGLE lifnr FROM lfb1
* INTO lv_butxt2 WHERE bukrs IN s_bukrs.
* SELECT SINGLE name1 FROM lfa1
* INTO lv_butxt1 WHERE lifnr = lv_butxt2.
START-OF-SELECTION.
PERFORM data_retrival.
PERFORM f_layout_init.
PERFORM f_eventtab_build.
i_variant-report = sy-repid.
PERFORM f_print_control.
* PERFORM f_build_header_list.
* perform f_build_header_list1.
* PERFORM f_build_fieldcat.
IF p_detail = 'X'.
PERFORM f_build_sort.
PERFORM fill_fieldcat.
PERFORM f_build_header_list.
ELSE.
PERFORM f_build_sort1.
PERFORM fill_fieldcat_sum.
PERFORM f_build_header_list1.
ENDIF.
PERFORM f_list_display TABLES gt_final[].
END-OF-SELECTION.
*& Form data_retrival
* text
* --> p1 text
* <-- p2 text
FORM data_retrival .
SELECT bukrs
lifnr
belnr
bldat
waers
dmbtr
wrbtr
zfbdt
zbd1t
zbd2t
zbd3t
FROM bsik INTO TABLE gt_bsik
WHERE bukrs IN s_bukrs
AND lifnr IN s_lifnr.
SELECT lifnr
name1
FROM lfa1 INTO TABLE gt_lfa1
FOR ALL ENTRIES IN gt_bsik
WHERE lifnr = gt_bsik-lifnr.
LOOP AT gt_bsik INTO wa_bsik.
READ TABLE gt_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_bsik-lifnr.
MOVE-CORRESPONDING wa_bsik TO wa_final.
MOVE-CORRESPONDING wa_lfa1 TO wa_final.
DATA: days TYPE char2,
c4 TYPE char2.
DATA: days1 TYPE sy-datum.
DATA:duedate TYPE rfpos-faedt.
CALL FUNCTION 'NET_DUE_DATE_GET'
EXPORTING
i_zfbdt = wa_final-zfbdt
i_zbd1t = wa_final-zbd1t
i_zbd2t = wa_final-zbd2t
i_zbd3t = wa_final-zbd3t
i_shkzg = ' '
i_rebzg = ' '
* I_KOART = 'D'
IMPORTING
e_faedt = duedate.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = duedate
i_datum_von = wa_final-bldat
* I_KZ_EXCL_VON = '0'
* I_KZ_INCL_BIS = '0'
* I_KZ_ULT_BIS = ' '
* I_KZ_ULT_VON = ' '
* I_STGMETH = '0'
* I_SZBMETH = '1'
IMPORTING
e_tage = days
EXCEPTIONS
days_method_not_defined = 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.
wa_final-days = duedate.
DATA : wf_char TYPE char10.
wf_char = days.
IF wf_char+0(1) EQ '*' .
SKIP.
ELSE.
IF days EQ 0.
wa_final-current = wa_bsik-wrbtr.
ELSEIF days LE 30 AND days GT 0.
wa_final-d30 = wa_bsik-wrbtr.
ELSEIF days LE 60 AND days GT 30 .
wa_final-d60 = wa_bsik-wrbtr.
ELSEIF days LE 90 AND days GT 60.
wa_final-d90 = wa_bsik-wrbtr.
ELSEIF days LE 120 AND days GT 90.
wa_final-d120 = wa_bsik-wrbtr.
ELSEIF days LE 180 AND days GT 120.
wa_final-d180 = wa_bsik-wrbtr.
ELSEIF days LE 240 AND days GT 180.
wa_final-d240 = wa_bsik-wrbtr.
ELSEIF days LE 360 AND days GT 240.
wa_final-d360 = wa_bsik-wrbtr.
ELSEIF days GT 365 .
wa_final-da365 = wa_bsik-wrbtr.
ENDIF.
ENDIF.
APPEND wa_final TO gt_final.
CLEAR: wa_final,
days,
duedate,days1.
ENDLOOP.
ENDFORM. " data_retrival
*& Form fill_fieldcat
* text
FORM fill_fieldcat.
PERFORM fill_fields USING: 'Vendor Number' 'LIFNR',
'Vendor Name' 'NAME1',
'Document Number' 'BELNR',
'Document Date' 'BLDAT',
'Due Date' 'DAYS',
'Total In Document Currency' 'WRBTR',
'Currency' 'WAERS',
'Total In Reporting Currency' 'DMBTR',
'Current' 'CURRENT',
'1-30 days' 'D30',
'31-60 days' 'D60',
'61-90 days' 'D90',
'91-120 days' 'D120',
'121-180 days' 'D180',
'181-240 days' 'D240',
'241-360 days' 'D360',
* '181-365 days' 'D365',
'Above 365 days' 'DA365'.
ENDFORM. "fill_fieldcat
*& Form fill_fieldcat_sum
* text
FORM fill_fieldcat_sum.
PERFORM fill_fields USING: 'Vendor Number' 'LIFNR',
'Vendor Name' 'NAME1',
'Total In Reporting Currency' 'DMBTR',
'Current' 'CURRENT',
'1-30 days' 'D30',
'31-60 days' 'D60',
'61-90 days' 'D90',
'91-120 days' 'D120',
'121-180 days' 'D180',
'181-240 days' 'D240',
'241-360 days' 'D360',
'Above 365 days' 'DA365'.
ENDFORM. "fill_fieldcat_sum
*& Form fill_fields
* text
* -->&01 text
* -->&02 text
FORM fill_fields USING &01 &02 .
wa_fieldcat-tabname = 'T_OUTPUT'. "t_output_provgr
wa_fieldcat-fieldname = &02.
wa_fieldcat-seltext_m = &01.
* wa_fieldcat-ref_fieldname = fieldname.
* wa_fieldcat-ref_tabname = 'SFLIGHT'.
* w_fieldcat-do_sum = &03.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. "fill_fields
*& Form f_layout_init
* Set the layout
FORM f_layout_init.
* P_layout-min_linesize = 170.
* p_layout-max_linesize = 170.
* P_layout-no_colhead = abap_true.
* p_layout-detail_popup = abap_true.
i_layout-colwidth_optimize = abap_true.
i_layout-zebra = abap_true.
* i_layout-subtotals_text = 'SubTotal'.
* i_layout-totals_text = 'Total'.
ENDFORM. " f_layout_init
*& Form f_eventtab_build
* Set the events
FORM f_eventtab_build.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = i_events.
READ TABLE i_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE v_top TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_end_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE v_eop TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_end_of_list
INTO ls_event.
IF sy-subrc = 0.
MOVE v_eol TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_top_of_list
INTO ls_event.
IF sy-subrc = 0.
MOVE v_tol TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
ENDFORM. " f_eventtab_build
*& Form f_print_control
* Set the print control
FORM f_print_control .
* i_print-no_print_listinfos = abap_true.
* i_print-no_print_selinfos = abap_true.
* i_print-reserve_lines = 2.
* i_print-no_change_print_params = abap_true.
ENDFORM. " f_print_control
*& Form f_build_header_list
* Build the header list (top of page)
FORM f_build_header_list .
lv_header = 'Vendor Open Item Analysis By Balance Of Overdue Items'(h01).
lv_text = 'Company Name:'(s01).
lv_text1 = 'Open Item As Key Date:'(s02).
lv_text2 = 'Company Code:'(s03).
lv_text3 = 'Vendor Number:'(s04).
lv_text4 = 'Vendor Name:'(s05).
* Header
CLEAR lwa_list_top.
lwa_list_top-typ = 'H'.
lwa_list_top-info = lv_header.
APPEND lwa_list_top TO i_list_top.
* Run date Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-datum TO lv_date MM/DD/YYYY.
lwa_list_top-key = 'Date :'(025).
lwa_list_top-info = lv_date.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_date.
* Run time Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
lwa_list_top-key = 'Time :'(026).
lwa_list_top-info = lv_time.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_time.
CLEAR lwa_list_top.
* Company Name
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text.
lwa_list_top-info = lv_butxt.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
*Open Item As Key Date
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text1.
lwa_list_top-info = p_bldat.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
* Company Code
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text2.
lwa_list_top-info = s_bukrs-low.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
** Vendor Number
* lwa_list_top-typ = 'S'.
* lwa_list_top-key = lv_text3.
* lwa_list_top-info = lv_butxt2.
* APPEND lwa_list_top TO i_list_top.
* CLEAR lwa_list_top.
**Vendor Name
* lwa_list_top-typ = 'S'.
* lwa_list_top-key = lv_text4.
* lwa_list_top-info = lv_butxt1.
* APPEND lwa_list_top TO i_list_top.
ENDFORM. " f_build_header_list
*& Form f_build_header_list1
* text
* --> p1 text
* <-- p2 text
FORM f_build_header_list1 .
lv_header = 'Vendor Open Item Analysis By Balance Of Overdue Items'(h01).
lv_text = 'Company Name:'(s01).
lv_text1 = 'Open Item As Key Date:'(s02).
lv_text2 = 'Company Code:'(s03).
lv_text3 = 'Vendor Number:'(s04).
lv_text4 = 'Vendor Name:'(s05).
lwa_list_top-typ = 'H'.
lwa_list_top-info = lv_header.
APPEND lwa_list_top TO i_list_top.
* Run date Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-datum TO lv_date MM/DD/YYYY.
lwa_list_top-key = 'Date :'(025).
lwa_list_top-info = lv_date.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_date.
* Run time Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
lwa_list_top-key = 'Time :'(026).
lwa_list_top-info = lv_time.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_time.
CLEAR lwa_list_top.
* Company Name
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text.
lwa_list_top-info = lv_butxt.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
*Open Item As Key Date
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text1.
lwa_list_top-info = p_bldat.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
ENDFORM. " f_build_header_list1
*& Form f_build_sort
* Set the sorting sequence
FORM f_build_sort .
DATA: l_sort TYPE slis_sortinfo_alv.
l_sort-spos = '1'.
l_sort-fieldname = 'LIFNR'.
l_sort-up = abap_true.
l_sort-group = '*'.
* l_sort-subtot = 'X'.
APPEND l_sort TO i_sort.
* l_sort-spos = '2'.
* l_sort-fieldname = 'NAME1'.
* l_sort-up = abap_true.
* l_sort-group = '*'.
** l_sort-subtot = 'X'.
* APPEND l_sort TO i_sort.
* l_sort-spos = '2'.
* l_sort-fieldname = 'LIFNR'.
* l_sort-up = abap_true.
* l_sort-subtot = abap_true.
* APPEND l_sort TO i_sort.
* l_sort-spos = '1'.
* l_sort-fieldname = 'VBELN'.
* l_sort-up = abap_true.
* l_sort-subtot = abap_true.
* APPEND l_sort TO i_sort.
* l_sort-spos = '2'.
* l_sort-fieldname = 'POSNR'.
* l_sort-up = abap_true.
* l_sort-subtot = abap_true.
* APPEND l_sort TO i_sort.
ENDFORM. " f_build_sort
*& Form f_list_display
* Display the ALV list report
* -->PT_DATA Internal table containing the data
FORM f_list_display TABLES pt_data.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_variant-report
is_layout = i_layout
it_fieldcat = i_fieldcat[]
it_sort = i_sort
i_default = 'X'
i_save = 'A'
is_variant = i_variant
it_events = i_events[]
is_print = i_print
TABLES
t_outtab = pt_data.
ENDFORM. "f_list_display
*& Form TOP_OF_PAGE
* TOP_OF_PAGE Event
FORM top_of_page. "#EC CALLED
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
* i_logo = 'ZLOGO_BAB'
it_list_commentary = i_list_top
i_alv_form = 'X'.
* PERFORM f_print_header USING SPACE SPACE SPACE.
ENDFORM. "TOP_OF_PAGE
*& Form END_OF_PAGE
* END_OF_PAGE Event
FORM end_of_page. "#EC CALLED
* DATA: l_pos(3) TYPE n VALUE 0,
* l_foot(30) VALUE '*** END OF PAGE ***'.
* l_pos = ( sy-linsz / 2 ) - ( STRLEN( l_foot ) / 2 ).
* ULINE.
* WRITE: /, AT l_pos l_foot.
ENDFORM. "END_OF_PAGE
*& Form END_OF_LIST
* END_OF_LIST Event
FORM end_of_list. "#EC CALLED
* DATA: l_pos(3) TYPE n VALUE 0,
* l_foot(30) VALUE '*** END OF REPORT ***'.
* l_pos = ( sy-linsz / 2 ) - ( STRLEN( l_foot ) / 2 ).
* ULINE.
* WRITE: /, AT l_pos l_foot.
ENDFORM. "END_OF_LIST
*& Form f_print_header
* Print the header (Top-Of-Page)
* -->P_P_TITLE1 Title text 1
* -->P_P_TITLE2 Title text 2
* -->P_P_TITLE3 Title text 3
FORM f_print_header USING p_title1 LIKE sy-title
p_title2 LIKE sy-title
p_title3 LIKE sy-title.
DATA: l_post1 TYPE i,
l_post2 TYPE i,
l_post3 TYPE i,
l_posin TYPE i.
l_post1 = ( sy-linsz / 2 ) - ( STRLEN( p_title1 ) / 2 ).
l_post2 = ( sy-linsz / 2 ) - ( STRLEN( p_title2 ) / 2 ).
l_post3 = ( sy-linsz / 2 ) - ( STRLEN( p_title3 ) / 2 ).
l_posin = sy-linsz - 17.
WRITE: / 'Report :', sy-cprog.
WRITE AT l_post1 p_title1.
WRITE AT l_posin 'Date :'.
WRITE sy-datum.
WRITE: / 'Cli/Sys :', sy-mandt, '/', sy-sysid.
WRITE AT l_post2 p_title2.
WRITE AT: l_posin 'Time :'.
WRITE sy-uzeit.
WRITE: / 'UserID :', sy-uname.
WRITE AT l_post3 p_title3.
WRITE AT l_posin 'Page :'.
WRITE sy-pagno NO-ZERO.
ENDFORM. " f_print_header
*& Form f_build_sort1
* text
* --> p1 text
* <-- p2 text
form f_build_sort1 .
DATA: l_sort TYPE slis_sortinfo_alv.
l_sort-spos = '1'.
l_sort-fieldname = 'LIFNR'.
l_sort-up = abap_true.
l_sort-group = '*'.
* l_sort-subtot = 'X'.
APPEND l_sort TO i_sort.
l_sort-spos = '2'.
l_sort-fieldname = 'NAME1'.
l_sort-up = abap_true.
l_sort-group = '*'.
* l_sort-subtot = 'X'.
APPEND l_sort TO i_sort.
* l_sort-spos = '3'.
* l_sort-fieldname = 'DMBTR'.
* l_sort-up = abap_true.
* l_sort-group = '*'.
* l_sort-subtot = 'X'.
* APPEND l_sort TO i_sort.
endform. " f_build_sort1
Regards
Sunita.
Hey,
U can try out "SORTING THE VENDORS AND DO THE SUM in the NETWR"... try it out....see u sort the customers...rit?...keep it as usual and little mentoned above...
hope dis help u out...
Thanks.
Similar Messages
-
ALV grid total or based on two key fields
Hello experts,
I have ALV grid with vendor, g/l account and amount field.
I want to have sum or total of each vendor, and if vendor having mutliple g/l accounts i want to have sum for each g/l account.
ex: vendor g/l account amount.
10 aa 100
10 bb 200
11 cc 300
olp : 10 aa 100
10 bb 200
11 cc 300
ex2 : vendor g/ account amount
10 aa 100
10 aa 200
11 cc 300
o/p 10 aa 300.
11 cc 300.
Could you please help me and any suggestions
<<Text removed>>
Thanks
reddy.
Edited by: Matt on Jul 27, 2011 9:21 AMHello Reddy,
Try using the sort functionality of ALV grid
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = lwa_layout
it_toolbar_excluding = i_excl_func
i_default = c_x
CHANGING
it_outtab = i_outtab[]
it_fieldcatalog = i_fieldcat[]
it_sort = li_sort[] "use this functionality as per your requirement
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
Hope this may be helpful.
Sharin -
ALV grid total line customizing
Dear Masters,
I need a solution for my problem. I need to modify sorting of subtotal and grand total based on currency which criteria i create myself. The standard alv output sort total by currency based on alpahabetical order, e.g: AUD, EUR, IDR, USD. I need to change the sorting into IDR, USD, AUD, EUR. How can i do it in alv grid?
I also like to add new line after grand total line, which is grand total in Local Currency, in this case, in IDR, which rate given. I can get the figure of subtotal, but i don't know how to append new line after grand total line output in alv standard.
Need your suggestion.
Many thanks,
TiaraHi,
I have used object oriented ALV. You can remove final total line and have sub total lines. Code below can help you.
1) Fieldcatalog you can do sum for currency values
2) Sort Build you can have sub totals.
3) layout_init you can remove final total line.
4) CALL METHOD grid->set_table_for_first_display you can pass above structure for excepted Result.
fieldcatalog_init
FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat
value(field_name) value(field_type) value(field_text) value(field_key).
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = field_name.
ls_fieldcatalog-datatype = field_type.
ls_fieldcatalog-reptext = field_text.
ls_fieldcatalog-coltext = field_text.
ls_fieldcatalog-seltext = field_text.
ls_fieldcatalog-tooltip = field_text.
ls_fieldcatalog-key = field_key.
IF field_type = 'CURR'.
ls_fieldcatalog-do_sum = 'X'.
ENDIF.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ENDFORM. "fieldcatalog_init
sort_build
FORM sort_build USING lt_sort TYPE lvc_t_sort.
DATA: ls_sort TYPE lvc_s_sort.
ls_sort-fieldname = 'BUKRS'. "Fieldname on which to sort
ls_sort-subtot = 'X'.
ls_sort-up = 'X'. "Sort Ascending
APPEND ls_sort TO lt_sort.
IF p_comp <> 'X'.
ls_sort-fieldname = 'LIFNR'. "Fieldname on which to sort
ls_sort-subtot = 'X'.
ls_sort-up = 'X'. "Sort Ascending
APPEND ls_sort TO lt_sort.
ENDIF.
ls_sort-fieldname = 'WAERS'. "Fieldname on which to sort
ls_sort-subtot = 'X'.
ls_sort-up = 'X'. "Sort Ascending
APPEND ls_sort TO lt_sort.
ENDFORM. "sort_build
layout_init
FORM layout_init USING ls_layout TYPE lvc_s_layo.
DATA lv_date(10) TYPE c.
WRITE sy-datum TO lv_date.
IF p_line = 'X'.
CONCATENATE 'Line Item wise Report as on' lv_date INTO w_string2 SEPARATED BY space.
ELSEIF p_vend = 'X'.
CONCATENATE 'Vendor Summary Report as on' lv_date INTO w_string2 SEPARATED BY space.
ELSEIF p_comp = 'X'.
CONCATENATE 'Company Summary Report as on' lv_date INTO w_string2 SEPARATED BY space.
ENDIF.
ls_layout-zebra = 'X'.
ls_layout-grid_title = w_string2.
ls_layout-sel_mode = 'A'.
ls_layout-no_merging = 'X'.
ls_layout-cwidth_opt = 'X'.
ls_layout-no_totline = 'X'.
IF p_line = 'X'.
ls_layout-ctab_fname = 'COLINFO'.
ENDIF.
ENDFORM. "layout_init
CALL METHOD grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = va_layout "&see below
i_save = 'A' "&see below
i_default = ''
CHANGING
it_outtab = it_apout[]
it_fieldcatalog = gt_fieldcatalog
it_sort = gt_sort.
Edited by: Himanshu Dave on May 11, 2009 2:33 PM -
hi all,
I have an overflow error in alv total field.
first i filled alv grid using et_table_for_first_display, again i changed itab data
and use refresh_table_display to refresh data.
the alv contains total fields in field catalog.... when i try to 'refresh_table_display '
it comes an over flow error is coming and it comes every sort of records.. how can i trap this error ..??
thanks and regards
JoseHi Anup,
While using ALV with OOP methodology, you can create an extra row for giving the sum of any field.
In the field catalog, there is a component named 'DO_SUM', if set, will give the total value for the field.
In the method where you fill the field catalog , just add this component.
eg:
form catalog_fill changing p_field_catalog.
data ls_fcat type lvc_s_fcat .
ls_fcat-fieldname = 'CARRID' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Carrier ID' .
ls_fcat-web_field = 'carrid_handle'.
ls_fcat-edit = 'X'.
*ls_fcat-emphasize = 'C310'. "needed for column coloring
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'FLDATE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'FLDATE' .
ls_fcat-outputlen = '20' .
<b>ls_fcat-do_sum = 'X'.</b>
ls_fcat-coltext = 'Flight Date' .
ls_fcat-web_field = 'fldate_handle'.
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'PRICE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'PRICE' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Airfare' .
append ls_fcat to field_catalog .
endform.
In this way, you can get the total of any field in ALV.
Regards,
SP. -
ALV Grid Total Text (OOPS)
Hi All,
I have a simple ALV Grid Report(OOPS), I would like to give a Text for Total Row. In REUSE_ALV_GRID we have the option of giving this text, but i am not able to figure it out how to get the same in OOPS.
Regards
AnupHi Anup,
While using ALV with OOP methodology, you can create an extra row for giving the sum of any field.
In the field catalog, there is a component named 'DO_SUM', if set, will give the total value for the field.
In the method where you fill the field catalog , just add this component.
eg:
form catalog_fill changing p_field_catalog.
data ls_fcat type lvc_s_fcat .
ls_fcat-fieldname = 'CARRID' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Carrier ID' .
ls_fcat-web_field = 'carrid_handle'.
ls_fcat-edit = 'X'.
*ls_fcat-emphasize = 'C310'. "needed for column coloring
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'FLDATE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'FLDATE' .
ls_fcat-outputlen = '20' .
<b>ls_fcat-do_sum = 'X'.</b>
ls_fcat-coltext = 'Flight Date' .
ls_fcat-web_field = 'fldate_handle'.
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'PRICE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'PRICE' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Airfare' .
append ls_fcat to field_catalog .
endform.
In this way, you can get the total of any field in ALV.
Regards,
SP. -
Hi,
I have created an application that uses a web dynpro alv grid. I want to display totals - is there a setting that can do this automatically - if so, can you please tell me how to do this? Thanks,Hi
You can take help of following code snippet to create totals for a particular column
Data: lr_function_settings TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_column TYPE REF TO cl_salv_wd_column,
lt_column type salv_wd_t_column_ref,
ls_column type salv_wd_s_column_ref.
Data: lr_field_amnt type REF TO CL_SALV_WD_FIELD.
* get reference of ALV component
lr_salv_wd_table = wd_this->wd_cpifc_OVERVIEW_EARNED_ALV( ).
wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
* get function settings
lr_function_settings ?= wd_this->alv_config_table.
* display columns in correct order
lr_column_settings ?= wd_this->alv_config_table.
lt_column = lr_column_settings->get_columns( ).
loop at lt_column into ls_column.
CASE ls_column-id.
when 'AMOUNT'
* aggregate field
CALL METHOD LR_FUNCTION_SETTINGS->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD
EXPORTING
FIELDNAME = 'AMOUNT'
RECEIVING
VALUE = lr_field_amnt.
* create aggregate rule as total
CALL METHOD LR_FIELD_AMNT->IF_SALV_WD_AGGR~CREATE_AGGR_RULE
EXPORTING
AGGREGATION_TYPE = IF_SALV_WD_C_AGGREGATION=>AGGRTYPE_TOTAL
RECEIVING
VALUE = lv_aggr_rule.
endcase.
Regards
Manas DUa -
How to Expand ALV Grid Total Width
I have to display 1476 characters in an ALV grid and then the users will use what they need when creating a layout.
Problem is ALV stops after displaying 1375 (or so) characters) - any parm or action to do this (maybe in the catalog setup sent to the program? Thanks!Hi Scott
This may be a restriction ALV Grid puts. My recommendation will be that, split some fields and generate more than one rows with the same key (you should then add a new key field which will hold line numbers specific to one definite key). When you sort with ALV Grid's sort option the keys will vertically merged (if you do not turn off this feature via layout or field catalog settings). I know this is not so pretty but ALV is not intended to show that kind of stuff.
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a> -
hi there...I know there´s a lot of posts about this subject but i didn't find what i´m looking for...
I want to know if there´s some way to give a total and a sub-total of a field, but instead of the total and subtotal sums I just want a count of the number of rows for the field that I've sorted.
FIELDCATALOG-FIELDNAME = 'BUKRS'.
FIELDCATALOG-SELTEXT_M = 'BUKRS'.
FIELDCATALOG-COL_POS = 0.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'BUTXT'.
FIELDCATALOG-SELTEXT_M = 'BUTXT'.
FIELDCATALOG-COL_POS = 1.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'LIFNR'.
FIELDCATALOG-SELTEXT_M = 'LIFNR'.
FIELDCATALOG-COL_POS = 2.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'NAME1'.
FIELDCATALOG-SELTEXT_M = 'NAME1'.
FIELDCATALOG-COL_POS = 3.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'MBLNR'.
FIELDCATALOG-SELTEXT_M = 'MBLNR'.
FIELDCATALOG-COL_POS = 4.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'MJAHR'.
FIELDCATALOG-SELTEXT_M = 'MJAHR'.
FIELDCATALOG-COL_POS = 5.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'CPUDT'.
FIELDCATALOG-SELTEXT_M = 'CPUDT'.
FIELDCATALOG-COL_POS = 6.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'BUDAT'.
FIELDCATALOG-SELTEXT_M = 'BUDAT'.
FIELDCATALOG-COL_POS = 7.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'USNAM'.
FIELDCATALOG-SELTEXT_M = 'BUDAT'.
FIELDCATALOG-COL_POS = 8.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'MENGE'.
FIELDCATALOG-SELTEXT_M = 'MENGE'.
FIELDCATALOG-COL_POS = 9.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'DMBTR'.
FIELDCATALOG-SELTEXT_M = 'DMBTR'.
FIELDCATALOG-COL_POS = 10.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
* SORT
WA_SORT-SPOS = 1.
WA_SORT-FIELDNAME = 'BUKRS'.
WA_SORT-TABNAME = 'ITAB'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-SPOS = 2.
WA_SORT-FIELDNAME = 'LIFNR'.
WA_SORT-TABNAME = 'ITAB'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
in the alv i want to know the number of rows for each value of lifnr (sub-total) and in the end the total of the all values of lifnr
thanksHi,
It is better to obtain this information not in ALV but working on the table. Using control level processing it is easy to achieve.
data: begin of it_overview occurs 0
lifnr type ..
tot_item type i, "number of lifnr withing subtotal
end of it_overwiev.
data: pos type i. "to remember the position.
"your output table
Loop at it_ouptut.
at new lifnr.
pos = sy-tabix. "remember first position of new LIFNR
endat.
at end of lifnr.
it_overview-lifnr = it_output-lifnr.
it_overview-tot_item = sy-tabix - pos. "calculate how many within one LIFNR
append it_overview. "store it in the table
clear pos.
endat.
endloop.
this way table IT_OVERVIEW stores LIFNRs and number of items forming their subtotals.
To get total use:
DESCRIEBE TABLE it_output.
it_output-lifnr = 'TOTAL_ITEMS'. "total items within all LIFNRs
it_output-tot_item = sy-tfill. "is equal to total lines in the table
append it_output.
Regards
Marcin -
Hi,
We are using REUSE_ALV_GRID_DISPLAY for diaplying grid . we want the totals to be displayed for some fields.
but for percentage fields we want to calculate the values. How do we do this?Hi Asharaghu,
FOR TOTAL:
there is a property of fieldcatalog, that is do_sum.
USE COED LIKE:
PERFORM fieldcat USING:
'1' 'KUNNR' 'I_MARD' 'CUSTOMER NO' ,
'2' 'DMBTR' 'I_MARD' 'CURRENCY' ,
FORM fieldcat USING value(p_0029)
value(p_0030)
value(p_0031)
value(p_0032)
wa_fieldcat-col_pos = p_0029.
wa_fieldcat-fieldname = p_0030.
wa_fieldcat-tabname = p_0031.
wa_fieldcat-reptext = p_0032.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " FIELDCAT
Then pass i_fieldcat through REUSE_ALV_GRID_DISPLAY.
in final output you will get the total of currency field.
Hope this can solve your problems.
Regards,
Tutun -
The Visible attribute on alv grid column is not changed after Change Layout
Setup:
I have a program that displays output in an ALV grid (using cl_salv_table).
The ALV grid is displayed within a custom control on a subscreen.
I have 4 subscreens being used on a tabstrip control. So I have 4 ALV grids total (one on each subscreen).
On each ALV grid, I have set the set_layout_change function to true so that the user can hide and unhide columns etc. on each grid via the button on the alv grid toolbar.
I also allow the user to dowload the contents of all 4 grids to excel. To do this I have a custom button that when clicked goes to each ALV grid - gets the column metadata (via cl_salv_columns_table-get() ) and checks the visibility to determine if the column should be downloaded or not (via cl_salv_column-is_visible() ) to excel.
The Problem:
As I said I have 4 grids being displayed via a tab control. Let's say the user is on tab 1 and unhides some columns on the alv grid 1 via the Change Layout... button. And then the user navigates to tab 2. If they click the download button at that point - when the download code is run and it checks the visibility of the columns on alv grid 1 - the changes that were made via the Change Layout... button have not synchronized yet. When I call is_visible() for a column that was unhid it still comes back as false.
The only way I have found to remedy this is to make the user click on a button on the alv grid's toolbar before navigating to a different tab to force the synchronization between the changes made and the backend column metadata. However, this is not the best option and requires training for the user that they have to do this for the download to work correctly.
The Question:
1) why is the Change Layout... button not automatically synchronizing the changes it made to the back end? Is there a way to make it do this?
2) OR, is there a way that I can force the synchronization within the code and not force the user to click a button on the alv grid? If there is a way to force the synchronization - where do I put that code? As far as I can tell, when I switch between tabs - I am unable to catch that action in my PAI events.
Thanks in advance for any help.I was able to resolve this issue with a satisfactory solution.
In my program I had a local class definition to handle the grids' events. When the synchronization wasn't working I only had two events defined: for link_click and added_functions.
I created another definition for event after_salv_function:
on_after_salv_function for event after_salv_function of cl_salv_events importing e_salv_function
There is no code in the method implementation - but adding this event handler now causes a synchronization to occur after the Change Layout is done. -
ALV Grid Control - Modifiy data in total and subtotal lines
Hello all,
I´am creating a report using ALV Grid Control. This report calculates (using delivered and returned materials) for each vendor/material-combination the return quote.
Using the totals and subtotals function for different characteristics I want to calculate the return quote for the selected characteristic. Example:
Material delivered returned quote
..4711 . . . 500 . . . 5 . . . . 1 (=returned*100/delivered)
..4711 . . . 400 . . . 10 . . . . 2,5
. SUM . . . 900 . . . 15 . . . . 3,5 <-- 3,5 is the sum but I want display the calculated value 1,667
Is there a possibility to modify data in the total and subtotal lines.
Thank you for your answer
Best regards
Thomasyou said instead of 3.5 you want to show 1,667 ..
how is it possible...
3,5 become 1,667
i thought you are doing any conversions...
vijay -
Can i change the values in total column in ALV Grid program. I had made one report with 3 hirerchy level and for first hirerchy i need different total values just for one column as total values are misleading the users. is it possible to change the value total field in ALV?
hi
make the fields for which u r displaying total as editable.
so when ever u make changes in the column,
see the sample code, i have done a similar program
FORM DATA_CHANGED_MATRIX USING P_ER_DATA_CHANGED TYPE REF TO
CL_ALV_CHANGED_DATA_PROTOCOL P_ONF4 type C E_UCOMM TYPE SY-UCOMM.
DATA: VALUE LIKE YRECORDINGD_QDMS-SCORE.
CLEAR VALUE.
data: begin of wa_tot,
TOTAL_SCORE like yrecordingd_qdms-score,
end of wa_tot.
DATA: BEGIN OF WA_DATA,
SRNO type i,
LOCATION LIKE YCONCERNS_QDMS-LOCATION,
LOC_DESC LIKE YLOCATION_QDMST-LOC_DESC,
TOTAL_SCORE LIKE YRECORDINGD_QDMS-SCORE,
END OF WA_DATA.
FIELD-SYMBOLS: <LS_VALUE1> TYPE ANY,
<LS_VALUE2> TYPE ANY.
DATA: L_VALUE TYPE LVC_VALUE,
ls_mod_cell type lvc_s_modi.
SORT P_ER_DATA_CHANGED->MT_MOD_CELLS BY ROW_ID.
LOOP AT P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
EXPORTING
I_ROW_ID = LS_MOD_CELL-row_id
I_FIELDNAME = LS_MOD_CELL-fieldname
IMPORTING
E_VALUE = L_VALUE.
VALUE = L_VALUE.
IF VALUE < 100.
READ TABLE <TEMP_TAB> INTO <TEMP_WA> INDEX LS_MOD_CELL-ROW_ID.
MOVE-CORRESPONDING <TEMP_WA> TO WA_TOT.
WA_TOT-TOTAL_SCORE = WA_TOT-TOTAL_SCORE + VALUE.
MOVE-CORRESPONDING WA_TOT TO <TEMP_WA>.
MODIFY <TEMP_TAB> FROM <TEMP_WA> INDEX LS_MOD_CELL-ROW_ID.
CALL METHOD GO_GRID->REFRESH_TABLE_DISPLAY.
ELSE.
CLEAR WA_DATA.
ENDIF.
CLEAR:WA_TOT,VALUE.
ENDLOOP.
ENDFORM. -
Subtotal in ALV grid for a particular type and Grand total in ALV
Hi,
I need to have sub total for a particular type(eg: goods, services).. and grand total at end in ALV grid..
ALV output required as below:
Type VAT registration number Country Total Gross Amounts Total Tax Amounts Total Amount, ex-tax
Goods ATU12345678 AT 222.42 0 222.42
Goods NL123456789B02 NL 3,417.00 0 3,417.00
Goods Total 3,639.42 - 3,639.42
Services ATU12345678 AT 2,342.34 0 2,342.34
Services NL123456789B02 NL 223.33 0 223.33
Services Total 2,565.67 - 2,565.67
Grand Total 6,205.09 - 6,205.09
Let me as to how to achieve the above type in ALV grid...
Regards
Shivacheck this link..
Grand Totals in ALV grid disply function module
or do like this..
REPORT ZALVTESTFORSUBTOTAL.
tables:pa0008.
type-pools:slis.
types:begin of ty_pa0008,
pernr like pa0008-pernr,
begda like pa0008-begda,
endda like pa0008-endda,
ansal like pa0008-ansal,
lga01 like pa0008-lga01,
bet01 like pa0008-bet01,
end of ty_pa0008.
data:it_pa0008 type standard table of ty_pa0008 with header line.
data:it_fieldcat type SLIS_T_FIELDCAT_ALV,
wa_fieldcat type slis_fieldcat_alv,
it_layout type slis_layout_alv,
WA_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
select-options:s_pernr for pa0008-pernr.
start-of-selection.
perform getD_data.
perform disp_alv.
*& Form getD_data
text
--> p1 text
<-- p2 text
form getD_data .
select pernr
begda
endda
ansal
lga01
bet01
from pa0008
into table it_pa0008
where pernr in s_pernr.
sort it_pa0008 by pernr begda descending.
endform. " getD_data
*& Form disp_alv
text
--> p1 text
<-- p2 text
form disp_alv .
wa_fieldcat-fieldname = 'PERNR'.
wa_FIELDCAT-REPTEXT_DDIC = 'Personnel no'.
*WA_FIELDCAT-no_subtotals = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BEGDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'Start date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENDDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'End date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ANSAL'.
wa_FIELDCAT-REPTEXT_DDIC = 'Annula salary'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'LGA01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Wage Type'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BET01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Amount for wagetype'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
DATA: sort TYPE slis_sortinfo_alv,
it_sort TYPE slis_t_sortinfo_alv.
sort-fieldname = 'PERNR'.
sort-subtot = 'X'.
SORT-UP = 'X'.
APPEND sort TO it_sort.
*sort-fieldname = 'BEGDA'.
*SORT-NO_SUBTOTS = 'X'.
*APPEND sort TO it_sort.
IT_layout-totals_text = 'total text'.
IT_layout-subtotals_text = 'Subtotal text'.
*WA_EVENTS-NAME = 'SUBTOTAL TEXT'.
*WA_EVENTS-FORM = 'SUBTOTAL TEXT'.
*APPEND WA_EVENTS TO IT_EVENTS.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = it_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_sort = it_sort
it_events = it_events
TABLES
t_outtab = it_pa0008 .
endform. " disp_alv -
Total for a Numeric field in ALV Grid display
Hi all,
I am not getting the Total for a Numeric field in ALV Grid output. What might be the problem.
Regards,
Balavardhan.KCheck this code for subtotals and totals..
REPORT ZYFI_REPT007
NO STANDARD PAGE HEADING
LINE-SIZE 300
LINE-COUNT 50
MESSAGE-ID ZYFI.
TABLES : COOI, " Commitments Management: Line Items
LFA1, " Vendor master (general section)
VBEP,
RKPLN.
TABLE TYPES AND INTERNAL TABLES *
DATA : BEGIN OF TYP_COOI ,
OBJNR LIKE COOI-OBJNR,
SAKTO LIKE COOI-SAKTO,
MEGBTR LIKE COOI-MEGBTR,
MEINH LIKE COOI-MEINH,
WKGBTR LIKE COOI-WKGBTR,
REFBN LIKE COOI-REFBN,
RFPOS LIKE COOI-RFPOS,
SGTXT LIKE COOI-SGTXT,
BUDAT LIKE COOI-BUDAT,
LIFNR LIKE COOI-LIFNR,
END OF TYP_COOI.
DATA : BEGIN OF TYP_LFA1 ,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF TYP_LFA1.
DATA : BEGIN OF IT_OUTTAB OCCURS 0,
OBJNR LIKE COOI-OBJNR,
SAKTO LIKE COOI-SAKTO,
MEGBTR LIKE COOI-MEGBTR,
MEINH LIKE COOI-MEINH,
WKGBTR LIKE COOI-WKGBTR,
REFBN LIKE COOI-REFBN,
RFPOS LIKE COOI-RFPOS,
SGTXT LIKE COOI-SGTXT,
BUDAT LIKE COOI-BUDAT,
LIFNR LIKE COOI-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF IT_OUTTAB.
DATA : IT_COOI LIKE TYP_COOI OCCURS 0 WITH HEADER LINE,
IT_LFA1 LIKE TYP_LFA1 OCCURS 0 WITH HEADER LINE.
*-- ALV Declarations
TYPE-POOLS SLIS.
DATA: IT_EVENTS TYPE SLIS_T_EVENT,
GS_EVENT TYPE SLIS_ALV_EVENT,
wa_fldcat type slis_fieldcat_alv.
DATA: S_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_PRINT TYPE SLIS_PRINT_ALV.
DATA: IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: IT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: V_REPID LIKE SY-REPID.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_KOKRS FOR COOI-KOKRS NO-EXTENSION NO INTERVALS,
" Controlling Area
S_BUKRS FOR COOI-BUKRS NO-EXTENSION NO INTERVALS,
" Company code
S_GJAHR FOR COOI-GJAHR NO-EXTENSION NO INTERVALS,
" Fiscal Year
S_OBJNR FOR RKPLN-AUFNR MATCHCODE OBJECT ORDE,
" Internal order
S_SAKTO FOR COOI-SAKTO MATCHCODE OBJECT KART,
" Cost Element
S_BUDAT FOR COOI-BUDAT, " Debit Date
S_LIFNR FOR COOI-LIFNR. " Vendor
SELECTION-SCREEN END OF BLOCK B1.
S T A R T O F S E L E C T I O N *
START-OF-SELECTION.
*-- Read data
PERFORM GET_DATA.
E N D O F S E L E C T I O N *
END-OF-SELECTION.
*-- Process the data and prepare the output data
PERFORM CALCULATE_FINAL_INFO.
*--Display Report output
PERFORM DISPLAY_REPORT.
FORM CALCULATE_FINAL_INFO *
Process the data and prepare final internal table *
FORM CALCULATE_FINAL_INFO.
DATA : L_OBJNR LIKE COOI-OBJNR.
SORT IT_LFA1 BY LIFNR.
DELETE ADJACENT DUPLICATES FROM IT_LFA1 COMPARING LIFNR.
LOOP AT IT_COOI.
L_OBJNR = IT_COOI-OBJNR+2(20).
SHIFT L_OBJNR LEFT DELETING LEADING '0'.
IF L_OBJNR IN S_OBJNR.
READ TABLE IT_LFA1 WITH KEY LIFNR = IT_COOI-LIFNR.
IF SY-SUBRC EQ 0.
IT_OUTTAB-NAME1 = IT_LFA1-NAME1.
ENDIF.
MOVE-CORRESPONDING IT_COOI TO IT_OUTTAB.
CLEAR IT_OUTTAB-OBJNR.
IT_OUTTAB-OBJNR = L_OBJNR.
APPEND IT_OUTTAB.
CLEAR IT_OUTTAB.
CLEAR IT_LFA1.
CLEAR L_OBJNR.
ENDIF.
ENDLOOP.
ENDFORM.
*& Form GET_DATA
Fetch the Data from the table COOI and LFA1
FORM GET_DATA.
SELECT OBJNR
SAKTO
MEGBTR
MEINH
WKGBTR
REFBN
RFPOS
SGTXT
BUDAT
LIFNR
FROM COOI
INTO TABLE IT_COOI
WHERE BUDAT IN S_BUDAT
AND LIFNR IN S_LIFNR
AND KOKRS IN S_KOKRS
AND BUKRS IN S_BUKRS
AND GJAHR IN S_GJAHR
AND SAKTO IN S_SAKTO.
IF SY-SUBRC EQ 0 .
Get the Vendor name from LFA1
SELECT LIFNR
NAME1
FROM LFA1
INTO TABLE IT_LFA1
FOR ALL ENTRIES IN IT_COOI
WHERE LIFNR EQ IT_COOI-LIFNR.
ELSE.
MESSAGE I999 WITH TEXT-013.
ENDIF.
ENDFORM. " GET_DATA
*& Form DISPLAY_REPORT
Display the output
FORM DISPLAY_REPORT.
PERFORM BUILD_CATALOG.
PERFORM FRM_PREPARE_EVENT_LIST TABLES IT_EVENTS.
IF NOT IT_OUTTAB[] IS INITIAL.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FLDCAT
IT_SORT = IT_SORT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = IT_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ELSE.
MESSAGE I999 WITH TEXT-013.
ENDIF.
ENDFORM. " DISPLAY_REPORT
*& Form BUILD_CATALOG
Build the Field catalog for the ALV Report
FORM BUILD_CATALOG.
DATA: V_INDEX LIKE SY-TABIX.
V_REPID = SY-REPID.
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'IT_OUTTAB'
I_INCLNAME = V_REPID
CHANGING
CT_FIELDCAT = IT_FLDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
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 IT_FLDCAT WITH KEY FIELDNAME = 'WKGBTR'
TABNAME = 'IT_OUTTAB' INTO WA_FLDCAT.
IF SY-SUBRC EQ 0.
WA_FLDCAT-DO_SUM = 'X'.
MODIFY IT_FLDCAT FROM WA_FLDCAT INDEX SY-TABIX.
ENDIF.
READ TABLE IT_FLDCAT WITH KEY FIELDNAME = 'OBJNR'
TABNAME = 'IT_OUTTAB' INTO WA_FLDCAT.
IF SY-SUBRC EQ 0.
WA_FLDCAT-SELTEXT_L = 'Order'.
WA_FLDCAT-COL_POS = 1.
WA_FLDCAT-DDICTXT = 'L'.
MODIFY IT_FLDCAT FROM WA_FLDCAT INDEX SY-TABIX.
ENDIF.
LS_SORT-FIELDNAME = 'OBJNR'.
LS_SORT-SPOS = 1.
LS_SORT-UP = 'X'.
LS_SORT-SUBTOT = 'X'.
APPEND LS_SORT TO IT_SORT.
ENDFORM. " BUILD_CATALOG
*& Form FRM_PREPARE_EVENT_LIST
Build the Events
FORM FRM_PREPARE_EVENT_LIST TABLES IT_EVENTS TYPE SLIS_T_EVENT.
CLEAR GS_EVENT.
GS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
GS_EVENT-FORM = 'TOP_OF_PAGE_REPORT'.
APPEND GS_EVENT TO IT_EVENTS.
ENDFORM. " FRM_PREPARE_EVENT_LIST
TOP OF PAGE
FORM TOP_OF_PAGE_REPORT.
CALL FUNCTION 'Z_YREPORT_HEADER'
EXPORTING
DL_TITLE = SY-TITLE
DL_REPID = SY-CPROG
DL_LINSZ = SY-LINSZ
EXCEPTIONS
OTHERS = 1.
ENDFORM. " FRM_TOP_OF_PAGE_REPORT
*& Form USER_COMMAND
Drill Down Functionality to Call the Transaction ME23
FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM
P_SELFIELD TYPE SLIS_SELFIELD.
DATA : L_INDEX LIKE SY-INDEX,
L_REFBN LIKE COOI-REFBN.
L_INDEX = P_SELFIELD-TABINDEX. " holds the selected table index
CLEAR L_REFBN.
CASE P_UCOMM.
*-- On Double Click
WHEN '&IC1'.
CLEAR L_REFBN.
*-- Read the Current Line
READ TABLE IT_OUTTAB INDEX L_INDEX.
IF SY-SUBRC EQ 0.
L_REFBN = IT_OUTTAB-REFBN.
IF NOT L_REFBN IS INITIAL.
*-- Set the BES Paramater Id to the Current line Purchase Order Number
SET PARAMETER ID 'BES' FIELD L_REFBN.
*-- Call the Transaction Purchase Order Display with the above PO Number
CALL TRANSACTION 'ME23' AND SKIP FIRST SCREEN.
ENDIF.
ELSE.
MESSAGE E999 WITH TEXT-014.
ENDIF.
ENDCASE.
ENDFORM. " USER_COMMAND -
How to get Grand Total Text in ALV GRID
Hi Folks,
I am able to get the SUBTOTAL TEXT .....But i need...
How to get Grand Total Text in ALV GRID Display...
Can any one give a Solution for this...Hi Surendar,
Check out this code.. this is showing Total Text in Toal line in the very first column.
REPORT zsales_ord_det_1 .
TABLES: ztable_10.
TYPE-POOLS: slis.
DATA: BEGIN OF it OCCURS 0,
srno(6) type c,
name LIKE ztable_10-name,
age LIKE ztable_10-age,
END OF it.
DATA : BEGIN OF it_temp OCCURS 0,
name LIKE ztable_10-name,
age LIKE ztable_10-age,
END OF it_temp.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA: v_repid LIKE sy-repid,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
gs_layout TYPE slis_layout_alv,
gd_layout TYPE slis_layout_alv,
i_sort TYPE STANDARD TABLE OF slis_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
START-OF-SELECTION.
v_repid = sy-repid.
SELECT * FROM ztable_10 INTO TABLE it_temp.
LOOP AT it_temp .
it-srno = 'Total'.
it-name = it_temp-name.
it-age = it_temp-age.
APPEND it.
ENDLOOP.
END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = v_repid
i_internal_tabname = 'IT'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = v_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = i_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'SRNO'.
wa_fieldcat-tabname = it.
append wa_fieldcat to i_fieldcat.
LOOP AT i_fieldcat INTO wa_fieldcat.
IF wa_fieldcat-fieldname = 'AGE'.
wa_fieldcat-do_sum = 'X'.
MODIFY i_fieldcat FROM wa_fieldcat.
ENDIF.
IF wa_fieldcat-fieldname = 'SRNO'.
Hide this field so that it can display it's content i.e.
Total text in Subtotal level
wa_fieldcat-tech = 'X'.
wa_fieldcat-no_out = 'X'.
MODIFY i_fieldcat FROM wa_fieldcat TRANSPORTING tech no_out.
ENDIF.
ENDLOOP.
wa_sort-spos = 1.
wa_sort-fieldname = 'SRNO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort.
gd_layout-no_totalline = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
is_layout = gd_layout
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = i_sort
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it
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.
Regards,
Seema
Maybe you are looking for
-
How to restore accounts and Mail?
My Mail account suddenly disappeared (MacBook, 10.5.8, POP). So I reentered all the settings and logged in again. Many emails were missing so I deleted the Envelope file and restarted Mail. Now it is sort of back, but one of my accounts is missing, a
-
Modify Sales order Item additional tab B
I need to modify Sales order item additional tab B ...by removing the exisitng fields and should add some new fields ....which is ok. But does it have any impact becoz the same screen fields coulbe used in any of the other transaction .......i just
-
Is there a way to CAPTURE audio/video off the net then run it m.m. prsntn
I'm fairly new to the mac genre. In windows we had apps like Camtasia to capture audio/video off the net. I was hoping something like that would be avail for the mac and then once capture it how would I edit it and include it in a presentation softwa
-
Anyone heard when this will be released? Apple only says "October". That could be the 1st or the 31st. Anything ideas?
-
What r the jdbc options available?
hi all, i am using a proxy to JDBC scenario.... i need to update the jdbc by deleting the already existing data could u tell me wat r the possible ways of doing this and which one is best and why?