一、单价赋值:
1.1、其他入库单JSKLHB,取出入库异动档(进货单/其他入库/成品入库)JSKLNA,最近一次进价
UPDATE JSKLHB SET LHB009=LNA012,LHB010=LNA012*LHB008
FROM JSKLHB
INNER JOIN
(select ROW_NUMBER() over(partition by LNA005 order by LNA006 DESC ,LNA002,LNA003 ) ROWNUM,
LNA005,LNA012,LNA006,LNA002,LNA003 from JSKLNA
WHERE LNA004='I' AND LNA012>0) AA ON LNA005=LHB003 AND ROWNUM=1
WHERE LHB009=0
1.2、将其他入库单身价格,更新出入库异动档其他入库的单价。
UPDATE JSKLNA SET LNA012=LHB009,LNA013=LHB010
FROM JSKLNA
INNER JOIN JSKLHB ON LHB001=LNA002 AND LHB002=LNA003
WHERE LNA012=0 AND LNA001='45'
注意:先后顺序不能返
二、更改单据属性
2.1更改出入库移动档
update JSKLNA set LNA028='3' where LNA004='I' and LNA001='45'
update JSKLNA set LNA016='T' where LNA004='I' and LNA001='45'
2.2更改其他入库档
update JSKLHA set LHA013='3'
2.3更改出入库类别
update JSKLAA set LAA004='3' where LAA001='04' or LAA001='07' or LAA001='08'
尽心, 2018.06.20 00:54