// POST api/values public RTNMANVAL Post([FromBody] ARBA value) { RTNMANVAL returnVal = null; SAPbobsCOM.Company oCompany = null; string newKey = ""; try { oCompany = Company.GetCompany(Properties.Settings.Default.StrDbServer, Properties.Settings.Default.StrDbUserName, Properties.Settings.Default.StrDbPassword, Properties.Settings.Default.StrDbName, Properties.Settings.Default.StrSapB1UserName, Properties.Settings.Default.StrSapB1Password, Properties.Settings.Default.StrSapB1LicenseServer); newKey = Logic.SAP.SAP_ARBA.AddData(oCompany, value); returnVal = new RTNMANVAL() { errorCode = "0", message = "Data has beed added", value = newKey }; } catch (Exception e) { returnVal = new RTNMANVAL() { errorCode = "-1", message = e.Message.ToString() }; } return(returnVal); }
public static string AddData(Company oCompany, ARBA model) { BlanketAgreement oObject = null; BlanketAgreementsService oService = null; RTNMANVAL rtn = new RTNMANVAL(); int errCode; string errMessage, strResult = ""; try { oCompany.StartTransaction(); oService = oCompany.GetCompanyService().GetBusinessService(ServiceTypes.BlanketAgreementsService); oObject = oService.GetDataInterface(BlanketAgreementsServiceDataInterfaces.basBlanketAgreement); oObject.BPCode = model.bpCode; oObject.UserFields.Item("U_IDU_SiteID").Value = model.siteID; oObject.UserFields.Item("U_IDU_SiteName").Value = model.siteName; oObject.UserFields.Item("U_IDU_SiteOp").Value = model.siteOp; oObject.Remarks = model.remarks; oObject.StartDate = model.startDate; oObject.EndDate = model.endDate; oObject.AgreementType = BlanketAgreementTypeEnum.atSpecific; BlanketAgreements_ItemsLine lines = oObject.BlanketAgreements_ItemsLines.Add(); lines.ItemNo = "L00001"; lines.PlannedQuantity = model.plannedQuantity; lines.UnitPrice = model.unitPrice; int addStatus = oService.AddBlanketAgreement(oObject).AgreementNo; if (addStatus != 0) { if (strResult == "") { strResult = oCompany.GetNewObjectKey(); } else { strResult = strResult + " | " + oCompany.GetNewObjectKey(); } } else { if (oCompany.InTransaction) { oCompany.EndTransaction(BoWfTransOpt.wf_RollBack); } oCompany.GetLastError(out errCode, out errMessage); throw new Exception("Error Code : " + errCode + " | Error Message : " + errMessage); } oCompany.EndTransaction(BoWfTransOpt.wf_Commit); } catch (Exception) { if (oCompany.InTransaction) { oCompany.EndTransaction(BoWfTransOpt.wf_RollBack); } ; throw; } return(strResult); }