--先从预占里查到没拣货记帐的单据
select f_get_ph(spid,yzid,phid),t.*,t.rowid from kc_spyfpzy t where spid ='SPH00002147' and f_get_ph(spid,yzid,phid)='202109079' order by rq desc
--从单据中找到分配单号
select * from out_sale_task_d_hty t where djbh='XSGYMA00604208'and spid='SPH00000591';
select * from out_sale_task_d_hty t where djbh_fpd='2022012298145'
--SPH00000591
--2022012298145
select * from kc_spzy t where djbh='XSGYMA00604208';
select *from stock_lot_storagespaces t where spid='SPH00003560'
--运行过程
begin
for R_MX in (
select * from out_sale_task_d_hty t where djbh_fpd='2022012298145'
) loop
PROC_STOCK_NUM_PRE(R_MX.YZID,
R_MX.SPID,
R_MX.PHID,
R_MX.HWID,
'2',
-R_MX.SL_JH,
'1',
'',
R_MX.DJBH,
'拣货确认记帐');
PROC_STOCK_NUM_PRO(R_MX.YZID,
R_MX.SPID,
R_MX.PHID_TZ,
R_MX.HWID_TZ,
'2',
R_MX.SL_SJ,
'1',
'');
PROC_WRITE_ACC_CK(R_MX.YZID,
R_MX.DJBH,
R_MX.SPID,
R_MX.PHID_TZ,
R_MX.HWID_TZ,
0,--入库数
R_MX.SL_SJ,--出库数
'出库',
SYSDATE,
R_MX.DJ);
end loop;
end;