Skip to Content
author's profile photo Former Member
Former Member

REGARDING: Sub total activation button in alv

hi,

I had made dis report and added the feature SUB total ,but the problem is when i select 1 coloumn den it used to display correct sub total but when i choose all these buttons den it does not display the correct sub - total.

PLZZ GO THROUGH THE CODE AND HELP ME OUT WHAT PROBLEM IS WITH IT?

Moreover it does not display the RADIO BUTTON ACTIVE when i execute the report.

here is d code:-

&----


*& 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.

*********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 : '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

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-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 get_subtotals.

CLEAR lv_sort.

lv_sort-fieldname = 'MENGE'.

lv_sort-tabname = 'ITS1'.

lv_sort-spos = 3.

lv_sort-up = 'X'.

lv_sort-subtot = 'X'.

APPEND lv_sort TO t_sort.

clear lv_sort.

lv_sort-fieldname = 'WRTZL'.

lv_sort-tabname = 'ITS1'.

lv_sort-spos = 4.

lv_sort-up = 'X'.

lv_sort-subtot = 'X'.

APPEND lv_sort TO t_sort.

clear lv_sort.

*

lv_sort-fieldname = 'BUCHM'.

lv_sort-tabname = 'ITS1'.

lv_sort-spos = 5.

lv_sort-up = 'X'.

lv_sort-subtot = 'X'.

APPEND lv_sort TO t_sort.

clear lv_sort.

lv_sort-fieldname = 'WRTBM'.

lv_sort-tabname = 'ITS1'.

lv_sort-spos = 6.

lv_sort-up = 'X'.

lv_sort-subtot = 'X'.

APPEND lv_sort TO t_sort.

clear lv_sort.

lv_sort-fieldname = 'DIFFQTY'.

lv_sort-tabname = 'ITS1'.

lv_sort-spos = 7.

lv_sort-up = 'X'.

lv_sort-subtot = 'X'.

APPEND lv_sort TO t_sort.

clear lv_sort.

lv_sort-fieldname = 'DIFFVALUE'.

lv_sort-tabname = 'ITS1'.

lv_sort-spos = 8.

lv_sort-up = 'X'.

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jan 30, 2008 at 10:46 AM

    Don't give the ratios (quantity, amount, etc.) in the IT_SORT parameter, but the criteria of sorting. (material type, material number, etc.)

    In the field catalog IT_FIELDCAT of the ratio, give the do_sum = 'X'.

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.