private void btnGetWWPOComponent_Click(object sender, EventArgs e) { try { WWPO2SAP wwpo2SAP = new WWPO2SAP(); List <WWPOComponentPara> paraList = new List <WWPOComponentPara>(); if (!string.IsNullOrEmpty(txtWWPONO1.Text)) { WWPOComponentPara para = new WWPOComponentPara(); para.PONO = txtWWPONO1.Text; if (!string.IsNullOrEmpty(txtWWPOLine1.Text)) { para.POLine = Convert.ToInt32(txtWWPOLine1.Text); } paraList.Add(para); } if (!string.IsNullOrEmpty(txtWWPONO2.Text)) { WWPOComponentPara para = new WWPOComponentPara(); para.PONO = txtWWPONO2.Text; if (!string.IsNullOrEmpty(txtWWPOLine2.Text)) { para.POLine = Convert.ToInt32(txtWWPOLine2.Text); } paraList.Add(para); } WWPOComponentResult rs = wwpo2SAP.GetWWPOList(paraList); dgvWWPOList.DataSource = rs.WWPOComponentList; ShowMessage("====================" + btnGetWWPOComponent.Text + " " + DateTime.Now + "===================="); ShowMessage("执行结果标识(S表示成功,E表示失败):" + rs.RfcResult.Result); //ShowMessage("SAP物料凭证编码:" + rs.RfcResult.MaterialDocument); ShowMessage("执行结果信息:" + rs.RfcResult.Message + "\r\n"); } catch (Exception ex) { ShowMessage("Exception:" + ex.Message); } }
public WWPOComponentResult GetWWPOList(List <WWPOComponentPara> list) { try { NcoFunction ncoClient = new NcoFunction(); string[] rfcArray = ConfigHelper.LoadRFCConfig(ConfigHelper.strDestinationName); ncoClient.Connect(rfcArray[0], "", rfcArray[3], rfcArray[4], "ZH", rfcArray[5], rfcArray[8], 2, 10, "", rfcArray[9]); ncoClient.FunctionName = MES2SAPRfcFunctionName.WWPOComponent; Dictionary <string, object> importParameters = new Dictionary <string, object>(); DataTable dt = new DataTable(); dt.Columns.Add("EBELN", typeof(string)); dt.Columns.Add("EBELP", typeof(int)); foreach (var item in list) { DataRow row = dt.NewRow(); row["EBELN"] = item.PONO; //row["EBELP"] = item.POLine; dt.Rows.Add(row); } IRfcTable rfcTable = ncoClient.ConvertDataTabletoRFCTable(dt, MES2SAPRfcInTableName.WWPOComponent); importParameters.Add(MES2SAPRfcInTableName.WWPOComponent, rfcTable); ncoClient.ImportParameters = importParameters; Dictionary <string, object> exportParameters = new Dictionary <string, object>(); DataSet ds = ncoClient.Execute(ref exportParameters); WWPOComponentResult result = new WWPOComponentResult(); List <WWPOComponent> componentList = new List <WWPOComponent>(); if (ds != null && ds.Tables[MES2SAPRfcOutTableName.WWPOComponent] != null && ds.Tables[MES2SAPRfcOutTableName.WWPOComponent].Rows.Count > 0) { foreach (DataRow row in ds.Tables[MES2SAPRfcOutTableName.WWPOComponent].Rows) { WWPOComponent co = new WWPOComponent(); co.PONO = Convert.ToString(row["EBELN"]); co.POLine = Convert.ToInt32(row["EBELP"]); co.SubLine = Convert.ToInt32(row["RSPOS"]); co.MCode = Convert.ToString(row["MATNR"]); co.HWMCode = Convert.ToString(row["IDNLF"]); co.Qty = Convert.ToDecimal(row["BDMNG"]); co.Unit = Convert.ToString(row["MEINS"]); componentList.Add(co); } } result.WWPOComponentList = componentList; object parameter = null; SAPRfcReturn re = new SAPRfcReturn(); if (exportParameters != null) { if (exportParameters.TryGetValue("ES_RESULT", out parameter)) { IRfcStructure ROFStrcture = parameter as IRfcStructure; re.Result = ROFStrcture["RETUN"].GetValue().ToString(); re.MaterialDocument = null; re.Message = ROFStrcture["MESSG"].GetValue().ToString(); } } result.RfcResult = re; return(result); } catch (Exception ex) { throw ex; } }