Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

improve the execution of code

hi,

i given my program. can any one tell me how to improve the execution speed of this program. it is working very slow in quality system.

&----


*& Report ZQMRSMNMWIPRPT *

*& *

&----


*& *

*& *

&----


REPORT zqmrsmnmwiprpt LINE-SIZE 328.

TABLES : mbew, mver, mseg, mara, mkpf, makt, zqmtsmnm,keko,ckis,marc.

DATA: PLANT TYPE mard-werks.

DATA : BEGIN OF it_mbew OCCURS 0,

bwkey TYPE bwkey,

bklas LIKE mbew-bklas,

matnr LIKE mbew-matnr,

salk3 LIKE mbew-salk3,

lbkum TYPE p DECIMALS 2,

stprs LIKE mbew-stprs,

maktx LIKE makt-maktx,

werks LIKE mver-werks,

gjahr LIKE mver-gjahr,

perkz LIKE mver-perkz,

meins LIKE mara-meins,

EKGRP LIKE MARC-EKGRP,

LABST TYPE p DECIMALS 2,

EINME LIKE MARD-EINME,

LABST1 type p DECIMALS 2,

EINME1 LIKE MARD-EINME,

TOTUR type p DECIMALS 2,

SALK1 LIKE MBEW-SALK3,

SALK2 LIKE MBEW-SALK3,

letztzug TYPE s032-letztzug,

letztabg TYPE s032-letztabg,

letztver TYPE s032-letztver,

letztbew TYPE s032-letztbew,

tot_1 TYPE p DECIMALS 2,

tot_11 TYPE p DECIMALS 2,

tot_12 TYPE p DECIMALS 2,

menge LIKE mseg-menge,

w_lbkum TYPE p DECIMALS 2,

tot_2 TYPE p DECIMALS 2,

tot_21 TYPE p DECIMALS 2,

TOT_3 TYPE P DECIMALS 2,

TOT_31 TYPE P DECIMALS 2,

  • w_consm type p decimals 2,

w_days TYPE p,

erfmg TYPE p DECIMALS 2,

erfme LIKE mseg-erfme,

cur_rate LIKE mbew-stprs,

w_value TYPE i,

w_value01 TYPE i,

w_value1 TYPE i,

w_value11 TYPE i,

*----


added by mohan on 20/08/2007

w_value2 type i,

w_value21 type i,

--


end of addition----

END OF it_mbew.

DATA: BEGIN OF it_mard OCCURS 0,

matnr TYPE mard-matnr,

werks TYPE mard-werks,

labst TYPE p DECIMALS 2,

einme TYPE mard-einme,

labst1 TYPE p DECIMALS 2,

einme1 TYPE mard-einme,

END OF it_mard.

DATA : BEGIN OF it_mver OCCURS 0,

werks LIKE mver-werks,

gjahr LIKE mver-gjahr,

matnr LIKE mver-matnr,

perkz LIKE mver-perkz,

gsv01 LIKE mver-gsv01,

gsv02 LIKE mver-gsv02,

gsv03 LIKE mver-gsv03,

gsv04 LIKE mver-gsv04,

gsv05 LIKE mver-gsv05,

gsv06 LIKE mver-gsv06,

gsv07 LIKE mver-gsv07,

gsv08 LIKE mver-gsv08,

gsv09 LIKE mver-gsv09,

gsv10 LIKE mver-gsv10,

gsv11 LIKE mver-gsv11,

gsv12 LIKE mver-gsv12,

curr_dt(08) TYPE c,

currdt(2) TYPE n,

tot_1 LIKE mver-gsv01,

tot_2 LIKE mver-gsv01,

END OF it_mver.

DATA: BEGIN OF it_s032 OCCURS 0,

matnr TYPE s032-matnr,

letztzug TYPE s032-letztzug,

letztabg TYPE s032-letztabg,

letztver TYPE s032-letztver,

letztbew TYPE s032-letztbew,

werks TYPE s032-werks,

END OF it_s032.

DATA: it_mbew1 LIKE it_mbew OCCURS 0 WITH HEADER LINE.

DATA : BEGIN OF dt OCCURS 0,

currdt(2) TYPE n,

curryr(4) TYPE N,

curryr1(4) TYPE N,

END OF dt.

DATA : currdate LIKE sy-datum,

newdate LIKE sy-datum.

DATA : tot_12 LIKE mver-gsv01,

tot_1 LIKE mver-gsv01,

tot_2 LIKE mver-gsv01,

TOT_3 LIKE MVER-GSV01.

DATA : abc TYPE p,

w_mjahr LIKE mseg-mjahr,

w_bwart LIKE mseg-bwart.

DATA : w_lbkum TYPE p,

