Regarding the 'TOTALS' in ALV's
Hi friends,
I have a doubt in ALV while displaying totals.
How can we display the "totals" immediately when the ALV output is displayed. I tried many ways but when im clicking on the 'Summation' symbol in the output of the ALV then only the 'Totals' or 'Subtotals' are being displayed.
Please give me some helpfull tips...
Regards
Pradeep Goli
hi,
take reference of this exp...
*FORM FOR DISPLAY DATA
FORM display_data.
PERFORM fill_layout_structure.
PERFORM fill_field_catalog_table.
PERFORM get_event USING it_event.
PERFORM fill_listheader USING it_listheader.
PERFORM call_alv_function.
ENDFORM. "display_data
*FORM FOR ALV LAYOUT STRUCTURE
FORM fill_layout_structure.
CLEAR st_layout.
st_layout-colwidth_optimize = 'X'.
st_layout-zebra = 'X'.
st_layout-f2code = '&ETA'.
st_layout-detail_popup = 'X'.
st_layout-colwidth_optimize = 'X'.
ENDFORM. "fill_layout_structure
*FORM FOR ALV FIELD CATALOG TABLE
FORM fill_field_catalog_table .
PERFORM fill_field_catalog USING :
'SAKNR' 'G/L Account No' 15 'IT_DATA' 'X' space,
'TXT50' 'A/C Description' 50 'IT_DATA' space space,
'BO' 'BO' 15 'IT_DATA' space 'X',
'FACT' 'Factories' 15 'IT_DATA' space 'X',
'TOTAL_BO' 'BO Total' 15 'IT_DATA' space 'X'.
ENDFORM. "fill_field_catalog_table
*FORM FOR FILLING FIELD CATALOG
FORM fill_field_catalog USING f d l t p s.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
STATICS v_pos TYPE i VALUE 1.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = v_pos.
wa_fieldcat-fieldname = f.
wa_fieldcat-seltext_m = d.
wa_fieldcat-tabname = t.
wa_fieldcat-outputlen = l.
wa_fieldcat-fix_column = p.
wa_fieldcat-do_sum = s.
APPEND wa_fieldcat TO it_fieldcat.
v_pos = v_pos + 1.
ENDFORM. "fill_field_catalog
*FORM FOR ALV FUNCTIONS
FORM call_alv_function.
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 = ' '
I_CALLBACK_TOP_OF_PAGE = '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 = st_layout
it_fieldcat = it_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT =
it_events = it_event[]
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_data[]
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. "call_alv_function
Similar Messages
-
Calculating the total in alv and displaying the date
Hi,
I am trying to calculate the totals of netwr and fkimg in a report but the following coding cannot giv me the right answer so if there is anyone with the solution for this problem may you please help me out and how can i display the date on my report......here is my coding:
REPORT Z_DAILY_STOCK_NEW.
TYPE-POOLS: SLIS.
TABLES
TABLES: vbrk, kna1,vbrp,vbap,vbak, sflight.
ALV FIELDS
DATA: it_fieldcat TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA: w_cnt LIKE sy-tabix.
total ref to data.
t_alv LIKE TABLE OF s_error WITH HEADER LINE.
DATA: gr_layout TYPE slis_layout_alv,
gr_tab_group TYPE slis_t_sp_group_alv,
gr_repid LIKE sy-repid,
gr_events TYPE slis_t_event,
gr_print TYPE slis_print_alv,
gr_user TYPE slis_formname VALUE 'USER_COMMAND'.
SELECTION SCREEN
SELECT-OPTIONS:
s_werks FOR vbrp-werks,
s_auart FOR vbak-auart.
DEFINITION OF AN INTERNAL TABLE
DATA: begin of i_stocktab occurs 0,
kunag LIKE vbrk-kunag,
name1 LIKE kna1-name1,
ort01 LIKE kna1-ort01,
inco1 LIKE vbrk-inco1,
vkgrp LIKE vbrp-vkgrp,
fkimg LIKE vbrp-fkimg,
netwr LIKE vbrk-netwr,
end of i_stocktab.
START OF SELECTION
SELECT vbrkkunag kna1name1 kna1ort01 vbrkinco1 vbrp~vkgrp
vbrpfkimg vbrknetwr
FROM kna1 inner join vbrk on kna1kunnr EQ vbrkkunrg
inner join vbak on kna1kunnr EQ vbakkunnr
inner join vbrp on vbrkvbeln EQ vbrpvbeln
INTO i_stocktab
WHERE vbrp~werks IN s_werks
AND vbak~auart IN s_auart.
APPEND i_stocktab.
ENDSELECT.
*DATA tb_alv TYPE i_stocktab WITH HEADER LINE.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM build_event.
PERFORM build_print.
PERFORM calc_total.
PERFORM display_alv_report.
FORM build_fieldcatalog.
w_cnt = 1.
it_fieldcat-fieldname = 'KUNAG'.
it_fieldcat-seltext_m = 'Soldtp'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
it_fieldcat-key = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'NAME1'.
it_fieldcat-seltext_m = 'Name'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'ORT01'.
it_fieldcat-seltext_m = 'City'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'INC01'.
it_fieldcat-seltext_m = 'Incoterms'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'VKGRP'.
it_fieldcat-seltext_m = 'Sales Group'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'FKIMG'.
it_fieldcat-seltext_m = 'Invoiced Qty'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
*it_fieldcat-do_sum = 'x'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'NETWR'.
it_fieldcat-seltext_m = 'Invoiced Value'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
it_fieldcat-do_sum = 'x'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
ENDFORM.
FORM build_layout.
gr_layout-no_input = 'X'.
gr_layout-colwidth_optimize = 'X'.
gr_layout-totals_text = 'Totals: '(201).
gr_layout-detail_popup = 'X'.
ENDFORM.
FORM build_event.
DATA i_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gr_events[].
READ TABLE gr_events WITH KEY name = slis_ev_user_command
INTO i_event.
if sy-subrc = 0.
MOVE gr_user TO i_event-form.
APPEND i_event TO gr_events.
endif.
ENDFORM.
*FORM calc_total.
LOOP AT it_fieldcat into wa_fieldcat
WHERE fieldname EQ 'FKIMG' OR
fieldname EQ 'NETWR'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-datatype = 'QUAT'.
modify it_fieldcat from wa_fieldcat.
ENDLOOP.
*ENDFORM.
FORM build_print.
gr_print-reserve_lines = '2'.
gr_print-no_coverpage = 'X'.
ENDFORM.
FORM calc_total.
DATA: total type ref to data,
subtotal1 type ref to data.
field-symbols <fkimg> like sflight.
field-symbols <netwr> like sflight.
call method grid1-> get_subtotals
importing
ep_collect00 = subtotal
ep_collect01 = total.
assign total to <fkimg>.
assign total to <netwr>.
ENDFORM.
*& FUNCTION ALV DISPLAY
FORM display_alv_report.
gr_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = gr_repid
I_CALLBACK_USER_COMMAND = slis_ev_user_command
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE' " see FORM
IS_LAYOUT = gr_layout
IT_FIELDCAT = it_fieldcat[]
IT_SPECIAL_GROUPS = gr_tab_group
I_SAVE = 'X'
IT_EVENTS = gr_events
IS_PRINT = gr_print
TABLES
t_outtab = i_stocktab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
FORM top-of-page.
*ALV Header deaclarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc TYPE c.
*Title
wa_header-typ = 'H'.
wa_header-info = 'Report for daily Stock Returns'.
APPEND wa_header TO t_header.
CLEAR wa_header.
*Total No. Records Selected
DESCRIBE TABLE i_stocktab LINES ld_lines.
ld_linesc = ld_lines.
CONCATENATE 'Total No. of Records Selected:' ld_linesc
INTO t_line SEPARATED BY space.
wa_header-typ = 'A'.
wa_header-info = t_line.
APPEND wa_header TO t_header.
CLEAR: wa_header, t_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM.Try This
REPORT z_daily_stock_new.
TYPE-POOLS: slis.
* TABLES
TABLES: vbrk, kna1,vbrp,vbap,vbak, sflight.
* ALV FIELDS
DATA: it_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA: w_cnt LIKE sy-tabix.
* total ref to data.
* t_alv LIKE TABLE OF s_error WITH HEADER LINE.
DATA: gr_layout TYPE slis_layout_alv,
gr_tab_group TYPE slis_t_sp_group_alv,
gr_repid LIKE sy-repid,
gr_events TYPE slis_t_event,
gr_print TYPE slis_print_alv,
gr_user TYPE slis_formname VALUE 'USER_COMMAND'.
* SELECTION SCREEN
SELECT-OPTIONS:
s_werks FOR vbrp-werks,
s_auart FOR vbak-auart.
* DEFINITION OF AN INTERNAL TABLE
DATA: BEGIN OF i_stocktab OCCURS 0,
kunag LIKE vbrk-kunag,
name1 LIKE kna1-name1,
ort01 LIKE kna1-ort01,
inco1 LIKE vbrk-inco1,
vkgrp LIKE vbrp-vkgrp,
fkimg LIKE vbrp-fkimg,
netwr LIKE vbrk-netwr,
END OF i_stocktab.
* START OF SELECTION
SELECT vbrk~kunag kna1~name1 kna1~ort01 vbrk~inco1 vbrp~vkgrp
vbrp~fkimg vbrk~netwr
FROM kna1 INNER JOIN vbrk ON kna1~kunnr EQ vbrk~kunrg
INNER JOIN vbak ON kna1~kunnr EQ vbak~kunnr
INNER JOIN vbrp ON vbrk~vbeln EQ vbrp~vbeln
INTO i_stocktab
WHERE vbrp~werks IN s_werks
AND vbak~auart IN s_auart.
APPEND i_stocktab.
ENDSELECT.
*DATA tb_alv TYPE i_stocktab WITH HEADER LINE.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM build_event.
PERFORM build_print.
PERFORM calc_total.
PERFORM display_alv_report.
* FORM build_fieldcatalog *
FORM build_fieldcatalog.
w_cnt = 1.
it_fieldcat-fieldname = 'KUNAG'.
it_fieldcat-seltext_m = 'Soldtp'.
it_fieldcat-emphasize = 'X'.
it_fieldcat-key = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'NAME1'.
it_fieldcat-seltext_m = 'Name'.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'ORT01'.
it_fieldcat-seltext_m = 'City'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
* w_cnt = w_cnt + 1.
* it_fieldcat-fieldname = 'INC01'.
* it_fieldcat-seltext_m = 'Incoterms'.
* it_fieldcat-emphasize = 'X'.
* APPEND it_fieldcat TO it_fieldcat.
* CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'VKGRP'.
it_fieldcat-seltext_m = 'Sales Group'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'FKIMG'.
it_fieldcat-seltext_m = 'Invoiced Qty'.
it_fieldcat-emphasize = 'X'.
it_fieldcat-ref_tabname = 'VBRP' .
it_fieldcat-ref_fieldname = 'FKIMG' .
it_fieldcat-do_sum = 'X' .
* *it_fieldcat-do_sum = 'x'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
clear it_fieldcat .
it_fieldcat-fieldname = 'NETWR'.
it_fieldcat-seltext_m = 'Invoiced Value'.
it_fieldcat-emphasize = 'X'.
it_fieldcat-ref_tabname = 'VBRP' .
it_fieldcat-ref_fieldname = 'NETWR' .
it_fieldcat-do_sum = 'X' .
* it_fieldcat-do_sum = 'x'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
ENDFORM.
* FORM build_layout *
FORM build_layout.
gr_layout-no_input = 'X'.
gr_layout-colwidth_optimize = 'X'.
gr_layout-totals_text = 'Totals: '(201).
gr_layout-detail_popup = 'X'.
ENDFORM.
* FORM build_event *
FORM build_event.
DATA i_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gr_events[].
READ TABLE gr_events WITH KEY name = slis_ev_user_command
INTO i_event.
IF sy-subrc = 0.
MOVE gr_user TO i_event-form.
APPEND i_event TO gr_events.
ENDIF.
ENDFORM.
*FORM calc_total.
* LOOP AT it_fieldcat into wa_fieldcat
* WHERE fieldname EQ 'FKIMG' OR
* fieldname EQ 'NETWR'.
* wa_fieldcat-do_sum = 'X'.
* wa_fieldcat-datatype = 'QUAT'.
* modify it_fieldcat from wa_fieldcat.
* ENDLOOP.
*ENDFORM.
FORM build_print.
gr_print-reserve_lines = '2'.
gr_print-no_coverpage = 'X'.
ENDFORM.
* FORM calc_total *
FORM calc_total.
DATA: total TYPE REF TO data,
subtotal1 TYPE REF TO data.
* FIELD-SYMBOLS <fkimg> LIKE sflight.
* FIELD-SYMBOLS <netwr> LIKE sflight.
* CALL METHOD grid1-> get_subtotals
* IMPORTING
* ep_collect00 = subtotal
* ep_collect01 = total.
* ASSIGN total TO <fkimg>.
* ASSIGN total TO <netwr>.
ENDFORM.
*& FUNCTION ALV DISPLAY
FORM display_alv_report.
gr_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gr_repid
i_callback_user_command = slis_ev_user_command
i_callback_top_of_page = 'TOP-OF-PAGE' " see FORM
is_layout = gr_layout
it_fieldcat = it_fieldcat[]
it_special_groups = gr_tab_group
i_save = 'X'
it_events = gr_events
is_print = gr_print
TABLES
t_outtab = i_stocktab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
* FORM top-of-page *
FORM top-of-page.
*ALV Header deaclarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc TYPE c.
*Title
wa_header-typ = 'H'.
wa_header-info = 'Report for daily Stock Returns'.
APPEND wa_header TO t_header.
CLEAR wa_header.
*Total No. Records Selected
DESCRIBE TABLE i_stocktab LINES ld_lines.
ld_linesc = ld_lines.
CONCATENATE 'Total No. of Records Selected:' ld_linesc
INTO t_line SEPARATED BY space.
wa_header-typ = 'A'.
wa_header-info = t_line.
APPEND wa_header TO t_header.
CLEAR: wa_header, t_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM. -
Regarding the Extract in alv report
Hi gurus,
please explain to me what is the Extract in ALV's.
i have an alv report in which they declaired avariable like disextract and assigned a radio button, if the radiobutton is check then the data is stored in extract.what is the use of the extract?Hi,
Please check below thread;
Extract from ALV List
Regards
Jana -
hi,
i am making report in alv in which i have to display the sub totals and den full total.
is it possible to display sub total in ALV acccording to material type wise or itemid wise.
plzz help me with some example.
If find useful he or she will definately rewarded.........Hi,
The following example for sub totall for ALV report..
u have to pass do_sum = 'X'. for perticuler fileds.
if it is use full answer reward me a points..
*& Report ZDEL_ALV1
*Description: This ALV interactive report is display Delivary
status
REPORT zdel_alv1 NO STANDARD PAGE HEADING LINE-SIZE 255 LINE-COUNT 60.
*TABLE DECLARATION
TABLES : likp, "Delivery Header Data
lips, "Delivery item Data
vbup. "sales document item status
TYPE-POOLS : slis.
*SRUCTURE DECLARATION
*THIS TABLE FOR HEADER DETAILS
TYPES : BEGIN OF t_likp ,
vbeln LIKE likp-vbeln, "Delivery number
kosta like vbup-kosta,
kunnr LIKE likp-kunnr, "Customer number
wadat LIKE likp-wadat, "Planned goods movement date
ernam LIKE likp-ernam, "Name of person
vkorg LIKE likp-vkorg, "Sales organization
lfart LIKE likp-lfart, "DELIVERY TYPE
ntgew LIKE likp-ntgew, "NET WEIGHT
END OF t_likp.
*THIS TABLE FOR ITEM DETAILS
TYPES : BEGIN OF t_lips ,
vbeln LIKE lips-vbeln, "Delivery number
posnr LIKE lips-posnr, "delivery item
matnr LIKE lips-matnr, "Material number
lfimg LIKE lips-lfimg, "Actual quantity delivered
ntgew LIKE lips-ntgew, "Net weight
exbwr LIKE lips-exbwr, "Externally entered posting amount
arktx LIKE lips-arktx, "Short text SO Item
END OF t_lips.
*THIS IS FOR FINAL OUTPUT
TYPES : BEGIN OF t_vbup ,
vbeln LIKE likp-vbeln, "Delivery number
kosta LIKE vbup-kosta, "Picking status/Putaway status
posnr LIKE vbup-posnr, "delivery item
matnr LIKE lips-matnr, "Material number
lfimg LIKE lips-lfimg, "Actual quantity delivered
ntgew LIKE lips-ntgew, "Net weight
exbwr LIKE lips-exbwr, "Externally entered posting amount
arktx LIKE lips-arktx, "SHORT text SO Item
description(20), "for display text
END OF t_vbup.
*INTERNAL TABLES
DATA : i_likp TYPE STANDARD TABLE OF t_likp.
DATA : i_lips TYPE STANDARD TABLE OF t_lips.
DATA : i_vbup TYPE STANDARD TABLE OF t_vbup.
DATA : repid LIKE sy-repid.
DATA : delivar1(10) TYPE c.
*WORK AREA
DATA : wa_likp TYPE t_likp.
DATA : wa_lips TYPE t_lips.
DATA : wa_vbup TYPE t_vbup.
DATA: i_vbup1 LIKE wa_vbup OCCURS 0 WITH HEADER LINE.
*SLIS TABLE DECLARATIONS
DATA: i_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
i_events TYPE slis_t_event,
w_events TYPE slis_alv_event,
i_fieldcat1 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
i_layout TYPE slis_layout_alv.
*SELECTING RANGE OF VALUES
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_vbeln FOR likp-vbeln,
s_kunnr FOR likp-kunnr,
s_wadat FOR likp-wadat.
SELECTION-SCREEN END OF BLOCK b1 .
*CHOOSE ONE CHECK BOX FOR DISPLAYING THE DELIVARY STATUS
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS : cb_kostc AS CHECKBOX,"DEFAULT 'X',
cb_kosta AS CHECKBOX,
cb_kostb AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b2.
*INTIALIZATION CHECK
INITIALIZATION.
repid = sy-repid.
*START-OF-SELECTION
START-OF-SELECTION.
PERFORM get_data.
PERFORM get_field.
PERFORM GET_EVENTS.
PERFORM display.
*END-OF-SELECTION
END-OF-SELECTION.
*& Form RUCOMM
This form getting details from lips table for displaying
the item details and all select statements for delivary status
-->R_UCOMM text
-->RS_SELFIELDtext
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE
slis_selfield.
IF rs_selfield-fieldname = 'VBELN'.
delivar1 = rs_selfield-value.
ENDIF.
IF cb_kostc = 'X'.
SELECT VBELN KOSTA FROM VBUP
INTO TABLE I_VBUP
WHERE VBELN IN DELIVAR
AND KOSTA = 'C'.
SELECT VBELN MATNR LFIMG EXBWR INTO TABLE I_LIPS FROM LIPS
WHERE VBELN EQ DELIVAR1.
REFRESH i_vbup1[].
CLEAR i_vbup1.
SELECT avbeln akosta bposnr bmatnr blfimg bntgew b~exbwr
b~arktx
INTO TABLE i_vbup
FROM vbup AS a INNER JOIN lips AS b
ON avbeln = bvbeln
WHERE a~vbeln EQ delivar1
AND kosta = 'C'.
ELSEIF cb_kosta = 'X'.
SELECT VBELN KOSTA FROM VBUP
INTO TABLE I_VBUP
WHERE VBELN IN DELIVAR
AND KOSTA = 'A'.
SELECT avbeln akosta bposnr bmatnr blfimg bntgew b~exbwr
b~arktx
INTO TABLE i_vbup
FROM vbup AS a INNER JOIN lips AS b
ON avbeln = bvbeln
WHERE a~vbeln EQ delivar1
AND kosta = 'A'.
ELSEIF cb_kostb = 'X'.
SELECT VBELN KOSTA FROM VBUP
INTO TABLE I_VBUP
WHERE VBELN IN DELIVAR
AND KOSTA = 'B'.
SELECT avbeln akosta bposnr bmatnr blfimg bntgew b~exbwr
b~arktx
INTO TABLE i_vbup
FROM vbup AS a INNER JOIN lips AS b
ON avbeln = bvbeln
WHERE a~vbeln EQ delivar1
AND kosta = 'B'.
ENDIF.
CLEAR i_vbup1.
LOOP AT i_vbup INTO wa_vbup.
i_vbup1-vbeln = wa_vbup-vbeln.
i_vbup1-kosta = wa_vbup-kosta.
IF wa_vbup-kosta = 'C'.
i_vbup1-description = 'COMPLETELY PROCESSED'.
ELSEIF wa_vbup-kosta = 'B'.
i_vbup1-description = 'PARTIALLY PROCESSED'.
ELSEIF wa_vbup-kosta = 'A'.
i_vbup1-description = 'NOT YET PROCESSED'.
ENDIF.
i_vbup1-posnr = wa_vbup-posnr.
i_vbup1-matnr = wa_vbup-matnr.
i_vbup1-lfimg = wa_vbup-lfimg.
i_vbup1-ntgew = wa_vbup-ntgew.
i_vbup1-exbwr = wa_vbup-exbwr.
i_vbup1-arktx = wa_vbup-arktx.
APPEND i_vbup1 .
ENDLOOP.
SORT i_vbup1 BY vbeln matnr lfimg.
DELETE ADJACENT DUPLICATES FROM i_vbup1 COMPARING vbeln matnr lfimg.
SELECT VBELN MATNR LFIMG EXBWR INTO TABLE I_LIPS FROM LIPS
WHERE VBELN EQ DELIVAR1.
*This function module for displaying the item details
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
it_fieldcat = i_fieldcat1[]
i_callback_top_of_page = 'TOP_OF_PAGE'
i_callback_user_command = 'USER_COMMAND1'
it_events = i_events
TABLES
t_outtab = i_vbup1
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.
CLEAR i_vbup1.
ENDFORM. "RUCOMM
*& Form USER_COMMAND1
text
-->R_UCOMM1 text
-->RS_SELFIELDtext
FORM user_command1 USING r_ucomm1 LIKE sy-ucomm rs_selfield1 TYPE
slis_selfield.
DATA: deliv(10) TYPE c.
IF rs_selfield1 = 'VBELN'.
deliv = rs_selfield1-value.
ENDIF.
SET PARAMETER ID 'VL' FIELD delivar1.
CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
ENDFORM. "USER_COMMAND1
*& Form GET_DATA
This form for getting the data from likp table
--> p1 text
<-- p2 text
FORM get_data .
SELECT VBELN KUNNR WADAT FROM LIKP INTO TABLE I_LIKP
WHERE VBELN IN S_VBELN
AND KUNNR IN S_KUNNR
AND WADAT IN S_WADAT.
REFRESH i_likp[].
CLEAR i_likp.
IF cb_kostc = 'X' AND cb_kosta = ' ' AND cb_kostb = ''.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND a~kosta = 'C'.
ELSEIF cb_kosta = 'X' AND cb_kostb = ' ' AND cb_kostc = ''.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND a~kosta = 'A'.
ELSEIF cb_kostb = 'X' AND cb_kosta = '' AND cb_kostc = ''.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND kosta = 'B'.
ELSEIF cb_kostc = 'X' AND cb_kosta = 'X' AND cb_kostb = 'X'.
SELECT avbeln akosta bkunnr bwadat bernam bvkorg blfart bntgew
INTO TABLE i_likp
FROM vbup AS a INNER JOIN likp AS b
ON avbeln = bvbeln
WHERE
b~kunnr IN s_kunnr
AND b~vbeln IN s_vbeln
AND b~wadat IN s_wadat
AND kosta NE ' '.
ENDIF.
DELETE ADJACENT DUPLICATES FROM i_likp.
ENDFORM. " GET_DATA
*& Form GET_FIELD
This form for defining the every fields from likp & lips tables
FORM get_field .
*This fields are retrieving from header table(likp)
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'VBELN'.
i_fieldcat-seltext_m = 'SALES ORDER NO'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'KUNNR'.
i_fieldcat-seltext_m = 'CUSTOMER NO'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'WADAT'.
i_fieldcat-seltext_m = 'DATE'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'ERNAM'.
i_fieldcat-seltext_m = 'NAME OF PERSON'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'VKORG'.
i_fieldcat-seltext_m = 'SALES ORGANIZATION'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'LFART'.
i_fieldcat-seltext_m = 'DELIVERY TYPE'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
i_fieldcat-fieldname = 'NTGEW'.
i_fieldcat-seltext_m = 'NET WEIGHT'.
i_fieldcat-do_sum = 'X'.
APPEND i_fieldcat TO i_fieldcat.
CLEAR i_fieldcat.
*This fields are retrieving from item table(lips)
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'VBELN'.
i_fieldcat1-seltext_m = 'DELIVAR NO'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'POSNR'.
i_fieldcat1-seltext_m = 'DELIVERY ITEM'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'MATNR'.
i_fieldcat1-seltext_m = 'MATERIAL NO'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'LFIMG'.
i_fieldcat1-seltext_m = 'ACTUAL QUANTITY'.
i_fieldcat1-do_sum = 'X'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'NTGEW'.
i_fieldcat1-seltext_m = 'NET WEIGHT'.
i_fieldcat1-do_sum = 'X'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'EXBWR'.
i_fieldcat1-seltext_m = 'AMOUNT'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'ARKTX'.
i_fieldcat1-seltext_m = 'SHORT TEXT FOR so ITEM'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
i_fieldcat1-fieldname = 'DESCRIPTION'.
i_fieldcat1-seltext_m = 'PICKING STATUS'.
APPEND i_fieldcat1 TO i_fieldcat1.
CLEAR i_fieldcat1.
ENDFORM. " GET_FIELD
*& Form GET_EVENTS
This form defining the events
*FORM GET_EVENTS .
CLEAR W_EVENTS.
W_EVENTS-NAME = 'USER_COMMAND'.
W_EVENTS-FORM = 'RUCOMM'.
APPEND W_EVENTS TO I_EVENTS.
*ENDFORM. " GET_EVENTS
*& Form DISPLAY
This form is going to display header details from likp table
FORM display .
*This function module for displaying the header details
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = i_fieldcat[]
i_save = 'X'
it_events = i_events
TABLES
t_outtab = i_likp
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
This form is going to display top-of-page header text
FORM top-of-page.
DATA: i_list_comments TYPE slis_t_listheader.
DATA: w_list_comments TYPE slis_listheader.
CLEAR: i_list_comments[].
w_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action
w_list_comments-info = 'DELIVERY ORDER DETAILS'.
APPEND w_list_comments TO i_list_comments.
w_list_comments-typ = 'A'. " H = Header, S = Selection, A = Action
w_list_comments-info = 'Basic list'.
APPEND w_list_comments TO i_list_comments.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'enjoy'
it_list_commentary = i_list_comments.
ENDFORM. "TOP-OF-PAGE
*& Form TOP_OF_PAGE
This form is going to display top-of-page item text
FORM top_of_page.
DATA: i_list_comments TYPE slis_t_listheader.
DATA: w_list_comments TYPE slis_listheader.
DATA : i_line LIKE w_list_comments-info.
CONCATENATE 'DELIVERY ITEM DETAILS :' delivar1 INTO i_line .
SEPARATED BY SPACE.
CLEAR: i_list_comments[].
w_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action
w_list_comments-info = i_line.
APPEND w_list_comments TO i_list_comments.
w_list_comments-typ = 'A'. " H = Header, S = Selection, A = Action
w_list_comments-info = 'Secondary list'.
APPEND w_list_comments TO i_list_comments.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'enjoy'
it_list_commentary = i_list_comments.
ENDFORM. "TOP_OF_PAGE -
URGENT:-Regarding sub-total in alv code
Hi,
i had made dis report and it is working fine but now i want to add the sub total feature in dis report as it is the new requierment of report.
plzz help me out by providing the code of sub-total feature in dis report .
Help will be definately rewarded. here is d code of report:-
TABLES: ISEG,MARA.
TYPE-POOLS : SLIS.
DATA : DATE1(15) TYPE C,
DATE2(15) TYPE C,
TITLE(65) TYPE C,
DT(25) TYPE C.
DATA : ITEVENT TYPE SLIS_T_EVENT.
DATA: lv_sort TYPE slis_sortinfo_alv,
t_sort type slis_t_sortinfo_alv.
DATA : repid LIKE sy-repid.
INTERNAL TABLE FOR INVENTORY STOCK *****************
DATA: BEGIN OF ITS1 OCCURS 0,
MATNR LIKE ISEG-MATNR,
ITEMID(6) TYPE C,
MEINS LIKE ISEG-MEINS,
MENGE LIKE ISEG-MENGE,
WRTZL LIKE ISEG-WRTZL,
BUCHM LIKE ISEG-BUCHM,
WRTBM LIKE ISEG-WRTBM,
WERKS LIKE ISEG-WERKS,
BUDAT LIKE ISEG-BUDAT,
ZLDAT LIKE ISEG-ZLDAT,
MTART LIKE MARA-MTART,
ITEMDESC LIKE MAKT-MAKTX,
DIFFQTY LIKE ISEG-BUCHM,
DIFFVALUE LIKE ISEG-WRTBM,
GRUND LIKE ISEG-GRUND,
GRTXT LIKE T157E-GRTXT,
BWART LIKE T157E-BWART,
REAS TYPE C LENGTH 15,
END OF ITS1.
data: t_heading type slis_t_listheader.
SELECTION-SCREEN BEGIN OF BLOCK PAR1 WITH FRAME TITLE TEXT-001.
*SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
*********PARAMETERS*********
PARAMETERS : PLANT LIKE ISEG-WERKS OBLIGATORY.
*********SELECTION SCREEN OPTIONS*********
SELECT-OPTIONS : R_DATE FOR ISEG-BUDAT OBLIGATORY NO-EXTENSION,
M_TYPE FOR MARA-MTART,
IT_M FOR MARA-MATNR.
*********DEFINING VARIABLES*********
SELECTION-SCREEN END OF BLOCK par1.
CONCATENATE R_DATE-LOW6(2) '.' R_DATE-LOW4(2) '.' R_DATE-LOW+0(4) INTO DATE1.
CONCATENATE R_DATE-HIGH6(2) '.' R_DATE-HIGH4(2) '.' R_DATE-HIGH+0(4) INTO DATE2.
TOP-OF-PAGE.
PERFORM PG_HEADER.
START-OF-SELECTION.
SELECT AMATNR AMEINS AMENGE AWRTZL ABUCHM AWRTBM AWERKS ABUDAT AZLDAT BMTART AGRUND CBWART
FROM ISEG AS A INNER JOIN MARA AS B ON BMATNR = AMATNR
INNER JOIN MSEG AS C ON AMBLNR = CMBLNR
INTO CORRESPONDING FIELDS OF TABLE ITS1 WHERE BMATNR = AMATNR AND BMEINS = AMEINS AND AWERKS = PLANT AND ABUDAT IN R_DATE AND BMTART IN M_TYPE AND BMATNR IN IT_M.
SORT ITS1 BY MTART.
LOOP AT ITS1.
ITS1-ITEMID = ITS1-MATNR+12(6).
ITS1-DIFFQTY = ITS1-MENGE - ITS1-BUCHM.
ITS1-DIFFVALUE = ITS1-WRTZL - ITS1-WRTBM.
SELECT SINGLE MAKTX FROM MAKT INTO ITS1-ITEMDESC WHERE MATNR = ITS1-MATNR.
SELECT SINGLE GRTXT INTO ITS1-GRTXT FROM T157E WHERE GRUND = ITS1-GRUND AND SPRAS = 'E' AND BWART = ITS1-BWART.
MODIFY ITS1.
ENDLOOP.
PERFORM PRN_SMSTOCK_ALV.
WRITING DATA FROM D TABLES**********
FORM PG_HEADER.
WRITE : 'INVENTORY REPORT PLANT : ', PLANT.
ENDFORM.
*& Form PRN_SMSTOCK_ALV
text
--> p1 text
<-- p2 text
form PRN_SMSTOCK_ALV .
data: w_title type lvc_title,
w_repid type syrepid,
w_comm type slis_formname,
w_status type slis_formname,
x_layout type slis_layout_alv,
t_event type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv,
t_subtot TYPE slis_t_sortinfo_alv,
subtot LIKE LINE OF t_subtot.
refresh t_fieldcat.
refresh t_event.
refresh t_sort.
clear x_layout.
clear w_title.
perform set_fieldcat2 using:
1 'MTART' 'MTART' 'MARA' '15' space 'MATERIAL TYPE' space space space space space space space space SPACE t_fieldcat 'L' 'L',
2 'ITEMID' 'ITEMID' 'MARA' '7' space 'ITEM ID' space space space space space space space space SPACE t_fieldcat 'R' 'C',
3 'ITEMDESC' 'MAKTX' 'MAKT' '25' space 'MATERIAL DESCRIPTION' space space space space space space space space SPACE t_fieldcat 'L' 'C',
4 'MEINS' 'MEINS' 'MARA' '5' space 'UOM' space space space space space space space space SPACE t_fieldcat 'C' 'C',
5 'MENGE' 'MENGE' 'ISEG' '13' space 'ORG.INV.QTY' space space space space space space space space SPACE t_fieldcat 'R' 'C',
6 'WRTZL' 'WRTZL' 'ISEG' '13' space 'ORG.INV.VALUE' space space space space space space space space SPACE t_fieldcat 'R' 'C',
7 'BUCHM' 'BUCHM' 'ISEG' '13' space 'PHY.INV.QTY' space space space space space space space space SPACE t_fieldcat 'R' 'C',
8 'WRTBM' 'WRTBM' 'ISEG' '13' space 'PHY.INV.VALUE' space space space space space space space space SPACE t_fieldcat 'R' 'C',
9 'DIFFQTY' 'MENGE' 'ISEG' '13' space 'DIFF.INV.QTY' space space space space space space space space SPACE t_fieldcat 'R' 'C',
10 'DIFFVALUE' 'WRTZL' 'ISEG' '13' space 'DIFF.INV.VALUE' space space space space space space space space SPACE t_fieldcat SPACE 'P',
11 'BUDAT' 'BUDAT' 'ISEG' '18' space 'CORRECTED DATE' space space space space space space space space SPACE t_fieldcat 'C' 'C',
12 'GRTXT' 'GRTXT' 'ISEG' '18' space 'REASON' space space space space space space space space SPACE t_fieldcat 'L' 'L',
13 'REAS' 'REAS' 'ISEG' '18' space 'AUTH.BY' space space space space space space space space SPACE t_fieldcat 'C' 'C'.
x_layout-zebra = 'X'.
perform set_top_page_heading using t_heading t_event.
perform set_events using t_event.
w_status = ''.
w_repid = sy-repid.
w_comm = 'USER_COMMAND'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = w_repid
it_fieldcat = t_fieldcat
i_Callback_top_of_page = 'Top-of-page'
is_layout = x_layout
it_sort = t_sort
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = t_event
i_grid_title = w_title
tables
t_outtab = ITS1
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.
FORM set_fieldcat2 USING
p_colpos p_fieldname p_ref_fieldname p_ref_tabname
p_outputlen p_noout
p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
p_hotspot p_showasicon p_checkbox p_edit
p_dosum
p_subtot
t_fieldcat TYPE slis_t_fieldcat_alv
P_JUST
P_FTYPE.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
CLEAR wa_fieldcat.
General settings
wa_fieldcat-fieldname = p_fieldname.
wa_fieldcat-col_pos = p_colpos.
wa_fieldcat-no_out = p_noout.
wa_fieldcat-hotspot = p_hotspot.
wa_fieldcat-checkbox = p_checkbox.
wa_fieldcat-icon = p_showasicon.
wa_fieldcat-do_sum = p_dosum.
Set output length.
IF NOT p_outputlen IS INITIAL.
wa_fieldcat-outputlen = p_outputlen.
ENDIF.
Set text headers.
IF NOT p_seltext_m IS INITIAL.
wa_fieldcat-seltext_m = p_seltext_m.
ENDIF.
IF NOT p_seltext_l IS INITIAL.
wa_fieldcat-seltext_l = p_seltext_l.
ENDIF.
IF NOT p_seltext_s IS INITIAL.
wa_fieldcat-seltext_s = p_seltext_s.
ENDIF.
IF NOT p_reptext_ddic IS INITIAL.
wa_fieldcat-reptext_ddic = p_reptext_ddic.
ENDIF.
IF NOT p_ddictxt IS INITIAL.
wa_fieldcat-ddictxt = p_ddictxt.
ENDIF.
IF NOT P_JUST IS INITIAL.
WA_FIELDCAT-JUST = P_JUST.
ENDIF.
IF NOT p_edit IS INITIAL.
wa_fieldcat-Input = 'X'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-do_sum = 'x'.
wa_fieldcat-checkbox = 'x'.
wa_fieldcat-hotspot = 'x'.
ENDIF.
APPEND wa_fieldcat TO t_fieldcat.
ENDFORM. "set_fieldcat2
======================== Subroutines called by ALV ================
*& Form top_of_page
Called on top_of_page ALV event.
Prints the heading.
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_heading.
ENDFORM.
form set_top_page_heading using t_heading type slis_t_listheader
t_events type slis_t_event.
data: x_heading type slis_listheader,
x_event type line of slis_t_event.
Report title
clear t_heading[].
clear x_heading.
x_heading-typ = 'H'.
x_heading-info = 'PHYSICAL INVENTORY AUDIT REPORT'.
append x_heading to t_heading.
Plant Name
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'PLANT : '.
x_heading-info = PLANT.
append x_heading to t_heading.
IF DATE2 = '00.00.0000'.
CONCATENATE DATE1 'to' DATE1 INTO DT SEPARATED BY SPACE.
ELSE.
CONCATENATE DATE1 'to' DATE2 INTO DT SEPARATED BY SPACE.
ENDIF.
X_heading-TYP = 'S'.
X_heading-key = 'PERIOD :'.
X_heading-INFO = DT.
APPEND x_heading TO t_heading.
Control Date
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'CONTROL NO. :'.
x_heading-info = ' ASDFADDFAAS DATE : 11.04.2007'.
append x_heading to t_heading.
Top of page event
x_event-name = slis_ev_top_of_page.
x_event-form = 'TOP_OF_PAGE'.
append x_event to t_events.
endform.
form set_events using t_events type slis_t_event.
data: x_event type line of slis_t_event.
endform.
Edited by: ric .s on Jan 29, 2008 5:21 AMHi,
U can do subtotal for a field based on some other field in ur ALV report using slis_t_sortinfo_alv.
see the sample code below...
data: int_sort TYPE slis_t_sortinfo_alv,
fs_sort TYPE slis_sortinfo_alv.
Sort the output based on ORG UNIT.
CLEAR fs_sort.
fs_sort-fieldname = 'ORGEH'.
fs_sort-subtot = 'X'.
fs_sort-up = 'X'.
APPEND fs_sort TO int_sort.
perform f_alv_catsfieldcat.
Fieldcat calculates the sum for SMPCNT field.
FORM f_alv_catsfieldcat.
DATA: loc_fieldcat TYPE slis_fieldcat_alv.
DEFINE define_field.
clear loc_fieldcat.
loc_fieldcat-fieldname = &1.
loc_fieldcat-seltext_l = &2.
loc_fieldcat-key = &3.
loc_fieldcat-outputlen = &4.
loc_fieldcat-do_sum = &5.
append loc_fieldcat to int_fieldcat.
END-OF-DEFINITION.
REFRESH int_fieldcat.
CLEAR int_fieldcat.
define_field 'PERNR' text-029 'X' '8' ''.
define_field 'ENAME' text-030 '' '40' ''.
define_field 'KOSTL' text-037 '' '10' ''.
define_field 'SMPCNT' text-040 '' '' 'X'.
endform.
Then call REUSE_ALV-GRID_DISPLAY with ur internal table with int_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = 'TOP_OF_PAGE'
it_sort = int_sort
i_callback_pf_status_set = 'F_PF_STATUS_SET'
i_callback_user_command = 'F_USER_COMMAND'
it_fieldcat = int_fieldcat
i_save = 'X'
TABLES
t_outtab = int_outputcpy
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE / 'error'.
ENDIF.
Hope it will help u..
Reward points if helpful
Cheers,
Shanthi
Edited by: shanthi ps on Jan 29, 2008 5:37 AM
Edited by: shanthi ps on Jan 29, 2008 5:38 AM -
Unable to read the total value.
Hi guys,
I am able to get the total for alv table column.. but i want to display the total value in some other text view field.
In order to do that... first i have to read the total value, and have to set the same to text view field,
total value is of type ( DATA: LV_AGGR_RULE TYPE REF TO CL_SALV_WD_AGGR_RULE. )
but my text view field attribute is of STRING TYPE.
So am getting conversion error. Pleas help me in this.
Regards
Farooq
Edited by: farooq basha on Jun 13, 2011 12:52 PMHi ,
Try to loop your internal table on the column "Amount" and make a sum for that particular column, u will get the required sum Amount..
Thanks
Aisurya -
Hi,
I have an ALV that I have displayed in a view , the ALV contains few columns , I want to show the total of the fields. Please suggest how to do it.hi
have a look at following [article|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/4063c42a-2549-2c10-fab6-a8c99d98b9b5]
might help you.
regards
manas dua -
How to do the ALV report output in groups and caluculate the tOTALS(URGENT
Hi
In my ALV report output .I have to group the output based on the DAYS field
0-10 days in one group
10-30 days in one group
above 30 days one group
There is also a field by name "AMOUNT" in my output.
I have to calculate SUBTOTALs at the end of every group and at the end of the report i should caluculate GRAND TOTAL.
Please remember that i should not use any any BLOCKED ALVs and for Totals i should not use the SYMBOLS provided in the application toolbar of the report
Thanks in AdvancePlease don't repost your questions...
Check out my answer in your other post.
How to make the ALV report in groups and caluculate the TOTALS
Regards,
Naimesh Patel -
How to find out the total, subtotal in alv report
hi dears,
how to find out the total, subtotal in alv report?
pls tell me logic ,
i will be waiting for eply
regards
eswarHi,
<b>ALV Grid List with sub-totals</b>
REPORT z_demo_alv_sort.
* This program lists orders (VBAK) with sort and sub-total for *
* 'sold-to-party' (KUNNR) and 'Sales organization' (VKORG) *
TABLES : vbak.
TYPE-POOLS: slis. " ALV Global types
SELECT-OPTIONS :
s_vkorg FOR vbak-vkorg, " Sales organization
s_kunnr FOR vbak-kunnr, " Sold-to party
s_vbeln FOR vbak-vbeln. " Sales document
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
DATA:
BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg, " Sales organization
kunnr LIKE vbak-kunnr, " Sold-to party
vbeln LIKE vbak-vbeln, " Sales document
netwr LIKE vbak-netwr, " Net Value of the Sales Order
waerk LIKE vbak-waerk, " Document currency
END OF gt_vbak.
INITIALIZATION.
v_1 = 'Maximum of records to read'.
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
* Form f_read_data
FORM f_read_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
FROM vbak
UP TO p_max ROWS
WHERE kunnr IN s_kunnr
AND vbeln IN s_vbeln
AND vkorg IN s_vkorg.
ENDFORM. " F_READ_DATA
* Form f_display_data
FORM f_display_data.
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'VBAK'.
ls_fieldcat-do_sum = &2.
ls_fieldcat-cfieldname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
ls_sort-subtot = &2.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
m_fieldcat 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' ''.
m_fieldcat 'VBELN' '' ''.
m_fieldcat 'NETWR' 'X' 'WAERK'.
m_fieldcat 'WAERK' '' ''.
m_sort 'VKORG' 'X'. " Sort by vkorg and subtotal
m_sort 'KUNNR' 'X'. " Sort by kunnr and subtotal
m_sort 'VBELN' ''. " Sort by vbeln
ls_layout-cell_merge = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
TABLES
t_outtab = gt_vbak.
ENDFORM. " F_DISPLAY_DATA
***************** END OF PROGRAM Z_DEMO_ALV_SORT **********************
Regards
Sudheer -
Hi all,
I am using alv to display Currency fields in a tax return report.........I want to display the sum of a perticular column or all the columns when i press the total button from alv selecting the required columns. But its coming only for first two columns not for all. Please help.
Regards.Hi,
This ALV program have all the basic report requirements such as page heading, page no, sub-total and a grand total.
* This is a basic ALV with the followings:-
* - Page Heading
* - Page No
* - Sub-Total
* - Grand Total
REPORT ZALV.
TYPE-POOLS: SLIS.
DATA: G_REPID LIKE SY-REPID,
GS_PRINT TYPE SLIS_PRINT_ALV,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
GT_EVENTS TYPE SLIS_T_EVENT,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
COL_POS TYPE I.
DATA: BEGIN OF ITAB,
FIELD1(5) TYPE C,
FIELD2(5) TYPE C,
FIELD3(5) TYPE P DECIMALS 2,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0.
INCLUDE STRUCTURE ITAB.
DATA: END OF ITAB1.
DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.
INCLUDE STRUCTURE ITAB.
DATA: END OF ITAB_FIELDCAT.
* Print Parameters
PARAMETERS:
P_PRINT AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE
P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO
P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE
P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE
P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO
P_RESERV TYPE I. "NO OF FOOTER LINE
INITIALIZATION.
G_REPID = SY-REPID.
PERFORM PRINT_BUILD USING GS_PRINT. "Print PARAMETERS
START-OF-SELECTION.
* TEST DATA
MOVE 'TEST1' TO ITAB1-FIELD1.
MOVE 'TEST1' TO ITAB1-FIELD2.
MOVE '10.00' TO ITAB1-FIELD3.
APPEND ITAB1.
MOVE 'TEST2' TO ITAB1-FIELD1.
MOVE 'TEST2' TO ITAB1-FIELD2.
MOVE '20.00' TO ITAB1-FIELD3.
APPEND ITAB1.
DO 50 TIMES.
APPEND ITAB1.
ENDDO.
END-OF-SELECTION.
PERFORM BUILD.
PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.
PERFORM COMMENT_BUILD CHANGING GT_LIST_TOP_OF_PAGE.
PERFORM CALL_ALV.
FORM BUILD.
* DATA FIELD CATALOG
* Explain Field Description to ALV
DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD1'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
*FIELDCAT_LN-NO_OUT = 'X'. "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
FIELDCAT_LN-KEY = ' '. "SUBTOTAL KEY
FIELDCAT_LN-NO_OUT = ' '.
FIELDCAT_LN-SELTEXT_L = 'HEAD1'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD2'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
FIELDCAT_LN-NO_OUT = 'X'.
FIELDCAT_LN-SELTEXT_L = 'HEAD2'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD3'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
FIELDCAT_LN-REF_TABNAME = 'MSEG'. "<- REF TABLE IN THE DICTIONNARY
FIELDCAT_LN-NO_OUT = ' '.
FIELDCAT_LN-DO_SUM = 'X'. "SUM UPON DISPLAY
APPEND FIELDCAT_LN TO GT_FIELDCAT.
* DATA SORTING AND SUBTOTAL
DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD1'.
GS_SORT-SPOS = 1.
GS_SORT-UP = 'X'.
GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD2'.
GS_SORT-SPOS = 2.
GS_SORT-UP = 'X'.
*GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
ENDFORM.
FORM CALL_ALV.
* ABAP List Viewer
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = G_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'ITAB1'
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = GT_SORT[]
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
IT_EVENTS = GT_EVENTS[]
* IT_EVENT_EXIT =
IS_PRINT = GS_PRINT
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
* HEADER FORM
FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
*GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = LT_EVENTS.
READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO LT_EVENTS.
ENDIF.
* define END_OF_PAGE event
* READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
* INTO LS_EVENT.
* IF SY-SUBRC = 0.
* MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
* APPEND LS_EVENT TO LT_EVENTS.
* ENDIF.
ENDFORM.
FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: GS_LINE TYPE SLIS_LISTHEADER.
CLEAR GS_LINE.
GS_LINE-TYP = 'H'.
GS_LINE-INFO = 'HEADER 1'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
CLEAR GS_LINE.
GS_LINE-TYP = 'S'.
GS_LINE-KEY = 'STATUS 1'.
GS_LINE-INFO = 'INFO 1'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
GS_LINE-KEY = 'STATUS 2'.
GS_LINE-INFO = 'INFO 2'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
* CLEAR GS_LINE.
* GS_LINE-TYP = 'A'.
* GS_LINE-INFO = 'ACTION'.
* APPEND GS_LINE TO GT_TOP_OF_PAGE.
ENDFORM.
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.
ENDFORM.
FORM END_OF_PAGE.
WRITE at (sy-linsz) sy-pagno CENTERED.
ENDFORM.
* PRINT SETTINGS
FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
LS_PRINT-PRINT = P_PRINT. "PRINT IMMEDIATE
LS_PRINT-NO_PRINT_SELINFOS = P_NOSINF. "NO SELECTION INFO
LS_PRINT-NO_COVERPAGE = P_NOCOVE. "NO COVER PAGE
LS_PRINT-NO_NEW_PAGE = P_NONEWP.
LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO
LS_PRINT-RESERVE_LINES = P_RESERV.
ENDFORM.
*END OF ZALV PROGRAM
Regards
Sudheer -
Displaying the total no of records in ALV ouput.
Hi everybody,
I am displaying the output in ALV.
I want display the total number of records at the top of page.( before the columns).
Can any one throw light on this plz.
Karunakar reddyTo get the number of entries in your displayed table use:
<i>DESCRIBE TABLE tab LINES wg_lines.</i>
To display the value in a ALV Grid Control, use something like this:
<i>DATA: sl_layout TYPE lvc_s_layo.
sl_layout-grid_title = wl_lines.
CALL METHOD og_alv->set_table_for_first_display
EXPORTING
is_layout = sl_layout
....</i>
Regards,
Martin -
Just the sub totals in ALV ... is it possible
Report RCATS_APPROVE_ACTIVITIES
transaction called cats_appr_lite that displays a ALV report output
This report displayes the employees entered times in CATS and can be used by HR admins or managers for approval.
When the manager executes the report shows the times for each day
like it will show
PERN Date Time Unit
1000 1st jan monday 8 hours
1000 2nd jan monday 8 hours
1000 3rd jan monday 8 hours
1000 4th jan monday 8 hours
1000 5th jan monday 8 hours
And after i set the totals / sub totals for PERNR it also shows me another line
1000 40 hours
In this ALV report I just want to see the totals line like
1000 40 hours
and not the line items.
Idela scenario is I want to see the line items when clicked on the Totals line
1000 40 hours
Like i double click on the totals and see
1000 1st jan monday 8 hours
1000 2nd jan monday 8 hours
1000 3rd jan monday 8 hours
1000 4th jan monday 8 hours
1000 5th jan monday 8 hours
and from there on I can further navigate as required and currently avialable.
IS this something thatsome has every worked on. IS it technicallyfeasible with ALV reporting to show just the sub totals on the first page ( that is by not modifying the program but by just changing the layouts).You can achieve this with the layouts:
First run your ALV.. now do the subtotal based on your employe... you will have
new line with * in front of it.
1000 1st jan monday 8 hours
1000 2nd jan monday 8 hours
1000 3rd jan monday 8 hours
1000 4th jan monday 8 hours
1000 5th jan monday 8 hours
*1000 40 hours
Click on this astrick ... it will collepse the line items...
Now, save you layout by pressing the "Save layout" button.
Next time run your report with this newly crated layout.
Regards,
Naimesh Patel -
How to get the total pages in ALV report?
Hi guys,
Since I used page breaks can somebody please help me on how to get the total pages in ALV report?sincerely please...thanks guys.automatic display total page.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
r -
Change the total and subtotal dynamically in ALV GRID
Hi guys,
I need to change the total and subtotal of field "AMOUNT" dynamically.I am using ALV GRID CONTROL(oops concept).I need to override the standard functionality.I need to show my own subtotal and total line instead of standard one .Hi
I've understood it, I wanted to use OO Grid too, but I had to use the ALV list in order to write my total.
If you need to use OO grid u can try to exclude all funcitonalities for the total, subtotal and sorting and insert in the output table the lines with your totals.
Max -
Field over flow can not display the total and subtotal in ALV
hi
i am running a z report with huge data in quality system.
in 2 columns and not able to show the total and subtotal in 2 columns
it says field overflow and cannot be dispayed.
value is around 20character integer.You can create a domains with 20 positions and 2 decimal, for example.
Than, associate this domain a data element.
To finish assign that data element to the column you wanna sum.
I hope help.
Maybe you are looking for
-
HT204150 Problem with iCloud contacts
When I am trying to open my iCloud contacts I always get the message that the application cannot be loaded. Any solutions? Other applications as Remiders and Find my iPhone work properly. Thank you in advance!
-
Can't update iPhoto and iMovie. "ther was an error in the App Store (18)
I can't update iPhoto or iMovie. All others update OK. message pop up: "There was an error in the App Store" (18)
-
Email settings problem; error sending activation email
Hi there Hope everyone is doing well I am having some problems with my latest user registration pages for my site I am havving problems sending the activation email I have set up my server to relay emails and it works ok I use a linux server an
-
Regular expressions - annoyance
If: Pattern p = Pattern.compile( "(\\d){2}:(\\d){2}-(\\d){2}:(\\d){2}", Pattern.CASE_INSENSITIVE ); matches "01:02-03:04" matcher.group(1) returns: 1, instead of the "01" that should be matched. This is also the case with what should be a character m
-
Bex Web - Export to Excel / Export to PDF
Hi gurus, Using BI-IP. In a web-template, I use the function "Export to Excel 2000" (or "Printable version", which generates a PDF file). The function works, except that at detailed level there is no data for input-ready columns. Is it a known bug ?