点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
大家好,
添加GRPO时,我需要通过DIAPI自动进行库存转移过帐。 有时它可以成功运行,但有时会抛出
错误
"在未完全选择批次/序列号的情况下无法添加行 " 。
如果通过自动批次创建选项创建批次,则投递成功。 在手动创建批处理的情况下,有时会引发如上所述的错误。
请尽快解决此问题。
#region过帐存货过帐 公共布尔PostInventoryTransfer(字符串DcEntry) { 尝试 { 字符串itemCode = string.Empty; 字符串文档= string.Empty; 字符串docEntry = string.Empty; 字符串qcWhs = string.Empty; 字符串parentWhs = string.Empty; 字符串BplId,series; 双数量= 0; 字符串batchSer = string.Empty; 字符串oErrorMsg = String.Empty; DataTable dt = new DataTable(); DataTable dtBin = new DataTable(); int oErrorCode = 0; 字符串BranchWH = string.Empty; 字符串_sql1; int SERIES = 0; 如果(!Utilities.Application.Company.InTransaction) Utilities.Application.Company.StartTransaction(); //_ sql = @" exec GETITEMCODE'" + DcEntry.Trim()+"'"; //Utilities.ExecuteSQL(ref _recordSet,_sql); //string itmCd = _recordSet.Fields.Item(0).ToString(); SAPbobsCOM.StockTransfer传输=(SAPbobsCOM.StockTransfer)Utilities.Application.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer); 字符串docNum =((SAPbouiCOM.EditText)Form.Items.Item(" 8")。Specific).Value; BplId =((SAPbouiCOM.ComboBox)Form.Items.Item(" 2001")。Specific).Value.ToString()。Trim(); _sql = @"从OADM中选择MltpBrnchs"; Utilities.ExecuteSQL(ref _recordSet,_sql); 字符串IsBranch = _recordSet.Fields.Item(0).Value; 如果(IsBranch.Trim()==" Y") { _sql = @"从[@KBR_QMCONFIG]中选择U_IsBranch"; Utilities.ExecuteSQL(ref _recordSet,_sql); 字符串BranchEnable = _recordSet.Fields.Item(0).Value; 如果(!string.IsNullOrEmpty(BranchEnable.Trim())&& BranchEnable.Trim()==" Y") { _sql1 = @" EXEC ChkBranch1'" + BplId +"'"; Utilities.ExecuteSQL(ref _recordset2,_sql1); BranchWH = _recordset2.Fields.Item(0).Value; Int32.TryParse(_recordset2.Fields.Item(1).Value,列SERIES); } 其他 { _sql = @"从[@ KBR_QMCONFIG1]中选择U_InvTrSer,其中U_Stage ='GRPO'"; Utilities.ExecuteSQL(ref _recordSet,_sql); Int32.TryParse(_recordSet.Fields.Item(0).Value,不在SERIES范围内); } } 如果(_mtMatrix.VisualRowCount> 0) { 对于(int i = 1; i <= _mtMatrix.VisualRowCount; i ++) { Double itmQty = 0; 字符串itmCd =((SAPbouiCOM.EditText)_mtMatrix.Columns.Item(" 1")。Cells.Item(i).Specific).Value.ToString()。Trim(); _sql = @"从OITM中选择U_QCReqd,其中itemcode ='" + itmCd +"'"; Utilities.ExecuteSQL(ref _recordSet,_sql); 字符串_QcReq = Convert.ToString(_recordSet.Fields.Item(0).Value); 如果(_QcReq ==" Y") { 如果(itmCd!="") { itmQty = Convert.ToDouble((((SAPbouiCOM.EditText)_mtMatrix.Columns.Item(" 11")。Cells.Item(i).Specific).Value.ToString()。Trim()); parentWhs =(((SAPbouiCOM.EditText)_mtMatrix.Columns.Item(" 24")。Cells.Item(i).Specific).Value.ToString()。Trim(); 如果(string.IsNullOrEmpty(BranchWH)) { _sql = @" EXEC GETQCWHS'" + itmCd.Trim()+"','GRPO'"; Utilities.ExecuteSQL(ref _recordSet,_sql); 如果(_recordSet.RecordCount> 0) { qcWhs = Convert.ToString(_recordSet.Fields.Item(0).Value); } } 其他 { qcWhs = BranchWH; } transfer.DocDate = DateTime.Now; transfer.FromWarehouse = parentWhs; transfer.ToWarehouse = qcWhs; transfer.Series =系列; transfer.Lines.SetCurrentLine(0); transfer.Lines.ItemCode = itmCd; transfer.Lines.FromWarehouseCode = parentWhs; transfer.Lines.WarehouseCode = qcWhs; transfer.Lines.Quantity = itmQty; transfer.UserFields.Fields.Item(" U_PrntTrfr")。Value = DcEntry; transfer.UserFields.Fields.Item(" U_PrntDcNm")。Value = docNum; _sql = @" exec GetPostInventoryData'" + DcEntry.Trim()+"','" + itmCd.Trim()+"','GRPO'"; dt = Utilities.ExecuteDataSet(_sql).Tables [0]; 如果(dt.Rows.Count> 0) { int ctr = 0; foreach(dt.Rows中的DataRow行) { batchSer = Row [" BatchSer"]。ToString();//Convert.ToString(Form.DataSources.UserDataSources.Item(" BatchSer")。ValueEx).Trim(); itemCode = Row [" ITEMCODE"]。ToString(); document = Row [" DOCUMENT"]。ToString(); docEntry = Row [" DOCENTRY"]。ToString(); //parentWhs = Row [" WHARE HS CODE"]。ToString(); qty = Convert.ToDouble(Row [" QUANTITY"]); 如果(IsBatchManaged(itmCd)) { transfer.Lines.BatchNumbers.ManufacturerSerialNumber = batchSer; transfer.Lines.BatchNumbers.InternalSerialNumber = batchSer; transfer.Lines.BatchNumbers.SetCurrentLine(ctr); transfer.Lines.BatchNumbers.BatchNumber = batchSer; transfer.Lines.BatchNumbers.Quantity =数量; //transfer.Lines.BatchNumbers.ManufacturerSerialNumber = batchSer; //transfer.Lines.BatchNumbers.InternalSerialNumber = batchSer; transfer.Lines.BatchNumbers.Add(); } 其他 { 如果(IsSerialManaged(itmCd)) { transfer.Lines.SerialNumbers.SetCurrentLine(ctr); transfer.Lines.SerialNumbers.ManufacturerSerialNumber = batchSer; transfer.Lines.SerialNumbers.InternalSerialNumber = batchSer; transfer.Lines.SerialNumbers.Quantity =数量; transfer.Lines.SerialNumbers.Add(); } } _sql = @" EXEC GETBIN'" + docEntry +"','" + itemCode +"','" + parentWhs +"','" + batchSer +"','" +文档+"'"; dtBin = Utilities.ExecuteDataSet(_sql).Tables [0]; int ctrBin = 0; 如果(dtBin.Rows.Count> 0) { foreach(dtBin.Rows中的DataRow dr) { transfer.Lines.BinAllocations.SetCurrentLine(ctrBin); transfer.Lines.BinAllocations.BinActionType = SAPbobsCOM.BinActionTypeEnum.batFromWarehouse; transfer.Lines.BinAllocations.BinAbsEntry = Convert.ToInt32(dr [" BinAbs"]); transfer.Lines.BinAllocations.Quantity = Convert.ToDouble(dr [" Quantity"]); transfer.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = ctr; transfer.Lines.BinAllocations.Add(); ctrBin ++; } } ctr ++; ////transfer.lines.binallocations.setcurrentline(0); /////transfer.lines.binallocations.binactiontype = sapbobscom.binactiontypeenum.batfromwarehouse; ////transfer.lines.binallocations.binabsentry = fromlocation; ////transfer.lines.binallocations.quantity =数量; ////transfer.lines.binallocations.add(); ////transfer.lines.binallocations.setcurrentline(1); /////transfer.lines.binallocations.binactiontype = sapbobscom.binactiontypeenum.battowarehouse; ////transfer.lines.binallocations.binabsentry = tolocation; ////transfer.lines.binallocations.quantity =数量; ////transfer.lines.binallocations.add(); } //foreach的结尾 } //数据表的结尾,如果 transfer.Lines.Add(); int returnCode = transfer.Add(); 如果(returnCode!= 0) { //如果进程正在事务中,则事务将回滚。 如果(Utilities.Application.Company.InTransaction) Utilities.Application.Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); Utilities.Application.Company.GetLastError(out oErrorCode,out oErrorMsg); Utilities.ShowErrorMessage(oErrorMsg); //显示错误消息 返回false; //返回假 } } }//结束质量检查 } //矩阵循环结束 } 如果(Utilities.Application.Company.InTransaction) Utilities.Application.Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); //} //其他 //{ //Utilities.ShowErrorMessage("未为文档分支定义QC仓库。"); //返回false; //} } 抓住(前例外) { Utilities.ShowErrorMessage(ex.Message); 返回false; } 返回true; } #endregion
以上问题已解决。
谢谢
请告知您如何解决此问题?
如何在DI API中发布分支? 用于库存转移
一周热门 更多>