w_101menge TYPE P DECIMALS 2,

w_102menge TYPE P DECIMALS 2.

DATA : BEGIN OF it_mkpf OCCURS 0,

budat LIKE mkpf-budat,

mblnr LIKE mkpf-mblnr,

MJAHR like mkpf-MJAHR,

END OF it_mkpf.

DATA : BEGIN OF it_mseg OCCURS 0,

bwart LIKE mseg-bwart,

menge TYPE P DECIMALS 2,

mjahr LIKE mseg-mjahr,

mblnr LIKE mseg-mblnr,

erfmg TYPE p DECIMALS 2,

erfme LIKE mseg-erfme,

werks LIKE mseg-werks,

matnr LIKE mseg-matnr,

END OF it_mseg.

*data: it_mseg like table of mseg with header line.

DATA : BEGIN OF it_mseg1 OCCURS 0,

w_diffmenge TYPE P DECIMALS 2,

END OF it_mseg1.

DATA : w_srno TYPE i, " Serial number.

w_pagectr TYPE i, " Page counter.

w_linectr TYPE i. " Line counter

DATA: w_pos LIKE ckis-wrtfw_pos,

w_pfx LIKE ckis-wrtfw_pfx,

w_pos1 LIKE ckis-wrtfw_pos,

w_pfx1 LIKE ckis-wrtfw_pfx,

w_cost LIKE ckis-wrtfw_pos.

data : curryr2(4) type n,

curryr3(4) type n.

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

SELECT-OPTIONS : BWKEY1 FOR PLANT .

*NO DATABASE SELECTION.

PARAMETERS : p_kadky LIKE keko-kadky OBLIGATORY.

*----ADDED BY MOHAN ON 20/08/2007--


SELECT-OPTIONS : BKLAS FOR MBEW-BKLAS.

SELECT-OPTIONS : EKGRP FOR MARC-EKGRP.

SELECT-OPTIONS : MATNR FOR MBEW-MATNR.

--


END OF MODIFICATION--

SELECTION-SCREEN END OF BLOCK blk1.

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

PARAMETERS: p_summ AS CHECKBOX.

PARAMETERS : SUMMARY RADIOBUTTON GROUP G1,

DETAILS RADIOBUTTON GROUP G1.

SELECTION-SCREEN END OF BLOCK blk2.

SELECT F~bwkey

F~bklas

F~matnr

F~salk3

F~lbkum

F~STPRS

E~EKGRP

INTO CORRESPONDING FIELDS OF TABLE it_mbew

FROM mbew AS F INNER JOIN MARC AS E

ON FBWKEY = EWERKS AND FMATNR = EMATNR

WHERE F~BKLAS IN BKLAS AND

F~BWKEY in BWKEY1 AND

F~MATNR IN MATNR AND

E~EKGRP IN EKGRP .

*REFRESH it_mbew.

*

*IF it_mbew IS INITIAL.

*FREE it_mbew.

*ENDIF.

SELECT matnr

werks

labst

einme INTO CORRESPONDING FIELDS OF TABLE IT_MARD

FROM MARD

FOR ALL ENTRIES IN IT_MBEW

  • WHERE WERKS IN BWKEY1 AND

  • MATNR IN MATNR.

WHERE WERKS = IT_MBEW-BWKEY AND

MATNR = IT_MBEW-MATNR .

SELECT werks

matnr

letztzug

letztabg

letztver

letztbew

INTO CORRESPONDING FIELDS OF TABLE IT_S032

FROM S032

FOR ALL ENTRIES IN IT_MBEW

WHERE MATNR = IT_MBEW-MATNR and

WERKS = IT_MBEW-BWKEY.

LOOP AT it_mbew.

IF it_mbew-lbkum = 0 .

DELETE it_mbew INDEX sy-tabix.

ELSE.

ENDIF.

ENDLOOP.

loop at it_mard.

move it_mard-labst to it_mard-labst1.

move it_mard-einme to it_mard-einme1.

collect it_mard.

endloop.

CLEAR IT_MARD.

LOOP AT IT_MARD.

DELETE ADJACENT DUPLICATES FROM IT_MARD.

MODIFY IT_MARD.

ENDLOOP.

CLEAR IT_MARD.

*------MODIFIED BY MOHAN ON 21/10/2007

LOOP AT IT_MBEW.

READ TABLE IT_MARD WITH KEY MATNR = IT_MBEW-MATNR

WERKS = IT_MBEW-BWKEY.

IT_MBEW-LABST = IT_MARD-LABST.

IT_MBEW-EINME = IT_MARD-EINME.

MODIFY IT_MBEW.

ENDLOOP.

--


added by mohan 29/10/2007--

