Urgent: regarding sub total button in alv report
hi,
i had made dis report and it is is fine till now,but now i want add the sub total field in it ,by making double click on the field sub-total should be displayed in it.
here is d code as i had tried the sub - total but when i execute it is giving some diferrent result.
*& Report ZTET2
REPORT ZTET2.
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.
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 : 'PHYSICAL INVENTORY AUDIT 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.
perform get_subtotals.
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.
wa_fieldcat-t_subtot = p_subtot.
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-p_subtot = '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.
Control date
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'CONTROL DATE : '.
x_heading-info = ''.
append x_heading to t_heading.
Time of execution
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'DATE : '.
write sy-DATUM to x_heading-info.
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 get_subtotals.
CLEAR lv_sort.
lv_sort-fieldname = 'MENGE'.
lv_sort-up = 'X'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
*lv_sort-fieldname = 'MENGE'.
*lv_sort-tabname = 'ITS1'.
*lv_sort-subtot = 'X'.
*APPEND lv_sort TO t_sort.
lv_sort-fieldname = 'WRTZL'.
lv_sort-tabname = 'ITS1'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
lv_sort-fieldname = 'BUCHM'.
lv_sort-tabname = 'ITS1'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
lv_sort-fieldname = 'WRTBM'.
lv_sort-tabname = 'ITS1'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
lv_sort-fieldname = 'DIFFQTY'.
lv_sort-tabname = 'ITS1'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
lv_sort-fieldname = 'DIFFVALUE'.
lv_sort-tabname = 'ITS1'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO t_sort.
clear lv_sort.
ENDFORM.
form set_events using t_events type slis_t_event.
data: x_event type line of slis_t_event.
endform.
PLZ HELP ME and definately get rewarded.
hi,
how did u declared ur internal table?
Declare a dummy field in your internal table to trigger subtotal text event.
TYPES: BEGIN OF ty_ekpo,
lifnr TYPE ekko-lifnr, "vendor number
ebeln TYPE ekko-ebeln, "purchase document number
ebelp TYPE ekpo-ebelp, "Item Number of Purchasing Document
matnr TYPE ekpo-matnr, "Material Number
bukrs TYPE ekpo-bukrs, "Company Code
werks TYPE ekpo-werks, "Plant
d, "Dummy field to fire the Subtotal text event
END OF ty_ekpo.
Prepare field catalog for that dummyfield also and set attributes like below
wa_fcat-col_pos = 7.
wa_fcat-fieldname = 'D'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-ref_fieldname = 'NETPR'.
wa_fcat-ref_tabname = 'EKPO'.
wa_fcat-no_out = 'X'.
APPEND wa_fcat TO it_fcat.
Fill sortinfo table as follows
wa_sort-spos = 1.
wa_sort-fieldname = 'LIFNR'.
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
wa_sort-spos = 2.
wa_sort-fieldname = 'D'.
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO it_sort.
fill the event table
wa_event-name = 'SUBTOTAL_TEXT'. "--> this event is used to trigger subtotal text
wa_event-form = 'SUBTOTAL'.
APPEND wa_event TO it_event.
*& Form subtotal
FORM subtotal USING i_listhead STRUCTURE wa_ekpo i_subtotal TYPE slis_subtot_text.
READ TABLE it_sort INTO wa_sort WITH KEY fieldname = 'D'.
IF sy-subrc = 0.
IF i_subtotal-criteria = 'D'.
i_subtotal-display_text_for_subtotal = 'Sub total'.
ENDIF.
ENDIF.
ENDFORM. "subtotal
Thanks & REgards
Similar Messages
-
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 -
Sub totaling in the ALV report
Hi,
My requirement is to display the data in a ALV format. The ALV need to display the sub total. For example if the ALV display the comapny code, the number of the line of the company code need to displayed.
1000
1000
1000
Sub total 3
2000
2000
2000
2000
sub total 4
I made the changes to display the ALV. Please help mein obtaining the sub total..
Regards
SureshHI,
Below example may clear ur requirement.
REPORT YMS_ALVSUBTOTAL.
*REPORT z_alv_sub_totals .
TYPE-POOLS: slis.
DATA: BEGIN OF it_output OCCURS 0,
var1(8) TYPE n,
var2(10),
var3 TYPE I,
END OF it_output.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
t_fieldcat TYPE slis_fieldcat_alv,
it_sort TYPE slis_t_sortinfo_alv,
t_sort TYPE slis_sortinfo_alv,
v_repid LIKE sy-repid.
INITIALIZATION.
v_repid = sy-repid.
START-OF-SELECTION.
PERFORM get_data.
PERFORM sort_fields.
PERFORM fill_fieldcat.
PERFORM list_display.
*& Form GET_DATA
text
--> p1 text
<-- p2 text
FORM get_data.
it_output-var1 = 1000.
it_output-var2 = 'anupama'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 1000.
it_output-var2 = 'siddhu'.
it_output-var3 = '20000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 1000.
it_output-var2 = 'chinni'.
it_output-var3 = '100000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 2000.
it_output-var2 = 'chicchu'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 2000.
it_output-var2 = 'candy'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 1000.
it_output-var2 = 'anupama'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 4000.
it_output-var2 = 'anupama'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
ENDFORM. " GET_DATA
*& Form fill_fieldcat
text
--> p1 text
<-- p2 text
FORM fill_fieldcat.
PERFORM fill_fields USING: 'IT_OUTPUT' 'VAR1' 'Variable 1' ' ',
'IT_OUTPUT' 'VAR2' 'Variable 2' ' ',
'IT_OUTPUT' 'VAR3' 'Variable 3' 'X'.
ENDFORM. " fill_fieldcat
*& Form fill_fields
text
-->P_0146 text
-->P_0147 text
-->P_0148 text
-->P_0149 text
FORM fill_fields USING value(tabname) TYPE slis_tabname
value(fieldname) TYPE slis_fieldname
value(seltext_m) LIKE dd03p-scrtext_m
value(do_sum) TYPE c.
t_fieldcat-tabname = tabname.
t_fieldcat-fieldname = fieldname.
t_fieldcat-seltext_m = seltext_m.
IF do_sum = 'X'.
t_fieldcat-datatype = 'CURR'.
ENDIF.
t_fieldcat-do_sum = do_sum.
APPEND t_fieldcat TO it_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " fill_fields
*& Form list_display
text
--> p1 text
<-- p2 text
FORM list_display.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
it_fieldcat = it_fieldcat
it_sort = it_sort[]
TABLES
t_outtab = it_output
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. " list_display
*& Form sort_fields
text
--> p1 text
<-- p2 text
FORM sort_fields.
t_sort-fieldname = 'VAR1'.
t_sort-tabname = 'IT_OUTPUT'.
t_sort-spos = 1.
t_sort-up = 'X'.
t_sort-subtot = 'X'.
APPEND t_sort TO it_sort.
CLEAR t_sort.
t_sort-fieldname = 'VAR3'.
t_sort-tabname = 'IT_OUTPUT'.
t_sort-spos = 2.
t_sort-up = 'X'.
APPEND t_sort TO it_sort.
CLEAR t_sort.
ENDFORM. " sort_fields
Thanks,
Shankar -
Short dump when I do total or sub total in the ALV report
Hi,
When I do total or sub-total on the currency field in the ALV report, it'll give a short dump like
" The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X)".
Short text of error message:
Technical information about the message:
Message classe...... "0K"
Number.............. 000
Variable 1.......... " "
Variable 2.......... " "
Variable 3.......... " "
Variable 4.......... " "
Variable 3.......... " "
Variable 4.......... " "
Trigger Location of Runtime Error
Program SAPLSLVC
Include LSLVCF36
Row 2,726
Module type (FORM)
Module Name FILL_DATA_TABLE
sometime when I do the page down on the ALV report, the same short dump is coming.
Can anyone help me out.
Thanks
SelvaHi,
I'm getting this short dump in the standard program.
I'm getting ALV report display perfectly. the problem is, when I do total or subtotal on the currency fields.
2704
2705 ************************************
2706 * Column per Fieldcat Entry
2707 ************************************
2708 ls_lvc_data-value = space.
2709 clear ls_lvc_data-style.
2710 loop at it_fcat_local assigning <ls_fcat>
2711 where tech ne 'X' and no_out ne 'X'.
2712 if l_invisible eq 'X'.
2713 clear l_invisible.
2714 if <ls_fcat>-do_sum is initial.
2715 continue.
2716 else.
2717 clear ls_lvc_data-col_pos.
2718 endif.
2719 endif.
2720
2721 add 1 to ls_lvc_data-col_pos.
2722
2723 assign component <ls_fcat>-fieldname
2724 of structure <ls_data> to <l_field_value>.
2725 if sy-subrc ne 0.
>>>>> message x000(0k).
2727 endif.
2728
in this standard program, I'm getting the dump. the line is mentioned above in the code. -
Hi,
I need to do subtotalling in my program using ALV. I am getting the subtotal value in ALV list display , but not getting the text for subtotalling.
matnr werks stock
154 1001 1589
158 1001 1651
Subtotal for plant 1001 3240
155 1002 465
Subtotal for plant 1002 465hi,
how did u declared ur internal table?
Declare a dummy field in your internal table to trigger subtotal text event.
TYPES: BEGIN OF ty_ekpo,
lifnr TYPE ekko-lifnr, "vendor number
ebeln TYPE ekko-ebeln, "purchase document number
ebelp TYPE ekpo-ebelp, "Item Number of Purchasing Document
matnr TYPE ekpo-matnr, "Material Number
bukrs TYPE ekpo-bukrs, "Company Code
werks TYPE ekpo-werks, "Plant
d, "Dummy field to fire the Subtotal text event
END OF ty_ekpo.
Prepare field catalog for that dummyfield also and set attributes like below
wa_fcat-col_pos = 7.
wa_fcat-fieldname = 'D'.
wa_fcat-tabname = 'IT_EKPO'.
wa_fcat-ref_fieldname = 'NETPR'.
wa_fcat-ref_tabname = 'EKPO'.
wa_fcat-no_out = 'X'.
APPEND wa_fcat TO it_fcat.
Fill sortinfo table as follows
wa_sort-spos = 1.
wa_sort-fieldname = 'LIFNR'.
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
wa_sort-spos = 2.
wa_sort-fieldname = 'D'.
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO it_sort.
fill the event table
wa_event-name = 'SUBTOTAL_TEXT'. "--> this event is used to trigger subtotal text
wa_event-form = 'SUBTOTAL'.
APPEND wa_event TO it_event.
*& Form subtotal
FORM subtotal USING i_listhead STRUCTURE wa_ekpo i_subtotal TYPE slis_subtot_text.
READ TABLE it_sort INTO wa_sort WITH KEY fieldname = 'D'.
IF sy-subrc = 0.
IF i_subtotal-criteria = 'D'.
i_subtotal-display_text_for_subtotal = 'Sub total'.
ENDIF.
ENDIF.
ENDFORM. "subtotal
Thanks & REgards -
Activation of sub-totals button in ALV grid
hi experts
Execute the module pool program BCALV_GRID_DEMO .in the o/p screen - how to activate the subtotals button explicitly.HI,
Please refer the code below:
* ALV data declarations
data: it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort like line of it_sortcat.
perform build_sortcat.
*& Form build_sortcat
* Build Sort catalog
FORM build_sortcat .
wa_sort-spos = 1.
wa_sort-fieldname = 'EBELN'.
wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field
* gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.
wa_sort-spos = 2.
wa_sort-fieldname = 'EBELP'.
* gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.
ENDFORM. " build_sortcat
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_sort = it_sortcat
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
Thanks,
Sriram Ponna. -
How to calculate totals in Blocked ALV Report
Hi All,
Can any body tell how to calculate totals & sub totals in
Blocked ALV Report[Blocked List].
Thanks in advance
Thanks & Regards,
Rayeezuddin.read this it might help
Sums
15. No_sumchoice(1) TYPE c : This parameter allows the choice for summing up
Only by fieldcatalog.
Value set: SPACE, 'X'
'X' = fields which are to be summed, passed by the calling program (FIELDCAT-DO_SUM = 'X'). The user should not be able to change this value interactively.
16. No_totalline(1) TYPE c : Removes the option of having totals after sub-totals.
Value set: SPACE, 'X'
'X' = no total record is to be output. Subtotals can still be calculated and output. The fields in the subtotals are flagged DO_SUM = 'X' in the field list.
17. No_subchoice(1) TYPE c : Does not allow the user to interactively change the field chosen for subtotals.
Value set: SPACE, 'X'
'X' = value whose change triggers subtotals, provided by the calling program. The user should not be able to change this value interactively.
18. No_subtotals(1) TYPE c : No subtotals possible
Value set: SPACE, 'X'
'X' = no subtotals.
19. Numc_sum(1) TYPE c : Totals only possible for NUMC-Fields.
20. No_unit_splitting TYPE c: No separate total lines by inh.units
21.totals_before_items TYPE c: Display totals before the items
22. Totals_only(1) TYPE c : Show only totals
Value set: SPACE, 'X'
'X' = only total records are output.
23. Totals_text(60) TYPE c : Text for 1st col. in totals
Value set: SPACE, string (max.60)
' ' = The first column in the total record contains an appropriate number of '*'s to indicate the total by default. If the first column is wide enough, the string 'Total' is output after the asterisks.
'String = The string passed is output after the total indicated by '*', if the column is wide enough.
24. Subtotals_text(60) TYPE c : Texts for subtotals
Value set: SPACE, string (max.60)
' ' = In the first column of subtotal records, the subtotal is indicated by an appropriate number of '*' by default. If the first column is not a subtotal criterion, the string 'Total' is output after the asterisks, if the column is wide enough.
'String = the string passed is output after the subtotal indicated by '*', if the column is wide enough and the first column is not a subtotal criterion. If it is a subtotal criterion, its value is repeated after the total, if the column is wide enough.
ELSE TELL ME I WILL PASTE COMPLETE HELP
regards -
Sub Total Button in Report Painter Output
Hi,
I am working on the Balance Sheet Report in the Report Painter and i am trying to display the sub totaling display in the output.
In this i had defined the row which is based on the range of Account Number and it has the series i.e. 100000,30000,200000 etc..
Is it possible to display the output sub total on the basis of the Account Number Series which is mentioned above. As in a ALV Report we have the sub total button in report output.
If it is,then please provide me guidelines for it ......
Edited by: ricx .s on Jul 29, 2009 6:47 AMHi,
Try this code,
it working,
Data : X_SORT TYPE SLIS_SORTINFO_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
X_SORT-SPOS = 1. " Field number of ALV on which u want to sort
X_SORT-FIELDNAME = 'SEGMENT' . " field name
X_SORT-TABNAME = 'IT_ALV1'(001). "table name same as ur alv table name
X_SORT-UP = 'X'. " put up as 'X'
X_SORT-SUBTOT = 'X'. " Sub total allowed
APPEND X_SORT TO IT_SORT. "append
CLEAR X_SORT. "clear x_SORT
"in ALV_GRID_DISPLAY pass the it sort in it_SORT
IT_SORT = IT_SORT
Thanks
Arun Kayal -
Sub-total button In-active in ALV
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,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 -
Hide grand total field on ALV report, But keep the sub total fields
Dear Experts,
1) How to hide grand total field on ALV report, But keep the sub total fields.
2) How to populate rate per ton & calculate total price according to the qty in delivering document.Dear Experts,
1) How to hide grand total field on ALV report, But keep the sub total fields.
2) How to populate rate per ton & calculate total price according to the qty in delivering document. -
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 -
How to print sub total text in ALV
Hi All,
I have a prblem in printing sub total text in ALV. I am passing the text for sub total in ALV layout to the field SUBTOTALS_TEXT. Even then the text is not displayed where as this is working for TOTAL with the field TOTALS_TEXT.
Could any one provide me the solution please?
Thanks & Regards,
S.LakshmiHi Lakshmi,
Please refer to the following code :
report zalv10.
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'. ***CRUCIAL STATEMENT****
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'. **THIS SHOULD NOT BE UNCOMENTED*
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.
<b>Please reward points if helpful.</b>
Regards,
Amit Mishra -
Hi All,
I want to know how to create a button in alv report .
Please respond to my query.
Thanks and Regards,
Amanhi aman,
u can try this example:
where i have a created a button:
*& Report Z_GURU_ALV_EVENT01 *
report z_guru_alv_event01 .
tables: mara, makt.
type-pools slis.
data: begin of imara occurs 0,
matnr like mara-matnr,
ernam like mara-ernam,
ersda like mara-ersda,
end of imara.
data: begin of imakt occurs 0,
matnr like mara-matnr,
spras like makt-spras,
maktx like makt-maktx,
end of imakt.
data: ffc type slis_t_fieldcat_alv,
ievents type slis_t_event with header line,
iievent type slis_t_event with header line.
select-options: s_matnr for mara-matnr.
initialization.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = ievents[]
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
read table ievents with key name = slis_ev_top_of_page.
ievents-form = 'TOPP'.
modify ievents transporting form where name = slis_ev_top_of_page.
clear ievents.
read table ievents with key name = slis_ev_user_command.
ievents-form = 'USR_COM'.
modify ievents transporting form where name = slis_ev_user_command.
clear ievents.
read table ievents with key name = slis_ev_pf_status_set.
ievents-form = 'PFSTAT'.
modify ievents transporting form where name = slis_ev_pf_status_set.
clear ievents.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = iievent[]
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
read table iievent with key name = slis_ev_pf_status_set.
iievent-form = 'PFSTAT'.
modify iievent transporting form where name = slis_ev_pf_status_set.
clear iievent.
read table iievent with key name = slis_ev_user_command.
iievent-form = 'USERCOM'.
modify iievent transporting form where name = slis_ev_user_command.
clear iievent.
start-of-selection.
select matnr ernam ersda from mara into table imara where matnr
in s_matnr.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = 'IMARA'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = sy-repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = ffc
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.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
i_callback_top_of_page = 'ALV_BACKGROUND'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
i_callback_html_end_of_list = 'ALV_BACKGROUND'
I_STRUCTURE_NAME =
i_background_id = 'ALV_BACKGROUND'
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = ffc
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = ievents[]
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 = imara
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.
form topp.
data: it_top type slis_t_listheader,"having s , h ,a
wa type slis_listheader.
IT_SPEC TYPE SLIS_T_SPECIALCOL_ALV,
WA1 TYPE SLIS_SPECIALCOL_ALV.
wa-typ = 'H'.
wa-info = 'RELIANCE GLOBAL SERVICES' .
append wa to it_top.
clear wa.
wa-typ = 'S'.wa-key = 'NO:23'.
wa-info = 'TRIPLICANE HIGH ROAD'.
append wa to it_top.
clear wa.
wa-typ = 'S'.
wa-info = 'TRIPLICANE'.
append wa to it_top.
clear wa.
wa-typ = 'A'.
wa-info = 'sample'.
append wa to it_top.
clear wa.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_top
i_logo = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform.
form usr_com using r_ucomm type sy-ucomm r_selfield type slis_selfield.
case r_ucomm.
when 'CANC'.
leave to screen 0.
endcase.
data: ff type slis_t_fieldcat_alv.
data: v_vbeln(18) type n.
v_vbeln = r_selfield-value.
select matnr spras maktx
from makt into table imakt
up to 10 rows
where matnr = v_vbeln.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = 'IMAKT'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = sy-repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = ff
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.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_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 =
it_fieldcat = ff
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = iievent[]
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
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = imakt
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. "USR_COM
form pfstat using extab type slis_t_extab.
set pf-status 'STD' excluding extab.
endform. " pfstat
form usercom using rucom type sy-ucomm rselfield type slis_selfield.
case rucom.
when 'CANC'.
leave to screen 0.
endcase.
data: ffc type slis_t_fieldcat_alv,
v_matnr(18) type n.
v_matnr = rselfield-value.
select matnr ernam ersda from mara into table imara
where matnr = v_matnr.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = 'IMARA'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = sy-repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = ffc
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.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_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 =
it_fieldcat = ffc
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = iievent[]
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 = imara
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. -
How to give push button in alv report output
hi,
my requirement is that , i have to give push button in alv report output(item level) not in application toolbar, i am using reuse_alv_grid_display FM, can any body provide me sample code
regards,
siva kumarhave a look at this thread, also has a sample report at the end from Uwe Schieferstein.
[button on alv list|How to add and program a pushbutton on ALV grid line;
seems not to work try this:
How to add and program a pushbutton on ALV grid line
Edited by: Micky Oestreich on May 15, 2008 10:20 PM -
Add buttons in ALV Report output
Dear Friends,
I am developing one ALV report in PP moule for calculating Shelf Life. The output is coming properly in ALV.
But my additional requirement is ADD coustomise buttons in ALV Reports.
Please give me an idea how can I insert buttons in my alv report?
Thanks & Regards
VasuHi vasu,
consider the code given below.
FORM F4200_PF_STATUS_SET *
FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.
REFRESH i_extab.
PERFORM f4210_exclude_fcodes CHANGING i_extab.
The PF status is an exact copy of the PF status 'STANDARD' of program
SAPLSALV but with command 'CHNG' added to it.
SET PF-STATUS 'ZSOM_STANDARD' EXCLUDING i_extab.
ENDFORM.
*& Form f4210_exclude_fcodes
FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.
DATA: ws_fcode TYPE slis_extab.
CLEAR ws_fcode.
ws_fcode = '&EB9'. " Call up Report.
APPEND ws_fcode TO i_extab.
ws_fcode = '&ABC'. " ABC Analysis.
APPEND ws_fcode TO i_extab.
ws_fcode = '&NFO'. " Info Select.
APPEND ws_fcode TO i_extab.
ws_fcode = '&LFO'. " Information.
APPEND ws_fcode TO i_extab.
ENDFORM. " f4210_exclude_fcodes
*& Form f4300_user_command
FORM f4300_user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
CASE ucomm.
WHEN '&IC1'. "Double Click line Item
READ TABLE i_data INDEX selfield-tabindex.
IF i_data-qmnum NE space.
SET PARAMETER ID 'IQM' FIELD i_data-qmnum.
CALL TRANSACTION 'IW52' AND SKIP FIRST SCREEN.
CLEAR ucomm.
ENDIF.
WHEN 'CHNG'. " Change Notification Icon
READ TABLE i_data INDEX selfield-tabindex.
IF i_data-qmnum NE space.
SET PARAMETER ID 'IQM' FIELD i_data-qmnum.
CALL TRANSACTION 'IW52' AND SKIP FIRST SCREEN.
CLEAR ucomm.
ENDIF.
ENDCASE.
CLEAR ucomm.
ENDFORM. " f4300_user_command
EXPLANATION
In this program, first we created a PF status (ZSOM_STANDARD), which was an exact copy of STANDARD of program SAPLSALV through transaction SE41 (Menu Painter). Then we added another button to it,with a new fcode called CHNG. After this this we set this PF status instead of STANADRD.
We initialize a third event USER_COMMAND and associate a form with it. In this form we can capture the function codes and write any functionality under it. If we write functionality for an existing fcode, then this gets precedence over the default functionality that might be associated with it.
In this example, we capture a standard fcode &IC1 that is nothing but double clicking a line of the report. We are capturing the notification number of that line and calling transaction IW52 with it. We are also doing the same when a user clicks on the new Change Notification button.
When the user clicks the Back button in IW52, it comes back to the report.
Please reward for the same.
Message was edited by: Prakhar Saxena
Maybe you are looking for
-
Having issue in releasing a request
Dear gurus i was releasing my request a minute ago it was working fine then i updated my report and gave a new request number while releasing the new request i got the following error Test call of transport control program (tp) ended with return code
-
Using IPod on more than one machine
Does anyone know the process to authorize more than one computer to play and recognize an ipod's library? I want to use my ipod on my home computer and work one as well? I want to keep the same library and not lose anything. Anyone know how to do thi
-
Custom default value in view row class
How do I set a custom default value in a view row class? There is no create method to override, and I cannot seem to determine whether it's a new row or existing row in the code. The IDE wizard says it's possible, I can't find it in the documentation
-
How can I open iTunes 11 on Windows 8.1 64bit
Everytime, when I open iTunes on my laptop, it gives this message: The version of iTunes was 64bit, and version of my PC also 64bit.
-
Live verification shows bad, restore HD verification shows ok
Live verification - incorrect number of extended attributes (should be 863634 intead of 863633) - Disk Utility stopped verifying "Macintosh HD" - error: This disk needs to be repaired using the Recovery HD Recovery HD verification - Macintosh HD appe