10-24-2007 7:12 PM
Hi,
I have created ALV using set_table_for_first_display method, but in the toolbar 'sub total' and 'find next' buttons are In-active. How to activate these buttion in tool bar.
Thanks,
10-24-2007 7:16 PM
You can activate the subtotal button simply but setting a field in your field catalog to allow for summing. The field is DO_SUM in the fieldcatalog. Make sure that you add this to the field that you want to sum, and it should be a numerically typed field.
wa_fieldcat-DO_SUM = 'X'.
Regards,
Rich Heilman
10-24-2007 7:17 PM
Hi,
You the below code :
Data : gt_sort TYPE slis_t_sortinfo_alv.
DATA: ls_sort TYPE slis_sortinfo_alv
CLEAR ls_sort.
ls_sort-fieldname = 'HKONT'.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
APPEND ls_sort TO gt_sort.
And pass gt_sort to ALV display i_sort.
Thanks,
Sriram Ponna.
10-24-2007 9:18 PM
I want subtotal on currency fields and it's type is P. but when i use fieldcatalog-do_sum = 'X'. It gives me dump....
10-24-2007 9:21 PM
Hello,
You need to apply DO_SUM on the amount field.
and in SORT table you need fill the curreny field.
Regards,
Naimesh Patel
10-24-2007 9:30 PM
No need to use do_sum in field catlog.
I have created one dummy program and i am able to see sub total button.
Check the below program :
REPORT ZTEST_ALV1 no standard page heading.
Good Example for Object Oriented ALV
Handles Double click
class cl_event_receiver definition.
public section.
methods handle_double_click
for event double_click of cl_gui_alv_grid
importing e_row e_column.
private section.
endclass.
class cl_event_receiver implementation.
method handle_double_click.
perform drill_down using e_row-index.
endmethod.
endclass.
Data Declaration Part
tables : makt.
Internal table
types : begin of ty_itab ,
matnr(18) type c,
tqty like vbap-kwmeng,
kunnr(10) type c,
qty like vbap-kwmeng,
netpr like vbap-netpr,
end of ty_itab.
data itab type standard table of ty_itab.
data wa_itab like line of itab.
data wa_itab2 like line of itab.
ALV Internal table
Internal table
types : begin of ty_itab1 ,
matnr(18) type c,
tqty(15) type c,
kunnr(10) type c,
qty like vbap-kwmeng,
netpr like vbap-netpr,
end of ty_itab1.
data : itab1 type standard table of ty_itab1.
data : wa_itab1 like line of itab1.
ALV Variable
data : v_repid like sy-repid,
v_dynnr like sy-dynnr,
ok_code like sy-ucomm,
cl_gui_custom_container type ref to cl_gui_custom_container,
cl_gui_alv_grid type ref to cl_gui_alv_grid,
cl_event_reciver type ref to cl_event_receiver,
layout type lvc_s_layo,
fieldcat type lvc_t_fcat.
data : flag type c.
Fill the default values
initialization.
v_repid = sy-repid.
v_dynnr = sy-dynnr.
start-of-selection.
Get the data from MAKT Table
perform get_data_makt.
Call Screen
perform call_screen.
&----
*& Form get_data_makt
&----
Get the data from makt table
----
FORM get_data_makt.
wa_itab-matnr = 'Mat1'.
wa_itab-tqty = '500'.
wa_itab-kunnr = 'Kun1'.
wa_itab-qty = '100'.
wa_itab-netpr = '200.00'.
append wa_itab to itab.
wa_itab-matnr = 'Mat1'.
wa_itab-tqty = '500'.
wa_itab-kunnr = 'Kun2'.
wa_itab-qty = '400'.
wa_itab-netpr = '200.00'.
append wa_itab to itab.
wa_itab-matnr = 'Mat2'.
wa_itab-tqty = '300'.
wa_itab-kunnr = 'Kun3'.
wa_itab-qty = '150'.
wa_itab-netpr = '100.00'.
append wa_itab to itab.
wa_itab-matnr = 'Mat2'.
wa_itab-tqty = '300'.
wa_itab-kunnr = 'Kun1'.
wa_itab-qty = '150'.
wa_itab-netpr = '100.00'.
append wa_itab to itab.
sort itab by matnr.
Use internal table control break statements
loop at itab into wa_itab.
move wa_itab to wa_itab2.
at new tqty.
move wa_itab2-matnr to wa_itab1-matnr.
move wa_itab2-tqty to wa_itab1-tqty.
move wa_itab2-kunnr to wa_itab1-kunnr.
move wa_itab2-qty to wa_itab1-qty.
flag = 'X'.
endat.
if flag ne 'X'.
move space to wa_itab1-tqty.
move wa_itab2-kunnr to wa_itab1-kunnr.
move wa_itab2-qty to wa_itab1-qty.
endif.
append wa_itab1 to itab1.
clear : wa_itab,
flag,
wa_itab1,
wa_itab2.
endloop.
ENDFORM. " get_data_makt
&----
*& Form call_screen
&----
Screen 1000
----
FORM call_screen.
call screen 1000.
ENDFORM. " call_screen
&----
*& Module USER_COMMAND_1000 INPUT
&----
text
----
MODULE USER_COMMAND_1000 INPUT.
case ok_code.
when 'EXIT'.
leave to screen 0.
when 'BACK'.
leave to screen 0.
when 'CANC'.
leave to screen 0.
endcase.
ENDMODULE. " USER_COMMAND_1000 INPUT
&----
*& Module STATUS_1000 OUTPUT
&----
text
----
MODULE STATUS_1000 OUTPUT.
SET PF-STATUS '1000'.
SET TITLEBAR 'xxx'.
CREATE OBJECT CL_GUI_CUSTOM_CONTAINER
EXPORTING
PARENT =
CONTAINER_NAME = 'GRID1'
STYLE =
LIFETIME = lifetime_default
REPID = v_repid
DYNNR = v_dynnr
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT CL_GUI_ALV_GRID
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
I_PARENT = cl_gui_custom_container
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_USE_VARIANT_CLASS = SPACE
I_NAME =
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Create Event Receiver
create object cl_event_reciver.
ALV Specific .Data Selection
Populate field catalog
perform get_fieldcatlog.
CALL METHOD cl_gui_alv_grid->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'I_MAKT'
IS_VARIANT =
I_SAVE = 'U'
I_DEFAULT = 'X'
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
IT_OUTTAB = itab1
IT_FIELDCATALOG = fieldcat
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
set handler cl_event_reciver->handle_double_click for cl_gui_alv_grid.
ENDMODULE. " STATUS_1000 OUTPUT
&----
*& Form get_fieldcatlog
&----
text
----
FORM get_fieldcatlog.
data ls_fcat type lvc_s_fcat.
refresh fieldcat.
Material #
clear ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-coltext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-tabname = 'ITAB1'.
ls_fcat-outputlen = '18'.
ls_fcat-col_pos = 1.
append ls_fcat to fieldcat.
Material #
clear ls_fcat.
ls_fcat-reptext = 'Total Qty'.
ls_fcat-coltext = 'Total Qty'.
ls_fcat-fieldname = 'TQTY'.
ls_fcat-tabname = 'ITAB1'.
ls_fcat-outputlen = '15'.
ls_fcat-col_pos = 2.
append ls_fcat to fieldcat.
Material #
clear ls_fcat.
ls_fcat-reptext = 'Customer Number'.
ls_fcat-coltext = 'Customer Number'.
ls_fcat-fieldname = 'KUNNR'.
ls_fcat-tabname = 'ITAB1'.
ls_fcat-outputlen = '18'.
ls_fcat-col_pos = 3.
append ls_fcat to fieldcat.
Material #
clear ls_fcat.
ls_fcat-reptext = 'QTY'.
ls_fcat-coltext = 'QTY'.
ls_fcat-fieldname = 'QTY'.
ls_fcat-tabname = 'ITAB1'.
ls_fcat-outputlen = '18'.
ls_fcat-col_pos = 4.
append ls_fcat to fieldcat.
Material #
clear ls_fcat.
ls_fcat-reptext = 'NETPR'.
ls_fcat-coltext = 'Net value'.
ls_fcat-fieldname = 'NETPR'.
ls_fcat-tabname = 'ITAB1'.
ls_fcat-outputlen = '18'.
ls_fcat-col_pos = 4.
append ls_fcat to fieldcat.
ENDFORM. " get_fieldcatlog
&----
*& Form drill_down
&----
text
----
-->P_E_ROW_INDEX text
----
FORM drill_down USING P_E_ROW_INDEX.
*read table i_makt into wa_makt index p_e_row_index.
*
*if sy-subrc eq 0.
*
*set parameter id 'MAT' field wa_makt-matnr.
*call transaction 'MM02' and skip first screen.
*endif.
ENDFORM. " drill_down
Thanks
Seshu