SORT IT_S032 BY MATNR letztzug descending.

read table it_s032 index 1.

LOOP AT IT_MBEW.

READ TABLE IT_S032 WITH KEY MATNR = IT_MBEW-MATNR

WERKS = IT_MBEW-BWKEY.

IT_MBEW-LETZTZUG = IT_S032-LETZTZUG.

MODIFY IT_MBEW.

clear it_s032.

ENDLOOP.

SORT IT_S032 BY MATNR letztabg descending.

read table it_s032 index 1.

LOOP AT IT_MBEW.

READ TABLE IT_S032 WITH KEY MATNR = IT_MBEW-MATNR

WERKS = IT_MBEW-BWKEY.

IT_MBEW-letztabg = IT_S032-letztabg.

MODIFY IT_MBEW.

clear it_s032.

ENDLOOP.

SORT IT_S032 BY matnr letztver descending.

read table it_s032 index 1.

LOOP AT IT_MBEW.

READ TABLE IT_S032 WITH KEY MATNR = IT_MBEW-MATNR

WERKS = IT_MBEW-BWKEY.

IT_MBEW-letztver = IT_S032-letztver.

MODIFY IT_MBEW.

clear it_s032.

ENDLOOP.

SORT IT_S032 BY letztbew descending.

read table it_s032 index 1.

LOOP AT IT_MBEW.

READ TABLE IT_S032 WITH KEY MATNR = IT_MBEW-MATNR

WERKS = IT_MBEW-BWKEY.

IT_MBEW-letztbew = IT_S032-letztbew.

MODIFY IT_MBEW.

clear it_s032.

ENDLOOP.

SORT it_mbew BY matnr.

LOOP AT it_mbew.

SELECT SINGLE werks gjahr perkz INTO (mver-werks, mver-gjahr,

mver-perkz)

FROM mver

WHERE matnr = it_mbew-matnr AND

werks IN bwkey1.

SELECT SINGLE meins INTO mara-meins

FROM mara

WHERE matnr = it_mbew-matnr.

SELECT SINGLE maktx INTO makt-maktx

FROM makt

WHERE matnr = it_mbew-matnr.

it_mbew-werks = mver-werks.

it_mbew-gjahr = mver-gjahr.

it_mbew-perkz = mver-perkz.

it_mbew-meins = mara-meins.

it_mbew-maktx = makt-maktx.

MODIFY it_mbew.

ENDLOOP.

**DATA INTO INTERNAL TABLE OF IT_MVER.

**LOGIC FOR GETTING PREVIOUS 6 MONTHS DATA.

*ADDED BY MOHAN ON 20/08/2007

SORT it_mbew BY matnr werks gjahr.

LOOP AT it_mbew.

dt-curryr = p_kadky+0(4).

APPEND dt.

SELECT * INTO CORRESPONDING FIELDS OF TABLE it_mver FROM mver

WHERE matnr = it_mbew-matnr AND

werks = it_mbew-werks

AND

perkz = 'P'.

**LOGIC FOR GETTING PREVIOUS 6 MONTHS DATA.

LOOP AT it_mver.

if p_kadky+4(2) = '01'.

dt-currdt = '10'.

APPEND dt.

elseif p_kadky+4(2) = '02'.

dt-currdt = '11'.

APPEND dt.

elseif p_kadky+4(2) = '03'.

dt-currdt = 12.

APPEND dt.

elseif p_kadky+4(2) = '04'.

dt-currdt = '01'.

APPEND dt.

elseif p_kadky+4(2) = '05'.

dt-currdt = '02'.

APPEND dt.

elseif p_kadky+4(2) = '06'.

dt-currdt = '03'.

APPEND dt.

elseif p_kadky+4(2) = '07'.

dt-currdt = '04'.

APPEND dt.

elseif p_kadky+4(2) = '08'.

dt-currdt = '05'.

APPEND dt.

elseif p_kadky+4(2) = '09'.

dt-currdt = '06'.

APPEND dt.

elseif p_kadky+4(2) = '10'.

dt-currdt = '07'.

APPEND dt.

elseif p_kadky+4(2) = '11'.

dt-currdt = '08'.

APPEND dt.

elseif p_kadky+4(2) = '12'.

dt-currdt = '09'.

APPEND dt.

endif.

IF dt-currdt EQ '01'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_3 = it_mver-gsv10 + it_mver-gsv11 + it_mver-gsv12 +

it_mver-gsv07 + it_mver-gsv08 + it_mver-gsv09.

endif.

ELSEIF dt-currdt EQ '02'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_3 = it_mver-gsv10

+ it_mver-gsv11 + it_mver-gsv12 + it_mver-gsv08 +

it_mver-gsv09 .

endif.

