以料号作为筛选条件,带出INFO RECORD明细,
此资料要除掉已标识DELETE的部分(DELETE应该是EINA-LOEKZ = ‘X’),
并同时显示生效日期,VENDOR CODE,P/N,PRICE等资料,
最关键是直接DOWN为EXCEL格式
处理步骤:
一,从EINA中取出符合条件的资料:
select * from eina where matnr in s_matnr and
loekz <> 'X'....
二,串连EINE,得到INFO-RECORD之Item资料。
三,得到报表,并DOWN为EXCEL文件(两种方案,直接DOWN,再则另存为sheet)。
四,测试和结案。
==============================================
REPORT ZSZrMMW039 LINE-SIZE 255 LINE-COUNT 65 NO STANDARD PAGE HEADING
message-id zx.
TABLES: EINE, EINA,MARA,MAKT,LFA1.
DATA: BEGIN OF itab OCCURS 3,
infnr LIKE eina-infnr,
lifnr LIKE eina-lifnr,
matnr LIKE eina-matnr,
mfrnr LIKE eina-mfrnr,
matkl LIKE eina-matkl,
werks LIKE eine-werks,
erdat LIKE eine-erdat,
ernam LIKE eine-ernam,
ekgrp LIKE eine-ekgrp,
ebeln LIKE eine-ebeln,
ebelp LIKE eine-ebelp,
netpr LIKE eine-netpr,
peinh LIKE eine-peinh,
waers LIKE eine-waers,
mfrpn like mara-mfrpn,
maktx like makt-maktx,
name1 like lfa1-name1,
END OF itab.
SELECTION-SCREEN BEGIN OF BLOCK BK1.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:
P_LOEKZ LIKE EINA-LOEKZ. " 删除标记
SELECT-OPTIONS:
s_infnr for eina-infnr, " Info-record号码
s_lifnr for eina-lifnr, " Vendor
s_matnr for eina-matnr, " Material
s_mfrnr for eina-mfrnr, " Manufacturer
s_matkl for eina-matkl, " Material group
s_werks for eine-werks, " Plant
s_erdat for eine-erdat, " Create Date
s_ernam for eine-ernam, " Creater
s_ekgrp for eine-ekgrp, " Purchasing Group
s_ekorg for eine-ekorg default '1200',
" Purchasing Org.
s_ebeln for eine-ebeln. " Purchasing Document Num.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN END OF BLOCK BK1.
TOP-OF-PAGE.
PERFORM TITLE_FUNCTION.
PERFORM HEADER_FUNCTION.
START-OF-SELECTION.
PERFORM GET_INFO_RECORD_HEADER_DATA.
PERFORM GET_INFO_RECORD_ITEM_DATA.
PERFORM WRITE_REPORT.
*---------------------------------------------------------------------*
* FORM TITLE_FUNCTION *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM TITLE_FUNCTION.
call function 'Z_RP1_HEADING_X80'
EXPORTING
rp05_linsz = '165'
rp05_bukrs = '1200'
RP05_TCODE = 'ZSZD039'
RP05_TITLE2 = 'Info-Record list by Y/N complete'
EXCEPTIONS
size_too_small = 1
not_found_company = 2
title2_to_long = 3
title3_to_long = 4
others = 5.
skip.
ENDFORM.
*---------------------------------------------------------------------*
* FORM HEADER_FUNCTION *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM HEADER_FUNCTION.
WRITE: /001(006) 'Pur gp',
(018) 'Part no',
(010) 'Vendor',
(003) 'Cur',
(010) 'Valid from',
(010) 'Valid to',
(015) 'Scale1' RIGHT-JUSTIFIED,
(011) 'Rate1' RIGHT-JUSTIFIED,
(015) 'Scale2' RIGHT-JUSTIFIED,
(011) 'Rate2' RIGHT-JUSTIFIED,
(015) 'Scale3' RIGHT-JUSTIFIED,
(011) 'Rate3' RIGHT-JUSTIFIED,
(015) 'Scale4' RIGHT-JUSTIFIED,
(011) 'Rate4' RIGHT-JUSTIFIED,
(015) 'Scale5' RIGHT-JUSTIFIED,
(011) 'Rate5' RIGHT-JUSTIFIED,
(011) 'Punit',
(004) 'Plant',
(006) 'Tax co',
/030(040) 'Part description',
(030) 'Vendor name',
(010) 'MPN',
(040) 'MFRPN'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM WRITE_REPORT *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM WRITE_REPORT.
LOOP AT ITAB.
WRITE:/ itab-infnr,
itab-lifnr,
itab-matnr,
itab-mfrnr,
itab-matkl,
itab-werks,
itab-erdat,
itab-ernam,
itab-ekgrp,
itab-ebeln,
itab-ebelp,
itab-netpr,
itab-peinh,
itab-waers,
itab-mfrpn,
itab-maktx,
itab-name1.
ENDFORM.
*---------------------------------------------------------------------*
* FORM GET_INFO_RECORD_HEADER_DATA *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM GET_INFO_RECORD_HEADER_DATA.
clear itab.
refresh itab.
select
eina~infnr
eina~lifnr
eina~matnr
eina~mfrnr
eina~matkl
*******
eine~werks
eine~erdat
eine~ernam
eine~ekgrp
eine~ebeln
eine~ebelp
eine~netpr
eine~peinh
eine~waers
into
(itab-infnr
itab-lifnr
itab-matnr
itab-mfrnr
itab-matkl
itab-werks
itab-erdat
itab-ernam
itab-ekgrp
itab-ebeln
itab-ebelp
itab-netpr
itab-peinh
itab-waers)
from
eina inner join eine on eina~infnr = eine~infnr
where
eina~loekz = p_loekz and " 删除标记
eina~infnr in s_infnr and " Info-record号码
eina~lifnr in s_lifnr and " Vendor
eina~matnr in s_matnr and " Material
eina~mfrnr in s_mfrnr and " Manufacturer
eina~matkl in s_matkl and " Material group
eine~ekorg in s_ekorg and " purchasing org.
eine~werks in s_werks and " Plant
eine~erdat in s_erdat and " Create Date
eine~ernam in s_ernam and " Creater
eine~ekgrp in s_ekgrp and " Purchasing Group
eine~ebeln in s_ebeln. " Purchasing Document Num.
itab-netpr = itab-netpr / itab-peinh. "取得单价
append itab.
clear itab.
endselect.
ENDFORM.
*---------------------------------------------------------------------*
* FORM GET_INFO_RECORD_ITEM_DATA *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM GET_INFO_RECORD_ITEM_DATA.
clear itab.
refresh itab.
LOOP AT itab.
SELECT SINGLE * FROM MARA WHERE MATNR = itab-MATNR
AND MATKL IN S_MATKL.
if SY-SUBRC = 0.
itab-MFRPN = MARA-MFRPN.
endif.
SELECT SINGLE * FROM MAKT WHERE MATNR = itab-MATNR
and spras = sy-langu
AND MAKTX IN S_MAKTX.
if SY-SUBRC = 0.
itab-MAKTX = MAKT-MAKTX.
endif.
SELECT SINGLE * FROM LFA1 WHERE LIFNR = ITAB-LIFNR.
IF SY-SUBRC = 0.
itab-NAME1 = LFA1-NAME1.
ENDIF.
modify itab.
clear itab.
endloop.
ENDFORM.