使用DI-API添加信用卡存款

2020-08-17 05:07发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)嗨。 我正在尝试使用SAP B...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


嗨。

我正在尝试使用SAP B1中的DI-API添加信用卡存款。 添加多行时出现问题。 当我使用我的代码时,发生的事情是当我要添加2行时,它分别创建了2个沉积。 如果我有3行,它将添加3个单独的存款,每个存款1行。

如何修改代码以解决此问题?

#region对SAP使用DIAPI
SAPbobsCOM.CompanyService oService = SboConnection.Company.GetCompanyService();
SAPbobsCOM.DepositsService dpService =(SAPbobsCOM.DepositsService)oService.GetBusinessService(SAPbobsCOM.ServiceTypes.DepositsService); < br> SAPbobsCOM.Deposit dpsAddMpesa =(SAPbobsCOM.Deposit)dpService.GetDataInterface(SAPbobsCOM.DepositsServiceDataInterfaces.dsDeposit);
dpsAddMpesa.DepositType = SAPbobsCOM.BoDepositTypeEps.dtCredit;

COM SAPbobsCOM.CreditLines积分= dpsAddMpesa.Credits;
SAPbobsCOM.CreditLine积分;

dpsAddMpesa.DepositDate = DateTime.Now;
dpsAddMpesa.DepositAccountType = SAPbobsCOM.BoDepositAccountBanksd = depositAcct;
dpsAddMpesa.VoucherAccount = deferredPmtAcct;
dpsAddMpesa.CommissionAccount =" SDR-06";
dpsAddMpesa.Commission =佣金;
dpsAddMpesa.CommissionDate = DateTime.NowM;
dps.Add TaxCode =" X1";
dpsAddMpesa.DepositCurrency =" KES";
dpsAddMpesa.Project =" RETAIL";
dpsAddMpesa.DistributionRule =" GXD";
dpsAddMpesa.DistributionRule2 =" RETAIL";
dpsRemarkss。 ="使用SAP B1 AddOn添加了Mpesa存款";
dpsAddMpesa.ReconcileAfterDeposit = SAPbobsCOM.BoYesNoEnum.tYES;

credit = credits.Add();

//声明记录集< br> SAPbobsCOM.Recordset rs = SboConnection.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

//为(int i = 1;获取AbsId
我<= oMatrix.VisualRowCount; i ++)
{
字符串voucherNo ="";
int absId = 0;
//获取矩阵凭证编号
如果(oMatrix.IsRowSelected(i)== true)
{
voucherNo = oMatrix.Columns.Item(" 1")。Cells.Item(i).Specific.Value;

//获取absId
rs.DoQuery(" SELECT T0。\ "" AbsId \"来自OCRH T0,位于T0。\" VoucherNum \" ='" + voucherNo +"'AND T0。\" VoucherNum \"!='没有参考代码'");
rs.MoveFirst();

整数计数= rs.RecordCount;

如果(count> 0)
{
而(!rs.EoF)
{
absId = rs.Fields.Item(" AbsId")。Value;
rs.MoveNext();
}
}

credit.AbsId = absId;
dpsParamAddMpesa = dpService.AddDeposit(dpsAddMpesa);
}
}
#endregion

3条回答
zhangjiyang1323
2020-08-17 05:54 .采纳回答

这就是我解决的方法。

重新编写循环中的代码并得到

dpsParamAddMpesa = dpService.AddDeposit(dpsAddMpesa);

跳出循环

#region对SAP使用DIAPI
SAPbobsCOM.CompanyService oService = SboConnection.Company.GetCompanyService();
SAPbobsCOM.DepositsService dpService =(SAPbobsCOM.DepositsService)oService.GetBusinessService(SAPbobsCOM.ServiceTypes.DepositsService); < br> SAPbobsCOM.Deposit dpsAddMpesa =(SAPbobsCOM.Deposit)dpService.GetDataInterface(SAPbobsCOM.DepositsServiceDataInterfaces.dsDeposit);
dpsAddMpesa.DepositType = SAPbobsCOM.BoDepositTypeEps.dtCredit;

COM SAPbobsCOM.CreditLines积分= dpsAddMpesa.Credits;
SAPbobsCOM.CreditLine积分;

dpsAddMpesa.DepositDate = DateTime.Now;
dpsAddMpesa.DepositAccountType = SAPbobsCOM.BoDepositAccountBanksd = depositAcct;
dpsAddMpesa.VoucherAccount = deferredPmtAcct;
dpsAddMpesa.CommissionAccount =" SDR-06";
dpsAddMpesa.Commission =佣金;
dpsAddMpesa.CommissionDate = DateTime.NowM;
dps.Add TaxCode =" X1";
dpsAddMpesa.DepositCurrency =" KES";
dpsAddMpesa.Project =" RETAIL";
dpsAddMpesa.DistributionRule =" GXD";
dpsAddMpesa.DistributionRule2 =" RETAIL";
dpsRemarkss。 ="使用SAP B1附加组件添加了Mpesa存款";
dpsAddMpesa.ReconcileAfterDeposit = SAPbobsCOM.BoYesNoEnum.tYES;

//声明记录集
SAPbobsCOM.Recordset rs = SboConnection.Company.GetBusinessObject(SAPbobsCOM .BoObjectTypes.BoRecordset);

//为(int i = 1;获取AbsId
我<= oMatrix.VisualRowCount; i ++)
{
字符串voucherNo ="";
int absId = 0;
//如果(oMatrix.IsRowSelected(i)== true)
获取矩阵凭证编号
{
voucherNo = oMatrix.Columns.Item(" 1")。Cells.Item(i).Specific.Value;

//获取absId
rs.DoQuery(" SELECT T0。\ \" VoucherNum \" ='" + voucherNo +"'AND T0。\" VoucherNum \"!='没有参考代码'");
rs.MoveFirst();

int计数= rs.RecordCount;

如果(count> 0)
{
而(!rs.EoF)
{
absId = rs。 Fields.Item(" AbsId")。Value;
rs.MoveNext();
}
}

credit = dpsAddMpesa.Credits.Add();
credit.AbsId = absId;
}
}
dpsParamAddMpesa = dpService.AddDeposit(dpsAddMpesa);
#endregion

一周热门 更多>