if it_mver-gjahr = dt-curryr .

tot_3 = tot_3 + it_mver-gsv01.

endif.

ELSEIF dt-currdt EQ '03'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_3 = it_mver-gsv10 + it_mver-gsv11 +

it_mver-gsv12 + it_mver-gsv09.

endif.

if it_mver-gjahr = dt-curryr .

tot_3 = tot_3 + it_mver-gsv01 + it_mver-gsv02.

endif.

ELSEIF dt-currdt EQ '04'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_3 = it_mver-gsv10 + it_mver-gsv11 + it_mver-gsv12.

endif.

if it_mver-gjahr = dt-curryr .

tot_3 = tot_3 + it_mver-gsv01 + it_mver-gsv02 + it_mver-gsv03.

endif.

ELSEIF dt-currdt EQ '05'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_3 = it_mver-gsv11 + it_mver-gsv12.

endif.

if it_mver-gjahr = dt-curryr .

tot_3 = tot_3 + it_mver-gsv01 +

it_mver-gsv02 + it_mver-gsv03 + it_mver-gsv04.

endif.

ELSEIF dt-currdt EQ '06'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_3 = it_mver-gsv12 .

endif.

if it_mver-gjahr = dt-curryr .

tot_3 = tot_3 + it_mver-gsv01 + it_mver-gsv02

+ it_mver-gsv03 + it_mver-gsv04 + it_mver-gsv05.

endif.

ELSEIF dt-currdt EQ '07'.

if it_mver-gjahr = dt-curryr .

tot_3 = it_mver-gsv01 + it_mver-gsv02 + it_mver-gsv03

+ it_mver-gsv04 + it_mver-gsv05 + it_mver-gsv06.

endif.

ELSEIF dt-currdt EQ '08'.

if it_mver-gjahr = dt-curryr .

tot_3 = it_mver-gsv02 + it_mver-gsv03 + it_mver-gsv04

+ it_mver-gsv05 + it_mver-gsv06 + it_mver-gsv07.

endif.

ELSEIF dt-currdt EQ '09'.

if it_mver-gjahr = dt-curryr .

tot_3 = it_mver-gsv03 + it_mver-gsv04 + it_mver-gsv05

+ it_mver-gsv06 + it_mver-gsv07 + it_mver-gsv08.

endif.

ELSEIF dt-currdt EQ '10'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1 .

tot_3 = it_mver-gsv04 + it_mver-gsv05 + it_mver-gsv06

+ it_mver-gsv07 + it_mver-gsv08 + it_mver-gsv09.

endif.

ELSEIF dt-currdt EQ '11'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1 .

tot_3 = it_mver-gsv05 + it_mver-gsv06 + it_mver-gsv07

+ it_mver-gsv08 + it_mver-gsv09 + + it_mver-gsv10.

endif.

ELSEIF dt-currdt EQ '12'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1 .

tot_3 = it_mver-gsv06 + it_mver-gsv07 + it_mver-gsv08

+ it_mver-gsv09 + it_mver-gsv10 + it_mver-gsv11 .

endif.

ENDIF.

**MODIFYING THE VARIABLE TOT_1.

it_mbew-tot_3 = tot_3.

MODIFY it_mbew TRANSPORTING tot_3.

IF dt-currdt EQ '01'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_1 = it_mver-gsv10 + it_mver-gsv11 + it_mver-gsv12.

endif.

ELSEIF dt-currdt EQ '02'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_1 = it_mver-gsv11 + it_mver-gsv12 .

endif.

if it_mver-gjahr = dt-curryr .

tot_1 = tot_1 + it_mver-gsv01.

endif.

ELSEIF dt-currdt EQ '03'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_1 = it_mver-gsv12.

endif.

if it_mver-gjahr = dt-curryr .

tot_1 = tot_1 + it_mver-gsv01 + it_mver-gsv02.

endif.

ELSEIF dt-currdt EQ '04'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_1 = it_mver-gsv01 + it_mver-gsv02 + it_mver-gsv03.

endif.

ELSEIF dt-currdt EQ '05'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_1 = it_mver-gsv01 +

it_mver-gsv02 + it_mver-gsv03 + it_mver-gsv04.

endif.

ELSEIF dt-currdt EQ '06'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_1 = it_mver-gsv03 + it_mver-gsv04 + it_mver-gsv05.

endif.

ELSEIF dt-currdt EQ '07'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1 .

tot_1 = it_mver-gsv04 + it_mver-gsv05 + it_mver-gsv06.

endif.

ELSEIF dt-currdt EQ '08'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_1 = it_mver-gsv05 + it_mver-gsv06 + it_mver-gsv07.

endif.

