条件信息记录 获取价格 价格单位,
条件信息记录到工厂级别从A017表获取
条件信息记录到物料级别从A018获取
根据获取到的条件记录号关联KONP和KONH获取有效期内的价格
*获取信息记录 价格
SELECT SINGLE knumh
INTO @DATA(lv_knumh)
FROM a017
WHERE kappl = 'M'
AND lifnr = 供应商
AND matnr = 物料
AND ekorg = 采购组织
AND werks = 工厂
AND datbi >= sy-datum
AND datab <= sy-datum.
IF sy-subrc NE 0.
SELECT SINGLE knumh
INTO @lv_knumh
FROM a018
WHERE kappl = 'M'
AND lifnr = 供应商
AND matnr = 物料
AND ekorg = 采购组织
AND datbi >= sy-datum
AND datab <= sy-datum.
IF lv_knumh IS INITIAL .
MESSAGE e000(zmm01) WITH '获取不到相应的条件信息记录,价格未维护!'.
ENDIF.
ENDIF.
*获取价格
SELECT SINGLE a~kbetr a~kpein
FROM konp AS a INNER JOIN konh AS b ON a~knumh = b~knumh
INTO @(ls_konp)
WHERE a~knumh = lv_knumh
AND b~datab <= sy-datum "开始日期
AND b~datbi >= sy-datum. "截止日期
采购信息记录
工厂级别根据工厂+物料+采购组织+物料获取
物料级别根据物料+采购组织+物料获取
关联EINE EINA可以获取到税码,采购组,货币码,过量交货标识,交货不足限度
SELECT SINGLE a~mwskz
a~EKGRP,
a~WAERS,
a~uebto,
a~untto,
FROM eine AS a INNER JOIN eina AS b ON a~infnr = b~infnr
INTO @DATA(ls_eine)
WHERE a~ekorg = 采购组织
* AND a~werks = 工厂
AND b~matnr = 物料
AND b~lifnr = 供应商
AND b~loekz = ''.
IF sy-subrc NE 0 .
MESSAGE e000(zmm01) WITH '获取不到相应的采购信息记录!'.
ENDIF.