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

Dump Error in MAterial Consumption Report

Hi all Gurus

[1] I need help from your side i am doing one material consumption report in that i did all thing but it is giving me dump error while i was using sort in to ALV

so please any one help me out this .......

**********

[2] I am Printing sum of quantity in Header area of smartform it is printing with using comma e.x 43,000 but in body area it is showing with decimal point

e.x 43.000

*******************

Following is my ALV reports code please check it it is giving me short dump while using sort ..............

I am very much in neeed

Thanx for your suggestion in advanc.....

and god bless you............

&----


*& Report ZCONSUM

*&

&----


*&

*&

&----


REPORT ZCONSUM.

&----


*& Report ZCONSUMPTION

*&

&----


*&

*&

&----


TYPE-POOLS : SLIS.

TABLES:marc,

mara,

makt,

mard,

mbew,

mseg,

mkpf.

TYPES:

BEGIN OF s_mseg,

mblnr LIKE mseg-mblnr,

mjahr LIKE mseg-mjahr,

zeile LIKE mseg-zeile,

bwart LIKE mseg-bwart,

matnr LIKE mseg-matnr,

werks LIKE mseg-werks,

menge LIKE mseg-menge,

budat LIKE mkpf-budat,

mtart LIKE mara-matnr,

matkl LIKE mara-matkl,

END OF s_mseg,

BEGIN OF s_t001w,

werks LIKE t001w-werks,

name1 LIKE t001w-name1,

END OF s_t001w,

BEGIN OF s_mara,

matnr LIKE mara-matnr,

mtart LIKE mara-mtart,

matkl LIKE mara-matkl,

END OF s_mara,

BEGIN OF s_makt,

matnr LIKE makt-matnr,

spras LIKE makt-spras,

maktx LIKE makt-maktx,

END OF s_makt,

BEGIN OF s_calc,

matnr LIKE mara-matnr,

mtart LIKE mara-mtart,

matkl LIKE mara-matkl,

maktx LIKE makt-maktx,

  • menge_t LIKE mseg-menge,

  • menge_t1 LIKE mseg-menge,

menge_con_261 LIKE mseg-menge,

menge_con_262 LIKE mseg-menge,

menge_con1_261 LIKE mseg-menge,

menge_con1_262 LIKE mseg-menge,

menge_ret_291 LIKE mseg-menge,

menge_ret1_291 LIKE mseg-menge,

menge_ret_292 LIKE mseg-menge,

menge_ret1_292 LIKE mseg-menge,

menge_unit_301 LIKE mseg-menge,

menge_unit1_301 LIKE mseg-menge,

menge_unit_302 LIKE mseg-menge,

menge_unit1_302 LIKE mseg-menge,

menge_sub LIKE mseg-menge,

menge_sub1 LIKE mseg-menge,

menge_oth LIKE mseg-menge,

menge_oth1 LIKE mseg-menge,

END OF s_calc,

BEGIN OF s_data,

matnr LIKE mara-matnr,

matkl LIKE mara-matkl,

mtart LIKE mara-mtart,

maktx LIKE makt-maktx,

menge_t LIKE mseg-menge,

menge_t1 LIKE mseg-menge,

menge_con LIKE mseg-menge,

menge_con1 LIKE mseg-menge,

menge_ret LIKE mseg-menge,

menge_ret1 LIKE mseg-menge,

menge_unit LIKE mseg-menge,

menge_unit1 LIKE mseg-menge,

menge_sub LIKE mseg-menge,

menge_sub1 LIKE mseg-menge,

menge_oth LIKE mseg-menge,

menge_oth1 LIKE mseg-menge,

END OF s_data.

DATA: w_mseg TYPE s_mseg,

i_mseg TYPE s_mseg OCCURS 0,

w_t001w TYPE s_t001w,

i_t001w TYPE s_t001w OCCURS 0,

w_mara TYPE s_mara,

i_mara TYPE s_mara OCCURS 0,

w_makt TYPE s_makt,

i_makt TYPE s_makt OCCURS 0,

w_calc TYPE s_calc,

i_calc TYPE s_calc OCCURS 0,

w_data TYPE s_data,

i_data TYPE s_data OCCURS 0.

DATA: line_cnt TYPE i,

v_temp TYPE p DECIMALS 2.

*----


  • ALV DATA DECLERATION

*----