ELSEIF dt-currdt EQ '09'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_1 = it_mver-gsv06 + it_mver-gsv07 + it_mver-gsv08.

endif.

ELSEIF dt-currdt EQ '10'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_1 = it_mver-gsv07 + it_mver-gsv08 + it_mver-gsv09.

endif.

ELSEIF dt-currdt EQ '11'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_1 = it_mver-gsv08 + it_mver-gsv09 + it_mver-gsv10.

endif.

ELSEIF dt-currdt EQ '12'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_1 = it_mver-gsv09 + it_mver-gsv10 + it_mver-gsv11.

endif.

ENDIF.

it_mbew-tot_1 = tot_1.

MODIFY it_mbew TRANSPORTING tot_1.

if p_kadky+4(2) = '01'.

dt-currdt = '10'.

APPEND dt.

elseif p_kadky+4(2) = '02'.

dt-currdt = '11'.

APPEND dt.

elseif p_kadky+4(2) = '03'.

dt-currdt = 12.

APPEND dt.

elseif p_kadky+4(2) = '04'.

dt-currdt = '01'.

APPEND dt.

elseif p_kadky+4(2) = '05'.

dt-currdt = '02'.

APPEND dt.

elseif p_kadky+4(2) = '06'.

dt-currdt = '03'.

APPEND dt.

elseif p_kadky+4(2) = '07'.

dt-currdt = '04'.

APPEND dt.

elseif p_kadky+4(2) = '08'.

dt-currdt = '05'.

APPEND dt.

elseif p_kadky+4(2) = '09'.

dt-currdt = '06'.

APPEND dt.

elseif p_kadky+4(2) = '10'.

dt-currdt = '07'.

APPEND dt.

elseif p_kadky+4(2) = '11'.

dt-currdt = '08'.

APPEND dt.

elseif p_kadky+4(2) = '12'.

dt-currdt = '09'.

APPEND dt.

endif.

IF dt-currdt EQ '01'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_2 = it_mver-gsv12 .

endif.

ELSEIF dt-currdt EQ '02'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_2 = it_mver-gsv01.

endif.

ELSEIF dt-currdt EQ '03'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_2 = it_mver-gsv02.

endif.

ELSEIF dt-currdt EQ '04'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_2 = it_mver-gsv03.

endif.

ELSEIF dt-currdt EQ '05'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_2 = it_mver-gsv04.

endif.

ELSEIF dt-currdt EQ '06'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_2 = it_mver-gsv05.

endif.

ELSEIF dt-currdt EQ '07'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_2 = it_mver-gsv06.

endif.

ELSEIF dt-currdt EQ '08'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr.

tot_2 = it_mver-gsv07.

endif.

ELSEIF dt-currdt EQ '09'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr .

tot_2 = it_mver-gsv08.

endif.

ELSEIF dt-currdt EQ '10'.

if it_mver-gjahr = dt-curryr1.

tot_2 = it_mver-gsv09.

endif.

ELSEIF dt-currdt EQ '11'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_2 = it_mver-gsv10.

endif.

ELSEIF dt-currdt EQ '12'.

dt-curryr1 = dt-curryr - 1.

if it_mver-gjahr = dt-curryr1.

tot_2 = it_mver-gsv11.

endif.

ENDIF.

*****MODIFYING THE VARIABLE TOT_2.

it_mbew-tot_2 = tot_2.

MODIFY it_mbew TRANSPORTING tot_2.

ENDLOOP.

SELECT SINGLE RATE FROM ZPPTMB5L INTO W_COST

WHERE BWKEY = IT_MBEW-BWKEY AND

MATNR = IT_MBEW-MATNR.

it_mbew-cur_rate = w_cost.

MODIFY it_mbew.

CLEAR: w_cost,marc-losgr,w_pos1,w_pfx1.

  • ENDIF.

it_mbew-w_value = it_mbew-cur_rate * it_mbew-tot_1.

MODIFY it_mbew .

it_mbew-w_value1 = it_mbew-cur_rate * it_mbew-tot_2.

MODIFY it_mbew .

--


added by mohan on 20/08/2007--

it_mbew-w_value2 = it_mbew-cur_rate * it_mbew-tot_3.

MODIFY it_mbew .

IT_MBEW-SALK1 = IT_MBEW-LBKUM * IT_MBEW-cur_rate.

IT_MBEW-TOTUR = IT_MBEW-LABST + IT_MBEW-EINME.

IT_MBEW-SALK2 = IT_MBEW-TOTUR * IT_MBEW-cur_rate.

MODIFY IT_MBEW.

currdate = sy-datum.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

currdate = currdate

backmonths = '3'

IMPORTING

newdate = newdate.

curryr2 = currdate+0(4).

curryr3 = newdate+0(4).

