REPORT zscm_vendor2 LINE-SIZE 1023.
DATA: BEGIN OF itab OCCURS 0,
spras LIKE lfa1-spras,
lifnr LIKE lfa1-lifnr,
name1 LIKE adrc-name1,
name3 LIKE adrc-name3,
regio LIKE lfa1-regio,
stras LIKE lfa1-stras,
str_suppl1 LIKE adrc-str_suppl1,
pstlz LIKE lfa1-pstlz,
telf1 LIKE lfa1-telf1,
telfx LIKE lfa1-telfx,
name2 LIKE knvk-name1,
smtp_addr LIKE adr6-smtp_addr,
buy_id(12) TYPE c,
stceg LIKE lfa1-stceg,
banka LIKE bnka-banka,
bankn LIKE lfbk-bankn,
vendor_type(3) TYPE c,
* balance_type(4) TYPE c,
END OF itab.
DATA: BEGIN OF itab_temp OCCURS 0 ,
adrnr LIKE lfa1-adrnr.
INCLUDE STRUCTURE itab.
DATA: END OF itab_temp.
DATA: BEGIN OF itab_adrc OCCURS 0,
addrnumber LIKE adrc-addrnumber,
name1 LIKE adrc-name1,
name3 LIKE adrc-name3,
str_suppl1 LIKE adrc-str_suppl1,
smtp_addr LIKE adr6-smtp_addr,
END OF itab_adrc.
DATA: BEGIN OF itab_knvk OCCURS 0,
lifnr LIKE lfa1-lifnr,
name2 LIKE knvk-name1,
END OF itab_knvk.
DATA: BEGIN OF itab_bnka OCCURS 0,
lifnr LIKE lfbk-lifnr,
banka LIKE bnka-banka,
bankn LIKE lfbk-bankn,
END OF itab_bnka.
DATA: BEGIN OF itab_lfb1 OCCURS 0,
lifnr LIKE lfb1-lifnr,
bukrs LIKE lfb1-bukrs,
zterm LIKE lfb1-zterm,
END OF itab_lfb1.
DATA: changenr LIKE zcdhdr_max-changenr.
PARAMETER: date TYPE syst-datum.
DATA: BEGIN OF itab_object OCCURS 0,
objectid LIKE lfa1-lifnr ,
END OF itab_object.
PERFORM getvendordata.
*&---------------------------------------------------------------------*
*& Form getvendordata
*&---------------------------------------------------------------------*
FORM getvendordata.
** get max changenr
* SELECT MAX( zcdhdr_max~changenr )
* INTO changenr
* FROM zcdhdr_max
* WHERE zcdhdr_max~erdat < date .
* get objectid from cdhdr by using kred, max changenr, and date
SELECT cdhdr~objectid
INTO CORRESPONDING FIELDS OF TABLE itab_object
FROM cdhdr
WHERE cdhdr~objectclas = 'KRED' AND
* cdhdr~changenr > changenr AND
cdhdr~udate = date .
LOOP AT itab_object.
IF itab_object-objectid+0(1) = 'B'.“B为公司职员
DELETE itab_object.
ENDIF.
ENDLOOP.
* DELETE ADJACENT data
SORT itab_object.
DELETE ADJACENT DUPLICATES FROM itab_object.
CHECK NOT itab_object[] IS INITIAL.
SELECT lfa1~spras
lfa1~lifnr
lfa1~stceg
lfa1~regio
lfa1~stras
lfa1~pstlz
lfa1~telf1
lfa1~telfx
lfa1~adrnr
lfa1~ernam AS buy_id
lfa1~ktokk AS vendor_type
INTO CORRESPONDING FIELDS OF TABLE itab_temp
FROM lfa1
FOR ALL ENTRIES IN itab_object
WHERE lfa1~lifnr = itab_object-objectid.
SELECT
knvk~lifnr
knvk~name1 AS name2
INTO CORRESPONDING FIELDS OF TABLE itab_knvk
FROM knvk
FOR ALL ENTRIES IN itab_object
WHERE knvk~lifnr = itab_object-objectid.
SELECT lfbk~lifnr
bnka~banka
lfbk~bankn
INTO CORRESPONDING FIELDS OF TABLE itab_bnka
FROM lfbk INNER JOIN bnka
ON lfbk~banks = bnka~banks AND
lfbk~bankl = bnka~bankl
FOR ALL entries IN itab_object
WHERE lfbk~lifnr = itab_object-objectid.
CHECK NOT itab_temp[] IS INITIAL.
SELECT adrc~addrnumber
adrc~str_suppl1
adrc~name1
adrc~name3
adr6~smtp_addr
INTO CORRESPONDING FIELDS OF TABLE itab_adrc
FROM adrc LEFT JOIN adr6 ON adrc~addrnumber = adr6~addrnumber
FOR ALL entries IN itab_temp
WHERE adrc~addrnumber = itab_temp-adrnr .
LOOP AT itab_temp.
READ TABLE itab_knvk WITH KEY lifnr = itab_temp-lifnr.
IF sy-subrc = 0.
itab_temp-name2 = itab_knvk-name2.
ENDIF.
READ TABLE itab_bnka WITH KEY lifnr = itab_temp-lifnr.
IF sy-subrc = 0.
itab_temp-banka = itab_bnka-banka.
itab_temp-bankn = itab_bnka-bankn.
ENDIF.
READ TABLE itab_adrc WITH KEY addrnumber = itab_temp-adrnr.
IF sy-subrc = 0.
itab_temp-name1 = itab_adrc-name1.
itab_temp-name3 = itab_adrc-name3.
itab_temp-str_suppl1 = itab_adrc-str_suppl1.
itab_temp-smtp_addr = itab_adrc-smtp_addr.
ENDIF.
MODIFY itab_temp.
MOVE-CORRESPONDING itab_temp TO itab.
APPEND itab TO itab[] .
CLEAR itab_temp.
ENDLOOP.
LOOP AT itab.
WRITE:/ itab.
ENDLOOP.
* CALL FUNCTION 'WS_DOWNLOAD'
* EXPORTING
* filename = 'c:\vendor.txt'
* filetype = 'DAT'
* TABLES
* data_tab = itab[].
ENDFORM.
阅读(2773) | 评论(0) | 转发(0) |