123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- $PBExportHeader$f_check_mtrlware_inmx.srf
- global type f_check_mtrlware_inmx from function_object
- end type
- forward prototypes
- global function integer f_check_mtrlware_inmx (long arg_scid, long arg_mtrlwareid, ref transaction commit_transaction, ref string arg_msg)
- end prototypes
- global function integer f_check_mtrlware_inmx (long arg_scid, long arg_mtrlwareid, ref transaction commit_transaction, ref string arg_msg);//查有问题语句
- //SELECT u_mtrldef.mtrlcode,u_mtrlware.scid,u_mtrlware.mtrlwareid,u_mtrlware.noallocqty ,u_temp.qty From u_mtrlware
- //inner join u_mtrldef on u_mtrldef.mtrlid =u_mtrlware.mtrlid
- //inner join
- //
- //(SELECT scid,mtrlwareid,sum(inqty - outqty) as qty From u_mtrlware_inmx group by scid,mtrlwareid )
- //as u_temp on u_temp.scid =u_mtrlware.scid and u_temp.mtrlwareid =u_mtrlware.mtrlwareid
- //
- //where u_mtrlware.noallocqty <> u_temp.qty
- Long rslt = 1
- //查询当前库存数
- Decimal dec_noallocqty
- dec_noallocqty = 0
- SELECT noallocqty Into :dec_noallocqty From u_mtrlware Where scid = :arg_scid And mtrlwareid = :arg_mtrlwareid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询库存失败"
- GOTO ext
- END IF
- IF IsNull(dec_noallocqty) THEN dec_noallocqty = 0
- //查询进仓批可用数
- Decimal dec_useqty
- dec_useqty = 0
- SELECT sum(inqty - outqty) Into :dec_useqty From u_mtrlware_inmx Where scid = :arg_scid And mtrlwareid = :arg_mtrlwareid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询库存进仓批失败"
- GOTO ext
- END IF
- IF IsNull(dec_useqty) THEN dec_useqty = 0
- IF dec_noallocqty <> dec_useqty THEN
- rslt = 0
- arg_msg = "库存数和进仓批可用数不相同!请重试!"
- GOTO ext
- END IF
- ext:
- RETURN rslt
- end function
|