Skip to Content
0
Former Member
Jan 14, 2008 at 05:13 AM

VERY URGENT: REGARDING SUB TOTAL BUTTON ACTIVATION IN DIS CODE

52 Views

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.

Edited by: ric .s on Jan 15, 2008 5:27 AM