SELECT matnr menge mblnr mjahr bwart werks erfmg erfme

INTO CORRESPONDING FIELDS OF table it_mseg FROM mseg

WHERE

  • matnr in matnr

matnr = it_mbew-matnr

AND

mjahr le curryr2 and

mjahr ge curryr3

AND

bwart IN ('101','102') and

  • mblnr = it_mkpf-mblnr.

*change by 5-10-2007

werks = it_mbew-BWKEY.

SELECT mblnr budat mjahr INTO CORRESPONDING FIELDS OF TABLE

it_mkpf FROM mkpf WHERE budat GE newdate

AND

budat LE currdate

AND

mjahr le curryr2 and

mjahr ge curryr3.

loop at it_mseg.

loop at it_mkpf.

IF it_mseg-bwart = '101' and it_mseg-mblnr = it_mkpf-mblnr.

w_101menge = w_101menge + it_mseg-menge.

ELSEIF it_mseg-bwart = '102' and it_mseg-mblnr = it_mkpf-mblnr.

w_102menge = w_102menge + it_mseg-menge.

endif.

it_mseg1-w_diffmenge = w_101menge - w_102menge.

ENDLOOP.

endloop.

clear : w_102menge,w_101menge.

it_mbew-erfmg = it_mseg1-w_diffmenge.

it_mbew-erfme = it_mseg-erfme.

MODIFY it_mbew TRANSPORTING erfmg erfme.

IF it_mbew-tot_1 = 0.

ELSE.

it_mbew-w_days = it_mbew-lbkum / ( it_mbew-tot_1 / 90 ).

ENDIF.

*

  • it_mbew-w_days = w_days.

MODIFY it_mbew TRANSPORTING w_days.

ENDLOOP.

clear IT_MARD[].

clear IT_S032[].

clear IT_S032[].

clear it_mard[].

clear: it_mver,it_mver[].

CLEAR : it_mseg1[], it_mseg1.

*

  • clear : it_mkpf[], it_mkpf.

clear IT_MARD[].

clear IT_S032[].

clear IT_S032[].

clear it_mard.

clear : it_mseg[],it_mseg, it_mkpf[], it_mkpf.

free : it_mseg[],it_mseg, it_mkpf[], it_mkpf.

SORT it_mbew BY bwkey.

LOOP AT it_mbew.

IF p_summ = 'X'.

MOVE it_mbew-bwkey TO it_mbew1-bwkey.

it_mbew1-tot_1 = it_mbew-tot_1.

it_mbew1-tot_2 = it_mbew-tot_2.

it_mbew1-tot_3 = it_mbew-tot_3.

it_mbew1-w_value = it_mbew-w_value.

it_mbew1-w_value1 = it_mbew-w_value1.

it_mbew1-w_value2 = it_MBEW-W_VALUE2.

COLLECT it_mbew1.

elseif summary = 'X'.

AT FIRST.

w_pagectr = 1.

PERFORM header.

ENDAT.

FORMAT COLOR 2 ON INTENSIFIED.

WRITE : /01 sy-vline,

02 it_mbew-bwkey, 10 sy-vline,

11 it_mbew-bklas, 20 sy-vline,

21 IT_MBEW-EKGRP, 27 SY-VLINE,

28 it_mbew-matnr+11(7), 39 sy-vline,

40 it_mbew-maktx, 80 sy-vline,

81 it_mbew-cur_rate CENTERED, 91 sy-vline,

92(13) it_mbew-lbkum right-justified, 105 sy-vline,

106 it_mbew-meins, 111 sy-vline,

112 IT_MBEW-SALK1 left-justified, 126 SY-VLINE,

127(13) IT_MBEW-TOTUR right-justified, 141 SY-VLINE,

142 IT_MBEW-SALK2 left-justified, 156 SY-VLINE,

157(10) IT_MBEW-TOT_3 right-justified, 170 SY-VLINE,

171 IT_MBEW-W_VALUE2 left-justified, 184 SY-VLINE,

185(10) it_mbew-tot_1 right-justified, 198 sy-vline,

199 it_mbew-w_value left-justified, 212 sy-vline,

213 it_mbew-w_days CENTERED, 223 sy-vline,

224(10) it_mbew-tot_2 right-justified, 237 sy-vline,

238 it_mbew-w_value1 left-justified, 251 sy-vline.

FORMAT COLOR 2 OFF INTENSIFIED.

  • ENDLOOP.

ULINE (251).

elseif details = 'X'.

  • LOOP AT it_mbew.

AT FIRST.

w_pagectr = 1.

PERFORM header1.

ENDAT.

FORMAT COLOR 2 ON INTENSIFIED.

WRITE : /01 sy-vline,

