Skip to Content
0
Former Member
May 11, 2008 at 11:13 PM

how to get Max and Min in one line .

43 Views

Hi Guys

I know the program which I did is stupid .. I am getting the result for max and min value?

But I how can I get the value of km, h, lit in one line

Equno..max_date,min_date,min_value_km..max_value_km....min_value_h...max_value_h...min_value_l...max_value_l

with my program i am getting the vlaue of max and min value but not in one line.

the main parameter is recdu which is KM,L,H

Can anyone tell me the logic please

REPORT ZFUEL LINE-SIZE 200 LINE-COUNT 75

NO STANDARD PAGE HEADING.

TABLES : equi,

equz,

imptt,

imrg,

eqkt,

iloa.

  • Type Declaration

TYPES: BEGIN OF ty_data ,

equnr type equnr, " Euipment no

eqktx type eqkt-eqktx, " Equipment Text

eqfnr type iloa-eqfnr, " Equipment Sort field

idate type imrg-idate, " Measuring Date

recdu type imrg-recdu, " Unit of measuring ='KM','L','H'

recdv type imrg-recdv, " Counter reading data

END OF ty_data.

TYPES: BEGIN OF ty_final,

equnr type equnr, " Equipment no

eqktx type eqkt-eqktx, " Equipment Text

eqfnr type iloa-eqfnr, " Equipment Sort field

min_date type imrg-idate, " Min Date

min_km type p decimals 2, " Max Km

max_km type p decimals 2, " Min km

t_max_min_km type i, " Total min_km-max_km

max_date type imrg-idate, " Max Date

min_hr type imrg-recdv, " Max hr

max_hr type imrg-recdv, " Min hr

t_max_min_hr type i, " Total min_hr-max_hr

min_lit type imrg-recdv, " Max lit

max_lit type imrg-recdv, " Min lit

t_max_min_lit type i, " Total min_lit-max_lit

fuel_con type p decimals 2, " Total_hrs / t_max_min_hr

km_l type p decimals 2, " km / L

lit_per_hr type i , " fuel comsumed / t_max_min_hr

END OF ty_final.

DATA: i_data TYPE TABLE OF ty_data, " internal table

wa_data TYPE ty_data, " work area

i_final TYPE TABLE OF ty_final, " internal table

wa_final TYPE ty_final. " work area

data: begin of itab occurs 0,

num type i,

end of itab.

data: v_min_1 type i,

v_max_1 type i,

min_km like imrg-recdv,

max_km like imrg-recdv,

min_l like imrg-recdv,

max_l like imrg-recdv,

max_dt like imrg-idate,

min_dt like imrg-idate,

t_ma_mi type p decimals 2,

V1 LIKE IMRG-RECDV ,

V2 LIKE IMRG-RECDV .

SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.

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

SELECT-OPTIONS: p_equnr FOR equi-equnr ,"no-extension no intervals,

p_idate FOR imrg-idate. "NO-EXTENSION NO INTERVALS OBLIGATORY,

"p_recdu FOR imrg-recdu NO-EXTENSION NO INTERVALS default 'KM' OBLIGATORY.

SELECTION-SCREEN END OF BLOCK blk1.

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

SELECTION-SCREEN END OF BLOCK blk2.

SELECTION-SCREEN END OF BLOCK blk.

TOP-OF-PAGE.

FORMAT INTENSIFIED ON.

WRITE:/1(40) ' INVESTMENT LIMITED '.

WRITE:/50(40) ' FUEL CONSUMPTION REPORT ' CENTERED ,

2 'Page', sy-pagno.

FORMAT INTENSIFIED OFF.

WRITE:/50(40) '----


' CENTERED .

FORMAT INTENSIFIED ON.

WRITE:/2 sy-datum COLOR 3, sy-uzeit .

"WRITE:/1 S903-SPMON ."p_yearf.

ULINE.

"CENTERED.

write: /2 'Date From :'.

write: /2 'Equipment No :'.

write: /2 'Unit :'.

SKIP.

ULINE.

WRITE:/1 sy-vline,

2 'EQUIP NO', 10 sy-vline,

11 'NAME', 40 sy-vline,

41 'min date', 50 sy-vline,

51 'max date', 60 sy-vline,

61 'min km', 70 sy-vline,

71 'max km' , 80 sy-vline,

81 't_max_min_km', 90 sy-vline,

91 'min hr', 100 sy-vline,

101 'max hr', 110 sy-vline,

