05-31-2007 10:20 AM
REPORT ZMTEST no standard page heading.
tables: mseg, makt, resb.
types: begin of ty_head,
date like sy-datum,
time like sy-uzeit,
mblnr like mseg-mblnr,
mjahr like mseg-mjahr,
budat like mkpf-budat,
WERKS like mseg-WERKS ,
LGORT like resb-LGORT,
UMLGO like mseg-UMLGO,
rsnum like resb-rsnum,
rspos like resb-rspos,
rsart like resb-rsart,
MATNR like mseg-MATNR,
MAKTX like makt-MAKTX,
MEINS like mseg-MEINS,
BDMNG like resb-BDMNG,
MENGE like mseg-MENGE,
end of ty_head.
data sno type sy-index.
data v_menge type mseg-menge.
data: it_head type standard table of ty_head
initial size 50.
data: wa_head type ty_head.
select-options : s_mblnr for mseg-mblnr obligatory.
parameters : s_year like mseg-mjahr default sy-datum.
select mblnr mjahr matnr meins menge werks umlgo
rsnum rspos lgort
from mseg into corresponding fields of table it_head
where mblnr in s_mblnr
and mjahr eq s_year .
if sy-subrc = 0.
sort it_head by mblnr mjahr matnr.
write: /65 'Time', Sy-uzeit,
/65 'Date', sy-datum.
loop at it_head into wa_head.
on change of wa_head-mblnr.
sno = 0.
select single budat into wa_head-budat
from mkpf
where mblnr = wa_head-mblnr
and mjahr = wa_head-mjahr.
select single lgort from resb into wa_head-lgort where rsnum =
wa_head-rsnum.
write:/ 'Document number: ' , wa_head-mblnr,
50 'Date of issue', wa_head-budat,
/ 'Plant', wa_head-werks,
/ 'Storage loc.', wa_head-lgort,
50 'Recieving Stloc', wa_head-umlgo.
uline /1(119).
write: / sy-vline,
'Sno', 6 sy-vline,
text-001 ,26 sy-vline,
text-002, 70 sy-vline,
text-003, 77 sy-vline,
text-004, 99 sy-vline,
text-005, 119 sy-vline.
uline /1(119).
endon.
select single bdmng into wa_head-bdmng
from resb where rsnum = wa_head-rsnum
and rspos = wa_head-rspos .
select single maktx into wa_head-maktx from makt
where matnr = wa_head-matnr.
*on change of wa_head-matnr.
sno = sno + 1.
v_menge = wa_head-menge + v_menge.
write: / sy-vline ,
3 sno left-justified,
6 sy-vline,
wa_head-matnr under text-001,
26 sy-vline,
wa_head-maktx under text-002,
70 sy-vline,
wa_head-meins under text-003,
77 sy-vline,
wa_head-bdmng under text-004,
99 sy-vline,
v_menge under text-005,
119 sy-vline.
*endon.
endloop.
uline /1(119).
endif.
this is my program .I want to display only one record istead of repeated and menge will be add.
plz help me .
thanking you.
05-31-2007 10:23 AM
Hello Suresh,
Make the change like this:
select mblnr mjahr matnr meins menge werks umlgo
rsnum rspos lgort
from mseg into corresponding fields of table it_head
where mblnr in s_mblnr
and mjahr eq s_year.
data: it_tmp like it_head occurs 0 with header line.
loop at it_head.
it_tmp = it_head. " Check here
collect it_tmp. " Check here
endloop.
clear: it_head,it_tmp.
refresh it_head.
it_head[9 = it_tmp[] " Check here
Regards,
VAsanth