18910818955 发表于 2022-12-6 09:35:21

未将对象引用设置到对象的实例 请问如何解决

- ExecuteSingleFile end (with error).
- 执行错误的脚本内容:if object_id(N'BC_AnalyzeASNBarCode',N'P') is not null
begin
    drop proc BC_AnalyzeASNBarCode
END
go
Create procedure BC_AnalyzeASNBarCode
    @BarCode Nvarchar(Max)
As
Begin

    Declare @ErrorMess Nvarchar(1000)

    Declare @BarCodeID bigint
    Declare @BarCodeType Nvarchar(100)
    Declare @EntityID bigint
    Declare @EntityType nvarchar(100)
    Declare @EntityLineID bigint
    Declare @EntityLineType nvarchar(100)
    Declare @Qty decimal

    Select @BarCodeID=ID, @BarCodeType=BarCodeType, @EntityID=CreateEntity_EntityID,@EntityType=CreateEntity_EntityType ,
      @EntityLineID=CreateEntity_EntityID,@Qty=Qty
    From BC_BarCode Where Code=@BarCode


    -- 单据头条码
    If @BarCodeType=0 and @EntityType='UFIDA.U9.PM.ASN.ASN' and@EntityID>0
    Begin
      If Not Exists( Select 1 From PM_ASN where ID=@EntityID)
      Begin
            Raiserror('条码对应的创建ASN单据不存在,无法解析',16,1)
            Return
      End
                If Not Exists ( Select 1 From PM_ASN a   where a.ID=@EntityID and ((a.IsNeedPurConfirm=1 and a.IsConfirmed=1) or a.IsNeedPurConfirm=0) and a.Status=2)
      Begin
            Raiserror('ASN单未审核、或者需要做供应商确认',16,1)
            Return
      End

      Select
            @BarCode as BarCode,
            0 as IsItemCode,
            1 as Success,
            '' as ErrMsg,
            1 as 'DocInfos.$.*'

      Select
            1 as 'DocInfos.$',
            b.ID as EntityKey,
            'UFIDA.U9.PM.ASN.ASNLine' as EntityType,
            a.DocNo as DocNo,
            a.BusinessDate as DocDate,
            b.ItemInfo_ItemID as ItemID,
            c.Code as ItemCode,
            c.Name as ItemName,
            c.SPECS as ItemSpecs,
            b.LotMater as LotCode,
            b.TradeUOM as UOM,
            b.TradeBaseUOM as BaseUOM,
            d1.Name as TradeUOMName,
            b.ShipQtyTU-b.TotalRcvQtyTU as CanReceiveQty,
            b.ShipQtyTU-b.TotalRcvQtyTU as ReceivedQty,
            CONVERT(varchar(100), a.BusinessDate, 120) as DocDateStr,
            d.Round_RoundValue as RoundValue,
            d.Round_RoundType as RoundType,
            d.Round_Precision as RoundSpecision,
            a.Supplier_Supplier as SupplierID,
            a.Supplier_Code as SupplierCode,
            supplier.Name as SupplierName,
            @BarCode as BarCode
      From PM_ASN a
      Inner Join PM_ASNLine b on a.ID=b.ASN
      Inner Join CBO_ItemMaster c on b.ItemInfo_ItemID=c.ID
                left join CBO_Supplier_Trl supplier on supplier.ID = a.Supplier_Supplier and supplier.SysMLFlag='zh-CN'
      Inner Join Base_UOM d on b.TradeUOM=d.ID
      Left Join Base_UOM_trl d1 on d.ID=d1.ID and d1.SysMLFlag='zh-CN'
      Where a.ID=@EntityIDand ((a.IsNeedPurConfirm=1 and a.IsConfirmed=1) or a.IsNeedPurConfirm=0) anda.Status=2

    End
    Else If @BarCodeType=1 and @EntityType='UFIDA.U9.PM.ASN.ASNLine' and@EntityID>0
    Begin

      If Not Exists( Select 1 From PM_ASNLine where ID=@EntityID)
      Begin
            Raiserror('条码对应的创建ASN单据行不存在,无法解析',16,1)
            Return
      End

                If Not Exists ( Select 1 From PM_ASN a Inner Join PM_ASNLine b on a.ID=b.ASNwhere b.ID=@EntityID and ((a.IsNeedPurConfirm=1 and a.IsConfirmed=1) or a.IsNeedPurConfirm=0) and a.Status=2)
      Begin
            Raiserror('ASN单未审核、或者需要做供应商确认',16,1)
            Return
      End

         Select
            @BarCode as BarCode,
            0 as IsItemCode,
            1 as Success,
            '' as ErrMsg,
            1 as 'DocInfos.$.*'

      Select
            1 as 'DocInfos.$',
            b.ID as EntityKey,
            'UFIDA.U9.PM.ASN.ASNLine' as EntityType,
            a.DocNo as DocNo,
            a.BusinessDate as DocDate,
            b.ItemInfo_ItemID as ItemID,
            c.Code as ItemCode,
            c.Name as ItemName,
            c.SPECS as ItemSpecs,
            b.LotMater as LotCode,
            b.TradeUOM as UOM,
            b.TradeBaseUOM as BaseUOM,
            d1.Name as TradeUOMName,
            b.ShipQtyTU-b.TotalRcvQtyTU as CanReceiveQty,
            b.ShipQtyTU-b.TotalRcvQtyTU as ReceivedQty,
            CONVERT(varchar(100), a.BusinessDate, 120) as DocDateStr,
            d.Round_RoundValue as RoundValue,
            d.Round_RoundType as RoundType,
            d.Round_Precision as RoundSpecision,
            a.Supplier_Supplier as SupplierID,
            a.Supplier_Code as SupplierCode,
            supplier.Name as SupplierName,
            @BarCode as BarCode
      From PM_ASN a
      Inner Join PM_ASNLine b on a.ID=b.ASN
      Inner Join CBO_ItemMaster c on b.ItemInfo_ItemID=c.ID
                left join CBO_Supplier_Trl supplier on supplier.ID = a.Supplier_Supplierand supplier.SysMLFlag='zh-CN'
      Inner Join Base_UOM d on b.TradeUOM=d.ID
      Left Join Base_UOM_trl d1 on d.ID=d1.ID and d1.SysMLFlag='zh-CN'
      Where b.ID=@EntityIDand ((a.IsNeedPurConfirm=1 and a.IsConfirmed=1) or a.IsNeedPurConfirm=0) anda.Status=2
    End
    Else If @BarCodeType=3 and @EntityType='UFIDA.U9.PM.ASN.ASNLine' and@EntityID>0
    Begin
      
      If Not Exists( Select 1 From PM_ASNLine where ID=@EntityID)
      Begin
            Raiserror('条码对应的创建ASN单据行不存在,无法解析',16,1)
            Return
      End
               
                If Not Exists ( Select 1 From PM_ASN a Inner Join PM_ASNLine b on a.ID=b.ASNwhere b.ID=@EntityID and ((a.IsNeedPurConfirm=1 and a.IsConfirmed=1) or a.IsNeedPurConfirm=0) and a.Status=2)
      Begin
            Raiserror('ASN单未审核、或者需要做供应商确认',16,1)
            Return
      End

      Select
            @BarCode as BarCode,
            1 as IsItemCode,
            1 as Success,
            '' as ErrMsg,
            1 as 'DocInfos.$.*'

      Select
            1 as 'DocInfos.$',
            b.ID as EntityKey,
            'UFIDA.U9.PM.ASN.ASNLine' as EntityType,
            a.DocNo as DocNo,
            a.BusinessDate as DocDate,
            b.ItemInfo_ItemID as ItemID,
            c.Code as ItemCode,
            c.Name as ItemName,
            c.SPECS as ItemSpecs,
            b.LotMater as LotCode,
            b.TradeUOM as UOM,
            b.TradeBaseUOM as BaseUOM,
            d1.Name as TradeUOMName,
            b.ShipQtyTU-b.TotalRcvQtyTU as CanReceiveQty,
            @Qty as ReceivedQty,
            CONVERT(varchar(100), a.BusinessDate, 120) as DocDateStr,
            d.Round_RoundValue as RoundValue,
            d.Round_RoundType as RoundType,
            d.Round_Precision as RoundSpecision,
            a.Supplier_Supplier as SupplierID,
            a.Supplier_Code as SupplierCode,
            supplier.Name as SupplierName,
            @BarCode as BarCode
      From PM_ASN a
      Inner Join PM_ASNLine b on a.ID=b.ASN
      Inner Join CBO_ItemMaster c on b.ItemInfo_ItemID=c.ID
                left join CBO_Supplier_Trl supplier on supplier.ID = a.Supplier_Supplierand supplier.SysMLFlag='zh-CN'
      Inner Join Base_UOM d on b.TradeUOM=d.ID
      Left Join Base_UOM_trl d1 on d.ID=d1.ID and d1.SysMLFlag='zh-CN'
      Where b.ID=@EntityIDand ((a.IsNeedPurConfirm=1 and a.IsConfirmed=1) or a.IsNeedPurConfirm=0) anda.Status=2
    End
    Else If @BarCodeID Is Not Null
    Begin      
      Raiserror('条码类型不是ASN创建的单据条码或者料品条码,无法解析',16,1)
      Return   
    End
    Else
    Begin      
      Raiserror('未在条码主档中找到当前条码,请检查',16,1)
      Return   
    End
   
End

- 列名 'LotMater' 无效。
列名 'LotMater' 无效。
列名 'LotMater' 无效。
- 下列SQL执行出错
- C:\U9Patch\temp\U9V66E.BC.1002211010000018_20221205.055928\PostSql\BC_AnalyzeASNBarCode.sql

- 执行出错的SQL
-         BC_AnalyzeASNBarCode.sql

aksuper 发表于 2022-12-6 14:02:17

学习一下~

北笙 发表于 2022-12-10 14:49:57

不错不错

yanjg000 发表于 2022-12-13 13:00:24

说老实话,没看明白
页: [1]
查看完整版本: 未将对象引用设置到对象的实例 请问如何解决