具体情况如图所示。
附件是解决办法的SQL语句。
/**
使用方法:
一、在BOS中,增加自定义流程并配置好非自定义核算项目的对应关系.保存并启用.
二、使用下面的语句,一个字段一个字段的增加自定义核算项目的对应关系即可. 只需要修改对应的单据上的字段显示名,其他的不用改动.
1.设置 是否表头
2.设置 源单名称、目标单名称 从 ICTransactionType 中可以查询到
3.设置 源单字段显示名、目标单字段显示名
4.执行语句
**/
declare @FDestField varchar(255),@FSrcField varchar(255),@MaxInteriD int,@FItemClassID int,@TableNameAS varchar(255)
declare @SrcTable varchar(255),@SrcFID varchar(255),@FSrcTranTypeID int
declare @DstTable varchar(255),@DstFID varchar(255),@FTranTypeID int,@FLinkField varchar(255)
declare @isEntry as int,@SrcTabelNameAs varchar(255)
set @isEntry=0 --是否表头字段 @isEntry=0 表头 @isEntry=1 表体
select @SrcTable=FHeadTable,@SrcFID=FTemplateID,@FSrcTranTypeID=FID from ICTransactionType where FName='销售出库' --源单名称
select @DstTable=FHeadTable,@DstFID=FTemplateID,@FTranTypeID=FID from ICTransactionType where FName='购货发票(专用)' --目标单名称
select @FLinkField=FFieldName from ICClassLink WHERE FSourClassTypeID = -@FSrcTranTypeID AND FDestClassTypeID = -@FTranTypeID AND FSourTypeID = 0 AND FDestTypeID = 0
select @SrcTabelNameAs=case when @isEntry=0 then 'V1' else 'u1' end
select @FDestField=FFieldName from ICTemplate where FID=@DstFID and FCaption ='施工单位' --采购发票(专用) 字段显示名
select @FSrcField=FFieldName ,@FItemClassID=FLookUpCls,@TableNameAS='t_'+CAST(FLookUpCls as varchar(255)) from ICTemplate where FID=@SrcFID and FCaption ='施工单位' --销售出库单 字段显示名
SELECT @MaxInteriD=MAX(FInterID) FROM ICTableRelation WHERE FBillID=@DstFID AND FFieldID=@FLinkField
INSERT INTO ICSelBills ( FID, FFieldName, FDstCtlField, FSelType, FDK, FColName, FName, FTableName, FTableAlias, FAction )
Values(@DstFID,@FLinkField,@FDestField,2,0,@FDestField,@FSrcField,@SrcTable,@SrcTabelNameAs,'')
INSERT INTO ICSelBills ( FID, FFieldName, FDstCtlField, FSelType, FDK, FColName, FName, FTableName, FTableAlias, FAction )
Values (@DstFID,@FLinkField,@FDestField,2,1,@FDestField+'Name','FName','t_item',@TableNameAS,'')
INSERT INTO ICSelBills ( FID, FFieldName, FDstCtlField, FSelType, FDK, FColName, FName, FTableName, FTableAlias, FAction )
Values (@DstFID,@FLinkField,@FDestField,2,2,@FDestField+'Number','FNumber','t_item',@TableNameAS,'')
Insert Into ICTableRelation ( FInterID, FTableName, FTableNameAlias, FFieldName, FTableName11, FTableNameAlias11, FFieldName11, FLogic, FBillID, FFieldID )
Values(@MaxInteriD,@SrcTable,@SrcTabelNameAs,@FSrcField,'t_item',@TableNameAS,'FItemID','*=',@DstFID,@FLinkField)
go
推荐阅读