1、 MI21格式打印时很浪费纸张,所以创建ZMI21
2、 从表ISEG获取数据
*&---------------------------------------------------------------------*
*& Progarm : ZMM_MI21 Author : Jimmy Wong
*& Created : 11 Apr 2013 App : MM
*& Title : Material Copy by same SBU
*& Description : Material Copy by same SBU
*&---------------------------------------------------------------------*
*& Version Author Date description
*& Jimmy 11 Apr 2013 the first version
*& the last update time 2013.04.11 16:00
*&---------------------------------------------------------------------*
report zmm_mi21 line-size 132 line-count 60 no standard page heading.
tables: iseg.
data:begin of wa_itab ,
iblnr like iseg-iblnr,
gjahr like iseg-gjahr,
zeili like iseg-zeili,
matnr like iseg-matnr,
werks like iseg-werks,
lgort like iseg-lgort,
charg like iseg-charg,
menge like iseg-menge,
meins like iseg-meins,
maktx like makt-maktx,
end of wa_itab.
data: itab like table of wa_itab with header line.
data:begin of it_iblnr occurs 0,
iblnr like iseg-iblnr,
werks like iseg-werks,
lgort like iseg-lgort,
end of it_iblnr.
selection-screen begin of block 1 with frame title text-001.
select-options : s_iblnr for iseg-iblnr .
select-options : s_gjahr for iseg-gjahr .
select-options : s_werks for iseg-werks default '8101'.
select-options : s_matnr for iseg-matnr .
select-options : s_lgort for iseg-lgort .
selection-screen end of block 1.
top-of-page.
perform report_title.
start-of-selection.
perform get_data.
if itab[] is initial.
message i003(zmm).
exit.
endif.
perform write_data.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_data .
select a~iblnr a~gjahr a~zeili a~matnr a~werks a~lgort a~charg a~menge a~meins
b~maktx
into corresponding fields of table itab
from iseg as a inner join makt as b on a~matnr = b~matnr
where a~iblnr in s_iblnr
and a~gjahr in s_gjahr
and a~matnr in s_matnr
and a~werks in s_werks
and a~lgort in s_lgort.
loop at itab .
move-corresponding itab to it_iblnr.
collect it_iblnr.
endloop.
endform. " GET_DATA
*&---------------------------------------------------------------------*
*& Form REPORT_TITLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form report_title .
data : position like sy-linsz,
time(8) type c.
if sy-pagno ne 1 .
skip 2.
write :/ ' ',
at 10(30) 'Counted by _______________' ,
at 48(80) 'Checked by ______________' ,
at 81(100)'Input by _______________'.
skip 2.
endif.
write at /1(sy-linsz) 'VTECH COMMUNICATIONS LTD. (CMS)' centered.
write : 1 'Prg:', sy-cprog(14) no-gap,
'/' no-gap, sy-tcode(8).
position = sy-linsz - 16.
write: at position 'Page:', sy-pagno.
write : /1 'User-ID:', sy-uname.
write: at position 'Date:',sy-datum mm/dd/yyyy.
write at /1(sy-linsz) sy-title centered.
write at position 'Time:' .
write sy-timlo using edit mask '__:__:__'.
skip 1.
write: / ' ',
at 1(7) 'Plant:',
at 8(12) itab-werks,
at 15(32) 'Phys. inv. doc.:',
at 33(43) itab-iblnr,
at 45(56) 'Sloc Stor.:',
at 57(67) itab-lgort.
skip 1.
write :/ ' ',
at 1(5) 'Item',
at 6(25) 'Material' ,
at 26(66) 'Material Desc' ,
at 67(77) 'Batch' ,
at 78(88) 'Unit' ,
at 89(101)'Counted Qty'.
write :/ ' ',
at 1(5) '====',
at 6(25) '===================' ,
at 26(66) '=======================================' ,
at 67(77) '==========' ,
at 78(88) '==========' ,
at 89(101)'============'.
endform. " REPORT_TITLE
*&---------------------------------------------------------------------*
*& Form WRITE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form write_data .
sort itab by iblnr gjahr zeili werks lgort.
sort it_iblnr by iblnr werks lgort.
loop at it_iblnr .
new-page.
* perform report_title.
loop at itab where iblnr = it_iblnr-iblnr and werks = it_iblnr-werks and lgort = it_iblnr-lgort.
write :/ ' ',
at 1(5) itab-zeili no-zero,
at 6(25) itab-matnr ,
at 26(66) itab-maktx ,
at 67(77) itab-charg ,"no-zero ,
at 78(88) itab-meins ,
at 89(100)'___________'.
endloop.
at last.
skip 2.
write :/ ' ',
at 10(30) 'Counted by _______________' ,
at 48(80) 'Checked by ______________' ,
at 81(100)'Input by _______________'.
skip 2.
endat.
endloop.
endform. " WRITE_DATA