111 't_max_min_hr' , 120 sy-vline,

121 'min lit', 130 sy-vline,

131 'max lit', 140 sy-vline,

141 't_max_min_lit', 150 sy-vline,

151 'fuel con', 160 sy-vline,

161 'km_l', 170 sy-vline,

171 'lit_per_hr', 180 sy-vline.

FORMAT COLOR 3 ON.

ULINE.

END-OF-PAGE.

START-OF-SELECTION.

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

select aequnr deqktx feqfnr eidate erecdu erecdv

into table i_data

from equi AS a

inner join equz as b

on aequnr = bequnr

inner join iloa as f

on biloan = filoan

inner join imptt as c

on aobjnr = cmpobj

inner join eqkt as d

on aequnr = dequnr

inner join imrg as e

on epoint = cpoint

where a~equnr in p_equnr

and

e~idate in p_idate

and

e~recdu = 'KM'.

SORT i_data BY equnr idate descending .

loop at i_data into wa_data.

max_km = wa_data-recdv.

min_km = wa_data-recdv.

at new equnr.

read table i_data into wa_data index sy-tabix.

write:/ wa_data-equnr, wa_data-eqktx ,wa_data-eqfnr ,wa_data-idate ,'MAX KM',max_km EXPONENT 0 DECIMALS 2 color 7,wa_data-recdu .

endat.

at end of equnr.

read table i_data into wa_data index sy-tabix.

write:/ wa_data-equnr, wa_data-eqktx ,wa_data-eqfnr ,wa_data-idate ,'MIN KM', min_km EXPONENT 0 DECIMALS 2 color 7, wa_data-recdu .

endat.

at end of equnr.

write: / '----


'.

write: /50(80) 'Subtotal' COLOR 4 .

write:/ '----


'.

endat.

endloop.

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

select aequnr deqktx feqfnr eidate erecdu erecdv

into table i_data

from equi AS a

inner join equz as b

on aequnr = bequnr

inner join iloa as f

on biloan = filoan

inner join imptt as c

on aobjnr = cmpobj

inner join eqkt as d

on aequnr = dequnr

inner join imrg as e

on epoint = cpoint

where a~equnr in p_equnr

and

e~idate in p_idate

and

e~recdu = 'L'.

SORT i_data BY equnr idate descending .

loop at i_data into wa_data.

max_km = wa_data-recdv.

min_km = wa_data-recdv.

at new equnr.

read table i_data into wa_data index sy-tabix.

write:/ wa_data-equnr, wa_data-eqktx ,wa_data-eqfnr ,wa_data-idate ,'MAX LIT',max_km EXPONENT 0 DECIMALS 2 color 7,wa_data-recdu .

endat.

at end of equnr.

read table i_data into wa_data index sy-tabix.

write:/ wa_data-equnr, wa_data-eqktx ,wa_data-eqfnr ,wa_data-idate ,'MIN LIT', min_km EXPONENT 0 DECIMALS 2 color 7, wa_data-recdu .

endat.

at end of equnr.

write: / '----


'.

write: /50(80) 'Subtotal' COLOR 4 .

write:/ '----


'.

endat.ENDLOOP.

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

select aequnr deqktx feqfnr eidate erecdu erecdv

into table i_data

from equi AS a

inner join equz as b

on aequnr = bequnr

inner join iloa as f

on biloan = filoan

inner join imptt as c

on aobjnr = cmpobj

inner join eqkt as d

on aequnr = dequnr

inner join imrg as e

on epoint = cpoint

where a~equnr in p_equnr

and

e~idate in p_idate

and

e~recdu = 'H'.

SORT i_data BY equnr idate descending .

loop at i_data into wa_data.

max_km = wa_data-recdv.

min_km = wa_data-recdv.

at new equnr.

read table i_data into wa_data index sy-tabix.

write:/ wa_data-equnr, wa_data-eqktx ,wa_data-eqfnr ,wa_data-idate ,'MAX H',max_km EXPONENT 0 DECIMALS 2 color 7,wa_data-recdu .

endat.

at end of equnr.

read table i_data into wa_data index sy-tabix.

write:/ wa_data-equnr, wa_data-eqktx ,wa_data-eqfnr ,wa_data-idate ,'MIN H', min_h EXPONENT 0 DECIMALS 2 color 7, wa_data-recdu .

endat.

at end of equnr.

write: / '----


'.

write: /50(80) 'Subtotal' COLOR 4 .

write:/ '----


'.

endat.

endloop.