02 it_mbew-bwkey, 10 sy-vline,

11 it_mbew-bklas, 20 sy-vline,

21 IT_MBEW-EKGRP, 27 SY-VLINE,

28 it_mbew-matnr+11(7), 39 sy-vline,

40 it_mbew-maktx, 80 sy-vline,

81(10) it_mbew-erfmg right-justified, 93 sy-vline

,

94(10) it_mbew-erfme right-justified, 104 sy-vline,

105 it_mbew-letztzug, 117 sy-vline,

118 it_mbew-letztabg , 129 sy-vline,

130 it_mbew-letztver, 141 sy-vline,

142 it_mbew-letztbew, 153 sy-vline.

FORMAT COLOR 2 OFF INTENSIFIED.

ULINE /(153).

ENDIF.

ENDLOOP.

LOOP AT it_mbew1.

AT FIRST.

w_pagectr = 1.

PERFORM summary.

ENDAT.

************************by ganesh

it_mbew1-tot_31 = it_mbew1-tot_31 + it_mbew1-tot_3.

it_mbew1-tot_21 = it_mbew1-tot_21 + it_mbew1-tot_2.

it_mbew1-tot_11 = it_mbew1-tot_11 + it_mbew1-tot_1.

it_mbew1-w_value01 = it_mbew1-w_value01 + it_mbew1-w_value.

it_mbew1-w_value11 = it_mbew1-w_value11 + it_mbew1-w_value1.

it_mbew1-w_value21 = it_mbew1-w_value21 + it_mbew1-w_value2.

WRITE: /01 sy-vline,

10 sy-vline,

26 sy-vline,

44 sy-vline,

63 sy-vline,

82 sy-vline,

101 sy-vline,

119 sy-vline.

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

WRITE: 02 it_mbew1-bwkey COLOR 4 , 10 sy-vline.

WRITE: 01 sy-vline,

  • 11 it_mbew-tot_3 centered color 7, 26 sy-vline,

11 it_mbew1-tot_31 centered color 7, 26 sy-vline,

  • 27 it_mbew1-tot_1 CENTERED COLOR 7, 44 sy-vline,

27 it_mbew1-tot_11 CENTERED COLOR 7, 44 sy-vline,

  • 45 it_mbew1-tot_2 CENTERED COLOR 7, 63 sy-vline,

45 it_mbew1-tot_21 CENTERED COLOR 7, 63 sy-vline,

64 it_mbew1-w_value21 centered color 7, 82 sy-vline,

83 it_mbew1-w_value01 CENTERED COLOR 7, 101 sy-vline ,

102 it_mbew1-w_value11 CENTERED COLOR 7, 119 sy-vline.

ENDLOOP.

CLEAR : it_mbew1[] , it_mbew1.

free : it_mbew1[] , it_mbew1.

ULINE /(119).

clear : it_mseg[],it_mseg, it_mkpf[], it_mkpf, IT_MBEW, IT_MBEW[].

free: it_mseg[],it_mseg, it_mkpf[], it_mkpf, IT_MBEW, IT_MBEW[].

&----


*& Form header

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM header .

WRITE : AT 110 'Page : ', w_pagectr COLOR 7.

WRITE : /50 ' KANSAI NEROLAC PAINTS LIMITED' COLOR 7.

WRITE : /50 '----


'.

WRITE : /50 'INTERMEDIATE INVENTORY REPORT' COLOR 7. " ADDED BY

WRITE : /2 'DATE', sy-datum COLOR 6 INVERSE ON. "AMRITANSHU

FORMAT COLOR 7.

ULINE /(251).

FORMAT COLOR 4 ON INTENSIFIED.

WRITE : /01 sy-vline,

02 'FACTORY', 10 sy-vline,

11 'VALUATION', 20 sy-vline,

21 'PURCH', 27 SY-VLINE,

28 'MATERIAL', 39 sy-vline,

40 'MATERIAL DESCRIPTION', 80 sy-vline,

81 'RATE', 91 sy-vline,

92 'TOTAL STOCK', 105 sy-vline,

106 'UOM' , 111 SY-VLINE,

112 'TOTAL VALUE', 126 sy-vline,

127 'TOT UNRES & RES', 141 SY-VLINE,

142 'TOT UNRES & RES' , 156 SY-VLINE,

157 'QUANTITY', 170 sy-vline,

171 'VALUE CONSUMP', 184 sy-vline,

185 'QUANTITY', 198 sy-vline,

199 'VALUE CONSUMP', 212 sy-vline,

213 'NO.OF DAYS', 223 sy-vline,

224 'QUANTITY', 237 sy-vline,

238 'VALUE CONSUMP', 251 sy-vline.

