【问题标题】:SAP Business One DI API StockTransfer Object Error -1116SAP Business One DI API StockTransfer 对象错误 -1116
【发布时间】:2022-07-05 00:30:24
【问题描述】:

我正在尝试使用 SBO DI API (v9) 插入库存转移,但每次执行总是失败并返回错误代码

-1116 发生内部错误 (-5002)

如果我们改变

oDoc = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer);

进入

oDoc = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer草稿);

文档已保存但作为库存转移草稿,所以我们需要打开 SAP GUI 打开草稿然后手动添加它作为库存转移文档过帐,这不是我想要的做。我认为我缺少一些必填字段或不支持 DI API 来发布库存转移文档?问题是我不知道如何跟踪它们,错误消息根本没有帮助。 仅供参考,我创建了一些 API,例如 PickList、Inventory Transfer Request,但完全没有问题。

这是我的代码供您参考:

        SAPConnection connection = new SAPConnection();
        SAPbobsCOM.Company company = connection.OpenConnection();

        if (company != null) {
            SAPbobsCOM.IStockTransfer oDoc;
            oDoc = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer);
            
            //HEADER DEFINITION
            oDoc.Series = 347;  //SERIES NUMBER
            oDoc.FromWarehouse = d["h"]["FROM"].ToString();
            oDoc.ToWarehouse = d["h"]["TO"].ToString();
            oDoc.Comments = "Generated Automatically From WMS [" + d["h"]["NUMBER"].ToString() + "]";
            oDoc.JournalMemo = "Inventory Transfer - WMS";
            oDoc.DocDate = DateTime.Today;
            oDoc.DueDate = DateTime.Today;
            oDoc.DocObjectCode = SAPbobsCOM.BoObjectTypes.oStockTransfer;

            //DETAIL DEFINITION
            Int16 lines = (short)d["d"].Count();
            
            for(int i = 0; i<lines; i++) {
                if (i > 0)
                {
                    oDoc.Lines.Add();
                }

                oDoc.Lines.BaseType = SAPbobsCOM.InvBaseDocTypeEnum.InventoryTransferRequest;
                oDoc.Lines.BaseEntry = Convert.ToInt32(d["h"]["ID"].ToString());   //ID ITR
                oDoc.Lines.BaseLine = i;
                
                oDoc.Lines.ItemCode = d["d"][i]["item_no"].ToString();
                oDoc.Lines.ItemDescription = d["d"][i]["item_description"].ToString();
                oDoc.Lines.WarehouseCode = d["h"]["TO"].ToString();
                oDoc.Lines.FromWarehouseCode = d["h"]["FROM"].ToString();
                oDoc.Lines.Quantity = Convert.ToDouble(d["d"][i]["qty"].ToString());

                oDoc.Lines.BatchNumbers.BatchNumber = d["d"][i]["batch"].ToString();
                oDoc.Lines.BatchNumbers.Quantity = Convert.ToDouble(d["d"][i]["qty"].ToString());
            }

            int status = oDoc.Add();

            if (status == 0)
            {
                callResponse.Code = "OK";
                callResponse.Description = "Success #" + company.GetNewObjectKey();
            }
            else
            {
                callResponse.Code = "ERROR";
                callResponse.Description = company.GetLastErrorCode().ToString() + " " + company.GetLastErrorDescription().ToString();
            };


            return Ok(callResponse);
        }

        callResponse.Code = "ERROR";
        callResponse.Description = "Failed to connect server ! ";
        return Ok(callResponse);

【问题讨论】:

    标签: api sap-business-one-di-api


    【解决方案1】:

    试试

     oDocumento = null;
    

    oDocumento = Documents)SAPB1.myCompany.GetBusinessObject(BoObjectTypes.oDrafts); oDocumento.DocObjectCode = BoObjectTypes.oStockTransfer;

    【讨论】:

      猜你喜欢
      • 2023-02-01
      • 2012-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多