DATA : IT_FIELD TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELD TYPE SLIS_FIELDCAT_ALV.

DATA : IT_LAYOUT TYPE SLIS_LAYOUT_ALV.

IT_LAYOUT-ZEBRA = 'X'.

IT_LAYOUT-TOTALS_TEXT = 'Grand Total'.

IT_LAYOUT-SUBTOTALS_TEXT = 'Sub Total'.

IT_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.

DATA: WA_COMMENTRY TYPE SLIS_LISTHEADER.

DATA: IT_COMMENTRY TYPE SLIS_T_LISTHEADER.

DATA: WA_COMMENTRY1 TYPE SLIS_LISTHEADER.

DATA: IT_COMMENTRY1 TYPE SLIS_T_LISTHEADER.

DATA: WA_EVENT TYPE SLIS_ALV_EVENT.

DATA: IT_EVENT TYPE SLIS_T_EVENT.

WA_EVENT-NAME = 'TOP_OF_PAGE'.

WA_EVENT-FORM = 'TOP'.

APPEND WA_EVENT TO IT_EVENT.

DATA : WA_SORT TYPE slis_sortinfo_alv,

IT_SORT TYPE SLIS_T_SORTINFO_ALV.

CLEAR WA_SORT.

WA_SORT-SPOS = '1'.

WA_SORT-FIELDNAME = 'MATKL'.

WA_SORT-TABNAME = 'I_DATA'.

WA_SORT-SUBTOT = 'X'.

APPEND WA_SORT TO IT_SORT.

CLEAR WA_SORT.

WA_SORT-SPOS = '2'.

WA_SORT-FIELDNAME = 'MTART'.

WA_SORT-TABNAME = 'I_DATA'.

WA_SORT-SUBTOT = 'X'.

APPEND WA_SORT TO IT_SORT.

DEFINE MAC1.

WA_FIELD-TABNAME = 'I_DATA'.

WA_FIELD-FIELDNAME = &1.

WA_FIELD-COL_POS = &2.

WA_FIELD-SELTEXT_L =&3.

WA_FIELD-DO_SUM = &4.

APPEND WA_FIELD TO IT_FIELD.

END-OF-DEFINITION.

MAC1 'MATKL' '1' 'MATERIAL GROUP' 'X'.

MAC1 'MTART' '2' 'MATERIAL TYPE' 'X'.

MAC1 'MATNR' '3' 'MATERIAL NO' 'X'.

MAC1 'MAKTX' '4' 'DESCRIPTION' 'X'.

MAC1 'MENGE_CON1' '5' 'CONSUMPTION FOR PERIOD' 'X'.

MAC1 'MENGE_CON' '6' 'CONSUMPTION FOR CUMULATIVE' 'X'.

MAC1 'MENGE_RET1' '7' 'RETURN FROM DEPT. FOR PERIOD' 'X'.

MAC1 'MENGE_RET' '8' 'RETURN FROM DEPT.CUMULATIVE' 'X'.

MAC1 'MENGE_UNIT1' '9' 'INTER UNIT FOR PERIOD' 'X'.

MAC1 'MENGE_UNIT' '10' 'INTER UNIT CUMULATIVE' 'X'.

MAC1 'MENGE_SUB1' '11' 'SUB CONTRACTOR FOR PERIOD' 'X'.

MAC1 'MENGE_SUB' '12' 'SUB CONTRACTOR CUMULATIVE' 'X'.

MAC1 'MENGE_OTH1' '13' 'OTHERS FOR PERIOD' 'X'.

MAC1 'MENGE_OTH' '14' 'OTHERS CUMULATIVE' 'X'.

MAC1 'MENGE_t1' '15' 'TOTAL FOR PERIOD' 'X'.

MAC1 'MENGE_t' '16' 'TOTAL CUMULATIVE' 'X'.

*----


SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.

PARAMETERS: p_werks LIKE t001w-werks DEFAULT '1023' OBLIGATORY.

select-options: s_matkl FOR mara-matkl,

s_mtart FOR mara-mtart,

s_matnr FOR mara-matnr,

s_budat FOR mkpf-budat OBLIGATORY.

PARAMETERS: year(4) DEFAULT '2007'.

SELECTION-SCREEN:END OF BLOCK B1.

START-OF-SELECTION.

SELECT lk~mblnr

lk~mjahr

lk~budat

