2008 Jul 30 8:54 AM
I've develped an ALV report using OOPS. the function i used for display is this:
CALL METHOD ALV_GRID-> SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = it_data[]
IT_FIELDCATALOG = FIELDCAT[].
i got the output. but the total and subtotal buttons are disabled in the output. how can i enable this?
when we use the export parameter i_structure_name in SET_TABLE_FOR_FIRST_DISPLAY ? what is the use of this parameter?
I've develped an ALV report using OOPS. the function i used for display is this:
CALL METHOD ALV_GRID-> SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = it_data[]
IT_FIELDCATALOG = FIELDCAT[].
i got the output. but the total and subtotal buttons are disabled in the output. how can i enable this?
when we use the export parameter i_structure_name in SET_TABLE_FOR_FIRST_DISPLAY ? what is the use of this parameter?
2008 Jul 30 9:01 AM
try this
CALL METHOD R_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
CHANGING
IT_OUTTAB = IT_SFLIGHT
IT_FIELDCATALOG = GT_FIELDCAT.
EXPORTING
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'SFLIGHT'
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = gs_lay
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
CHANGING
it_outtab = it_sflight
it_fieldcatalog = gt_fieldcat
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4 .
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
"ELSE .
with this parameter u'll get total button.
2008 Jul 30 9:41 AM
Hi Malay,
thanks for ur reply...
what is "gs_lay". how do we define this?
is_layout = gs_lay
2008 Jul 30 10:23 AM
IF there is any summable field
then for that field you mention the DO_SUM = 'X'
and INTTYPE = 'P'.
then it will be enabled.
FIELDCAT-FIELDNAME = 'MENGE'.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-COLTEXT = 'Qty'.
FIELDCAT-OUTPUTLEN = 10.
FIELDCAT-DO_SUM = 'X'.
FIELDCAT-INTTYPE = 'P'.
APPEND FIELDCAT TO IT_FIELDCAT.Check this..
or show your fieldcatalog code.
2008 Jul 30 9:01 AM
IF there is any summable field
then for that field you mention the DO_SUM = 'X'
and INTTYPE = 'P'.
then it will be enabled.
FIELDCAT-FIELDNAME = 'MENGE'.
FIELDCAT-TABNAME = 'ITAB'.
FIELDCAT-COLTEXT = 'Qty'.
FIELDCAT-OUTPUTLEN = 10.
FIELDCAT-DO_SUM = 'X'.
FIELDCAT-INTTYPE = 'P'.
APPEND FIELDCAT TO IT_FIELDCAT.
2008 Jul 30 9:09 AM
Hi Christy,
Please check this programe in this ALV total been used and for the second question.
&----
*& Report Z_ALV_DEMO_TOTAL_TEXT
*&
&----
*&
*&
&----
TYPES: BEGIN OF ty_mara,
srno TYPE char40, " Storing the total text
matnr TYPE matnr, " Material
ersda TYPE ersda, " Creation date
ernam TYPE ernam, " Created by
laeda TYPE laeda, " Last change date
aenam TYPE aenam, " Last change by
vpsta TYPE vpsta, " Maintenance status
brgew TYPE brgew, " Gross weight
ntgew TYPE ntgew, " Net weight
gewei TYPE gewei, " Weight Unit
END OF ty_mara.* Type declaration for table storing temp. data
TYPES: BEGIN OF ty_mara_tmp,
matnr TYPE matnr, " Material
ersda TYPE ersda, " Creation date
ernam TYPE ernam, " Created by
laeda TYPE laeda, " Last change date
aenam TYPE aenam, " Last change by
vpsta TYPE vpsta, " Maintenance status
brgew TYPE brgew, " Gross weight
ntgew TYPE ntgew, " Net weight
gewei TYPE gewei, " Weight Unit
END OF ty_mara_tmp.* Internal table for storing final data
DATA: i_mara TYPE STANDARD TABLE OF ty_mara INITIAL SIZE 0.* Work area for final table
DATA: w_mara TYPE ty_mara.
Internal table for storing temp. data
DATA: i_mara_tmp TYPE STANDARD TABLE OF ty_mara_tmp INITIAL SIZE 0.* Work area for temp. table
DATA: w_mara_tmp TYPE ty_mara_tmp.* Object variable for ALV grid
DATA: oref1 TYPE REF TO cl_gui_alv_grid.* Field catalog table for ALV grid
DATA: fieldcat TYPE lvc_t_fcat.* Workarea for field catalog table
DATA: w_field TYPE lvc_s_fcat.* Internal table for storing info. for ALV grid
data: i_sort2 TYPE STANDARD TABLE OF lvc_s_sort INITIAL SIZE 0.* Workarea for sort table
DATA: wa_sort2 TYPE lvc_s_sort.* Workarea for ALV layout
data: wa_layout TYPE lvc_s_layo.
START-OF-SELECTION.* Fetch data
SELECT matnr " Material
ersda " Creation date
ernam " Created by
laeda " Last change date
aenam " Last change by
vpsta " Maintenance status
brgew " Gross weight
ntgew " Net weight
gewei " Weight Unit
FROM mara
INTO TABLE i_mara_tmp
UP TO 100 ROWS. CHECK sy-subrc = 0.* Populate final table
LOOP AT i_mara_tmp INTO w_mara_tmp.* Storing the Total text need to be displayed in
ALV
w_mara-srno = 'Total weight (Gross & Net)'.
w_mara-matnr = w_mara_tmp-matnr.
w_mara-ersda = w_mara_tmp-ersda. w_mara-ernam = w_mara_tmp-ernam . w_mara-laeda = w_mara_tmp-laeda. w_mara-aenam = w_mara_tmp-aenam.
w_mara-vpsta = w_mara_tmp-vpsta.
w_mara-brgew = w_mara_tmp-brgew.
w_mara-ntgew = w_mara_tmp-ntgew.
w_mara-gewei = w_mara_tmp-gewei.
APPEND w_mara TO i_mara. ENDLOOP.
Calling the screen to display ALV
CALL SCREEN 100.
&----
*& Module STATUS_0100 OUTPUT
&----
Display ALV report
----
MODULE status_0100 OUTPUT.
IF oref1 IS INITIAL.* Create ALV grid object
In this case we have not created any custom container in the screen,
Instead of that dummy container name is passed
ADVANTAGE: we can run this report in background without any problem
CREATE OBJECT oref1
EXPORTING
i_parent = cl_gui_custom_container=>screen0
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5
.
CHECK sy-subrc = 0.* Preparing the field catalog
ZDEMO: Defined in DDIC, it's structure is same as TYPE ty_mara
defined in the program
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZDEMO'
CHANGING
ct_fieldcat = fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0. LOOP AT fieldcat INTO w_field. IF w_field-fieldname = 'BRGEW' OR
w_field-fieldname = 'NTGEW'.
Summation for Gross & Net weight
w_field-do_sum = 'X'.
MODIFY fieldcat FROM w_field TRANSPORTING do_sum. ENDIF. IF w_field-fieldname = 'SRNO'.
Hide this field so that it can display it's content i.e.
Total text in Subtotal level
w_field-tech = 'X'.
w_field-no_out = 'X'.
MODIFY fieldcat FROM w_field TRANSPORTING tech no_out. ENDIF. CLEAR w_field.
ENDLOOP.
ENDIF.* Populate Sort table with SRNO field so that we can display the total
text in it's subtotal level
wa_sort2-spos = 1.
wa_sort2-fieldname = 'SRNO'.
wa_sort2-up = 'X'.
wa_sort2-subtot = 'X'.
APPEND wa_sort2 TO i_sort2.* Hide the total line
wa_layout-no_totline = 'X'.* Display the ALV grid
CALL METHOD oref1->set_table_for_first_display
EXPORTING
is_layout = wa_layout
CHANGING
it_outtab = i_mara[]
it_fieldcatalog = fieldcat
it_sort = i_sort2
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0. ENDIF.* Set the focus on the grid
CALL METHOD cl_gui_alv_grid=>set_focus
EXPORTING
control = oref1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF. ENDIF.ENDMODULE. " STATUS_0100 OUTPUT
check this link.
http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b5533cd30911d2b467006094192fe3/content.htm
Mohinder
Edited by: Mohinder Singh Chauhan on Jul 30, 2008 10:09 AM
2008 Aug 01 4:01 PM
HI Christy,
2 things to be done.
1. For the field that is to be totalled set the do_sum value appropriately.
2. Handle the TOOLBAR EVENT. This is the most important one as this enables all the buttons of the standard ALV toolbar.
This shld work out fine.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |