人法地,地法天,天法道,道法自然
分类:
2009-01-15 10:43:45
移动类型y01稽查表
供应商代码: [A]
序号 |
物料号 |
物料描述 |
单位 |
消耗数量 |
记帐日期 |
物料凭证 |
成本中心 |
成本中心名称 |
用户名称 |
移动原因 | |
[B] |
[C] |
[D] |
[E] |
[F] |
[G] |
[H] |
[I] |
[J] |
[K] |
[L] | |
栏位定义说明:
[A]:用移动类型Y01做交易时的供应商代码
[B]:按数字顺序
[C]:用移动类型Y01做交易时的物料代码
[D]:根据C栏中的物料代码取其物料描述.
[E]:即是C栏中物料的单位
[F]:用移动类型Y01做交易时的每笔交易数量
[G]:用移动类型Y01做交易时的记帐日期
[H]:做完交易记录时所产生的物料凭证号,双击凭证号时能显示此凭证号的交易信息.
[I]:用移动类型Y01做交易时所对应的成本中心代码
[J]:即是I栏中成本中心的名称
[K]:用移动类型Y01所做交易时的用户代码
[L]:用移动类型Y01做交易的时输入的移动原因
备注:抓取此报表数据时的第一条件是:在记帐日期范围内用移动类型:Y02对同一物料、库位、数量进行冲销时,此笔Y01的交易明细就不显示。
代码编写
*&------------------------------------------------------------------*
*& Form get_mkpf_mseg *
*& *
*&------------------------------------------------------------------*
*& text *
*& *
*&------------------------------------------------------------------*
form get_mkpf_mseg .
select * from mkpf inner join mseg on mkpf~mblnr = mseg~mblnr and mkpf~mjahr = mseg~mjahr
into corresponding fields of table itab
where mseg~werks = p_werks
and mseg~lgort in s_lgort
and mseg~kostl in s_kostl
and mseg~matnr in s_matnr
and ( bwart = 'Y01' or bwart = 'Y02' )
and mkpf~budat in s_budat .
loop at itab .
if itab-bwart = 'Y02'.
itab-erfmg = - itab-erfmg .
endif.
select single maktx into itab-maktx
from makt where matnr = itab-matnr and spras = '1' .
select single ktext into itab-ktext
from cskt where kostl = itab-kostl and spras = '1' .
modify itab.
clear itab.
endloop.
sort itab by lgort matnr .
append lines of itab to itab1 .
sort itab1 by lgort .
delete adjacent duplicates from itab1 comparing lgort .
loop at itab .
itab-bwart = '' .
itab-budat = '' .
* itab-mblnr = '' .
move-corresponding itab to itab2 .
collect itab2 .
endloop.
loop at itab2 .
clear itab .
read table itab with key matnr = itab2-matnr
mblnr = itab2-mblnr
kostl = itab2-kostl
lgort = itab2-lgort
usnam = itab2-usnam .
* bwart = '201'.
if sy-subrc = 0 .
itab2-mblnr = itab-mblnr .
itab2-budat = itab-budat .
itab2-bwart = itab-bwart .
modify itab2 .
endif.
endloop.
* delete itab2 where erfmg <= 0 .
clear itab[] .
append lines of itab2 to itab .
sort itab by lgort kostl budat mblnr .
sort itab2 by lgort kostl budat mblnr .
loop at itab2 where bwart = 'Y01'.
loop at itab where bwart = 'Y02'.
if itab2-matnr = itab-matnr and itab2-kostl = itab-kostl and itab2-lgort = itab-lgort .
itab2-erfmg = itab2-erfmg + itab-erfmg .
delete itab .
modify itab2 .
exit.
endif.
endloop.
endloop.
delete itab2 where bwart = 'Y02' .
delete itab2 where erfmg <= '0.000' .
clear itab[] .
append lines of itab2 to itab .
sort itab by lgort kostl budat mblnr .
endform.