同类型,不同长度的字段要相等,可以这样,如:
EKPO~EBELN = VBKD~BSTKD+0(10) 强制转化的方式,程序可以激活,可以执行,但是会有警告。如图:
不同类型,不同长度字段要相等,可以这样,如:
S_POSEX LIKE EKPO-EBELP,
S_BSTKD LIKE EKPO-EBELN,
在内表里填加2个参考要对等的字段,然后loop。
IF ITABMS[] IS NOT INITIAL.
SELECT D~VBELN D~POSNR D~VGBEL D~VGPOS D~POSEX D~KWMENG D~KDMAT D~MATNR
E~BSTKD E~BSTDK E~IHREZ
INTO CORRESPONDING FIELDS OF TABLE ITABAP
FROM VBAP AS D
JOIN VBKD AS E ON D~VBELN = E~VBELN AND D~POSNR = E~POSNR "销售凭证 : 业务数据
FOR ALL ENTRIES IN ITABMS
WHERE D~VBELN = ITABMS-VGBEL
AND D~MATNR = ITABMS-MATNR.
ENDIF.
DELETE ADJACENT DUPLICATES FROM ITABAP COMPARING ALL FIELDS.
LOOP AT ITABAP.
ITABAP-S_POSEX = ITABAP-POSEX.
ITABAP-S_BSTKD = ITABAP-BSTKD.
MODIFY ITABAP TRANSPORTING S_POSEX S_BSTKD.
CLEAR ITABAP.
ENDLOOP.
IF ITABAP[] IS NOT INITIAL.
SELECT A~EBELN A~EBELP A~MATNR A~NETPR A~PEINH A~BPRME A~MENGE A~MTART
INTO CORRESPONDING FIELDS OF TABLE ITABEK
FROM EKPO AS A
FOR ALL ENTRIES IN ITABAP
WHERE A~EBELN = ITABAP-S_BSTKD
AND A~EBELP = ITABAP-S_POSEX
AND A~MATNR = ITABAP-MATNR
AND A~MTART = 'FERT'.
ENDIF.