FORMAT COLOR 4 OFF INTENSIFIED.

WRITE: /01 sy-vline,

10 sy-vline ,

11 'CLASS' COLOR 4,

20 sy-vline,

21 'GROUP' COLOR 4,

27 sy-vline,

39 sy-vline,

80 sy-vline,

91 SY-VLINE,

105 SY-VLINE,

111 SY-VLINE,

112 '(INR)' COLOR 4,

126 SY-VLINE,

127 ' STOCK ' COLOR 4,

141 SY-VLINE,

142 '(INR)' COLOR 4,

156 SY-VLINE,

157 'IN 6 MNTHS' COLOR 4,

170 SY-VLINE,

171 'IN 6 MNTHS' COLOR 4,

184 SY-VLINE,

185 'IN 3 MNTHS' COLOR 4,

198 SY-VLINE,

199 'IN 3 MNTHS' COLOR 4,

212 SY-VLINE,

213 '(INVENTORY)' COLOR 4,

223 sy-vline,

224 'IN 1 MNTHS' COLOR 4,

237 SY-VLINE,

238 'IN 1 MNTHS' COLOR 4,

251 SY-VLINE.

ULINE (251).

ENDFORM. " header

&----


*& Form summary

&----


  • text

----


FORM summary.

WRITE : AT 110 'Page : ', w_pagectr COLOR 7.

WRITE : /50 ' KANSAI NEROLAC PAINTS LIMITED' COLOR 7.

WRITE : /50 '----


'.

WRITE : /50 'INTERMEDIATE INVENTORY SUM REPORT' COLOR 7. " ADDED BY

WRITE : /2 'DATE' , sy-datum COLOR 6 INVERSE ON. "AMRITANSHU

FORMAT COLOR 7.

ULINE /(119).

FORMAT COLOR 4 ON INTENSIFIED.

WRITE : /01 sy-vline,

02 'FACTORY' , 10 sy-vline,

11 ' QUANTITY', 26 sy-vline,

27 ' QUANTITY' , 44 sy-vline,

45 ' QUANTITY ' , 63 SY-VLINE,

64 ' Value CONSUMP', 82 sy-vline,

83 ' Value CONSUMP' , 101 sy-vline,

102 ' Value CONSUMP ', 119 sy-vline.

FORMAT COLOR 4 OFF INTENSIFIED.

WRITE: /01 sy-vline,

10 sy-vline,

11 ' IN 6 MNTHS ' COLOR 4,

26 sy-vline,

27 ' IN 3 MNTHS ' COLOR 4,

44 sy-vline,

45 ' IN 1 MNTHS ' COLOR 4,

63 sy-vline,

64 ' IN 6 MNTHS ' COLOR 4,

82 sy-vline,

83 ' IN 3 MNTHS ' COLOR 4,

101 sy-vline,

102 ' IN 1 MNTHS ' COLOR 4,

119 sy-vline.

ULINE /(119).

ENDFORM. "summary

&----


*& Form header1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form header1 .

WRITE : AT 110 'Page : ', w_pagectr COLOR 7.

WRITE : /50 ' KANSAI NEROLAC PAINTS LIMITED' COLOR 7.

WRITE : /50 '----


'.

WRITE : /50 'INTERMEDIATE INVENTORY REPORT' COLOR 7. " ADDED BY

WRITE : /2 'DATE', sy-datum COLOR 6 INVERSE ON. "AMRITANSHU

FORMAT COLOR 7.

ULINE /(153).

FORMAT COLOR 4 ON INTENSIFIED.

WRITE : /01 sy-vline,

02 'FACTORY', 10 sy-vline,

11 'VALUATION', 20 sy-vline,

21 'PURCH', 27 SY-VLINE,

28 'MATERIAL', 39 sy-vline,

40 'MATERIAL DESCRIPTION', 80 sy-vline,

81 'RECEIPTS', 93 sy-vline,

94 'UNIT ', 104 sy-vline,

105 'LAST.RECPT', 117 SY-VLINE,

118 'LAST.GOODS.', 129 SY-VLINE,

130 'LAST.COMSUMP', 141 SY-VLINE,

142 'LAST.GOODS', 153 SY-VLINE.

WRITE: /01 sy-vline,

10 sy-vline ,

11 'CLASS' COLOR 4,

20 sy-vline,

21 'GROUP' COLOR 4,

27 sy-vline,

39 sy-vline,

80 sy-vline,

93 sy-vline,

104 sy-vline,

117 SY-VLINE,

118 'ISSUE' COLOR 4,

129 SY-VLINE,

141 SY-VLINE,

142 'MVT' COLOR 4,

153 SY-VLINE.

ULINE /(153).

endform. " header1

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question