很多做用友U8二开的同学在问,有没有凭证接口,其实凭证有很多接口,今天我们就来一一罗列下:
-
有界面凭证接口(类似业务模块制单功能),后续会介绍如何使用
-
EAI接口
-
无界面凭证接口,即原生CO接口
今天我们来重点介绍下无界面凭证接口。
此组件是提供U8会计凭证录入的无界面交互组件,完全后台生成会计凭证。
同时本组件支持现金流量的录入。
组件文件cvoucher.dll,部署于安装目录u8soft\UFCOMSQL。
直接上代码
创建组件:
Dim obj As ObjectSet obj = CreateObject("CVoucher.CVInterface")Dim strSql As StringDim conn As New ADODB.Connectionconn.Open m_login.UfDbName
创建临时表
‘临时表obj.strTempTable = "tempdb..cus_gl_accvouch" ‘临时表结构同凭证接口,需要自行创建
strSql = "CREATE TABLE " & obj.strTempTable & " " _ & "(csign nvarchar(28),ino_id smallint, " _ & "inid smallint, cbill nvarchar(80), doutbilldate DATETIME, ccashier nvarchar(80), " _ & "idoc smallint default 0, ctext1 nvarchar(50), ctext2 nvarchar(50), cexch_name nvarchar(28), " _ & "cdigest nvarchar(120), ccode nvarchar(40), md money default 0, mc money default 0, " _ & "md_f money default 0, mc_f money default 0, nfrat float default 0, nd_s float default 0, nc_s float default 0, csettle nvarchar(23), " _ & "cn_id nvarchar(30), dt_date DATETIME, cdept_id nvarchar(12), cperson_id nvarchar(80), ccus_id nvarchar(80), csup_id nvarchar (20), " _ & "citem_id nvarchar(80), citem_class nvarchar(22), cname nvarchar(40), ccode_equal nvarchar(50), " _ & "bvouchedit bit default 0, bvouchaddordele bit default 0, bvouchmoneyhold bit default 0, bvalueedit bit default 0, bcodeedit bit default 0, ccodecontrol nvarchar(50), bPCSedit bit default 0, bDeptedit bit default 0, bItemedit bit default 0, bCusSupInput bit default 0, " _ & "coutaccset nvarchar(23), ioutyear smallint, coutsysname nvarchar(50) NOT NULL, coutsysver nvarchar(50), ioutperiod tinyint NOT NULL, coutsign nvarchar(80) NOT NULL, coutno_id nvarchar(100) NOT NULL, doutdate DATETIME, coutbillsign nvarchar(80), coutid nvarchar(50), iflag tinyint" _ & ",iBG_ControlResult smallint null,daudit_date DateTime NULL,cblueoutno_id nvarchar(50) NULL,bWH_BgFlag bit,cDefine1 nvarchar(40),"strSql = strSql & "cDefine2 nvarchar(40),cDefine3 nvarchar(40),cDefine4 DateTime,cDefine5 int,cDefine6 DateTime,cDefine7 Float,cDefine8 nvarchar(4),cDefine9 nvarchar(8),"strSql = strSql & "cDefine10 nvarchar(60),cDefine11 nvarchar(120),cDefine12 nvarchar(120),cDefine13 nvarchar(120),cDefine14 nvarchar(120),cDefine15 int,cDefine16 float)"
调用创建临时表:
conn.Execute strSql
组织凭证分录数据
'分录1:科目1001借方200strSql = "insert into " & obj.strTempTable & "(ioutperiod,coutsign ,cSign,coutno_id,cdigest,coutsysname,cbill,inid,ccode,cexch_name,dt_date,doutbilldate,bvouchedit,bvalueedit,bcodeedit,md,cdefine14,cdept_id) values(6,N'Z',N'Z', N'123456',N'1',N'PM',N'" & m_login.cUserName & "',1,N'1111',N'人民币','2014-6-30','2014-6-30',1,1,1,200,N'zr111',N'1')"conn.Execute strSql
'分录2:科目1002贷方200strSql = "insert into " & obj.strTempTable & "(ioutperiod,coutsign ,cSign,coutno_id,cdigest,coutsysname,cbill,inid,ccode,cexch_name,dt_date,doutbilldate,bvouchedit,bvalueedit,bcodeedit,mc,cdefine14,cdept_id) values(6,N'Z',N'Z', N'123456',N'2',N'PM',N'" & m_login.cUserName & "',1,N'1111',N'人民币','2014-6-30','2014-6-30',1,1,1,200,N'zr222',N'1')"conn.Execute strSql
调用保存
Set obj.Connection = conn 'ado.connection‘注:有的版本没有LoginByUserToken方法,使用login3方法代替obj.LoginByUserToken (m_login.userToken)If Not obj.SaveVoucher Then MsgBox obj.strErrMessageElse MsgBox "ok"End If
关于.NET版本写法及现金流量格式,关注公众号《用友U8二次开发分享》或者加入开发者社区了解后续更新。
标签:界面,U8,default,nvarchar,obj,CO,bit,id,strSql From: https://www.cnblogs.com/u8dev/p/u8-glvouch-co.html