lp~zeile

lp~bwart

lp~matnr

lp~werks

lp~menge

ma~mtart

ma~matkl

INTO CORRESPONDING FIELDs OF TABLE i_mseg

FROM MSEG AS lp INNER JOIN MKPF AS lk

ON lkmblnr EQ lpmblnr

AND lkmjahr EQ lkmjahr

INNER JOIN mara AS ma

ON mamatnr EQ lpmatnr

WHERE lp~werks EQ p_werks

AND lp~matnr IN s_matnr

AND lk~budat LE s_budat-high.

clear line_cnt. "Count line of i_table i_mseg

DESCRIBE TABLE i_mseg LINES line_cnt.

IF line_cnt GT 0. "If i_mseg has records

SELECT matnr "Collect material description

maktx

spras

INTO CORRESPONDING FIELDS OF TABLE i_makt

FROM makt

FOR ALL ENTRIES IN i_mseg

WHERE matnr EQ i_mseg-matnr

AND spras EQ 'E'.

CLEAR line_cnt.

DESCRIBE TABLE i_makt LINES line_cnt.

IF line_cnt GT 0.

SORT i_makt BY MATNR ASCENDING.

DELETE ADJACENT DUPLICATES FROM i_makt COMPARING matnr.

ENDIF.

SELECT werks "Collect plant name

name1

INTO CORRESPONDING FIELDS OF TABLE i_t001w

FROM t001w

FOR ALL ENTRIES IN i_mseg

WHERE werks EQ i_mseg-werks.

CLEAR line_cnt.

DESCRIBE TABLE i_t001w LINES line_cnt.

IF line_cnt GT 0.

SORT i_t001w BY werks ASCENDING.

DELETE ADJACENT DUPLICATES FROM i_t001w COMPARING werks.

ENDIF.

LOOP AT i_mseg INTO w_mseg. "Move recored into data i_tab

w_calc-matnr = w_mseg-matnr.

w_calc-mtart = w_mseg-mtart.

w_calc-matkl = w_mseg-matkl.

READ TABLE i_makt WITH KEY matnr = w_mseg-matnr INTO w_makt.

IF sy-subrc = 0.

w_calc-maktx = w_makt-maktx.

ENDIF.

IF w_mseg-bwart EQ '261' .

w_calc-menge_con_261 = w_mseg-menge.

IF w_mseg-budat GE s_budat-low.

w_calc-menge_con1_261 = w_mseg-menge.

ENDIF.

ENDIF.

IF w_mseg-bwart EQ '262' .

w_calc-menge_con_262 = w_mseg-menge.

IF w_mseg-budat GE s_budat-low.

w_calc-menge_con1_262 = w_mseg-menge.

ENDIF.

ENDIF.

IF w_mseg-bwart EQ '291' OR w_mseg-bwart EQ '201'.

w_calc-menge_ret_291 = w_mseg-menge.

IF w_mseg-budat GE s_budat-low.

w_calc-menge_ret1_291 = w_mseg-menge.

ENDIF.

ENDIF.

IF w_mseg-bwart EQ '292' OR w_mseg-bwart EQ '202'.

w_calc-menge_ret_292 = w_mseg-menge.

IF w_mseg-budat GE s_budat-low.

w_calc-menge_ret1_292 = w_mseg-menge.

ENDIF.

ENDIF.

IF w_mseg-bwart EQ '301'.

w_calc-menge_unit_301 = w_mseg-menge.

IF w_mseg-budat GE s_budat-low.

w_calc-menge_unit1_301 = w_mseg-menge.

ENDIF.

ENDIF.

IF w_mseg-bwart EQ '302'.

w_calc-menge_unit_302 = w_mseg-menge.

IF w_mseg-budat GE s_budat-low.

w_calc-menge_unit1_302 = w_mseg-menge.

ENDIF.

ENDIF.

IF w_mseg-bwart EQ '543'.

w_calc-menge_sub = w_mseg-menge.

IF w_mseg-budat GE s_budat-low.

w_calc-menge_sub1 = w_mseg-menge.

ENDIF.

ENDIF.

COLLECT w_calc INTO i_calc.

ENDLOOP. "ENDLOOP of Move recored into data i_tab

LOOP AT i_calc INTO w_calc.

w_data-matnr = w_calc-matnr.

w_data-mtart = w_calc-mtart.

w_data-matkl = w_calc-matkl.

w_data-maktx = w_calc-maktx.

v_temp = w_calc-menge_con_261 - w_calc-menge_con_262.

w_data-menge_con = v_temp.

CLEAR v_temp.

v_temp = w_calc-menge_con1_261 - w_calc-menge_con1_262.

w_data-menge_con1 = v_temp.

CLEAR v_temp.

v_temp = w_calc-menge_ret_291 - w_calc-menge_ret_292.

w_data-menge_ret = v_temp.

CLEAR v_temp.

v_temp = w_calc-menge_ret1_291 - w_calc-menge_ret1_292.

w_data-menge_ret1 = v_temp.

CLEAR v_temp.

v_temp = w_calc-menge_unit_301 - w_calc-menge_unit_302.

w_data-menge_unit = v_temp.

CLEAR v_temp.

v_temp = w_calc-menge_unit1_301 - w_calc-menge_unit1_302.

w_data-menge_unit1 = v_temp.

CLEAR v_temp.

w_data-menge_sub = w_calc-menge_sub.

w_data-menge_sub1 = w_calc-menge_sub.

v_temp = w_data-menge_con + w_data-menge_ret + w_data-menge_unit + w_data-menge_sub.

w_data-menge_t = v_temp.

CLEAR v_temp.

v_temp = w_data-menge_con1 + w_data-menge_ret1 + w_data-menge_unit1 + w_data-menge_sub1.

w_data-menge_t1 = v_temp.

CLEAR v_temp.

APPEND w_data TO i_data.

ENDLOOP.

ENDIF. "ENDIf i_mseg has records

*----


  • Display_ALV

*----


END-OF-SELECTION.

DATA : DATE(85),

DATE_LOW(10),

DATE_HIGH(10),

MSK TYPE STRING,

DATE1(10),

date2(10).

WA_COMMENTRY-TYP = 'H'.

WA_COMMENTRY-INFO = 'Material Consumption Report'.

APPEND WA_COMMENTRY TO IT_COMMENTRY.

CLEAR WA_COMMENTRY.

CONCATENATE S_BUDAT-LOW6(2) '/' S_BUDAT-LOW4(2) '/' S_BUDAT-LOW+0(4) INTO DATE1.

CONCATENATE S_BUDAT-high6(2) '/' S_BUDAT-high4(2) '/' S_BUDAT-high+0(4) INTO DATE2.

CONCATENATE 'Material Consumption Report :' DATE1 'To' date2 INTO DATE SEPARATED BY SPACE.

WA_COMMENTRY-TYP = 'S'.

WA_COMMENTRY-INFO = DATE.

APPEND WA_COMMENTRY TO IT_COMMENTRY.

CLEAR WA_COMMENTRY.

*SORT I_DATA BY MTART MATKL .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_BACKGROUND_ID = 'ALV_BACKGROUNG'

  • I_GRID_TITLE = 'STOCK LEDGER SUMMARY'

IS_LAYOUT = IT_LAYOUT

IT_FIELDCAT = IT_FIELD

  • IT_SORT = IT_SORT

  • I_SAVE = 'X'

IT_EVENTS = IT_EVENT

TABLES

T_OUTTAB = I_DATA.

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

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = IT_COMMENTRY

  • I_LOGO = 'INOXLOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM.

.

REFRESH IT_COMMENTRY.

ENDFORM. " TOP-OF-PAGE

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2007 at 01:45 PM

    Thanx for your suggession friend but it is not working any other idea pleas

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      It is giving me error on sort statement

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

      I_CALLBACK_PROGRAM = SY-REPID

      I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

      I_BACKGROUND_ID = 'ALV_BACKGROUNG'

      • I_GRID_TITLE = 'STOCK LEDGER SUMMARY'

      IS_LAYOUT = IT_LAYOUT

      IT_FIELDCAT = IT_FIELD

      • IT_SORT = IT_SORT <<<<<<<<<<<<<<<<<<<<<<<<<<<

      • I_SAVE = 'X'

      IT_EVENTS = IT_EVENT

      TABLES

      T_OUTTAB = I_DATA.

      IF SY-SUBRC <> 0.

      • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

      • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

      ENDIF.

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2007 at 01:31 PM

    Ateeque,

    Remove single quotes

    WA_SORT-SPOS = '1'.

    Regards,

    Satish

    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.