/// <summary> /// 返回表或结构的定义细节。 /// </summary> /// <param name="p_sysName">SAP系统</param> /// <param name="p_TableName">表或结构</param> /// <returns>结构定义</returns> private static DataTable _GetSAPTableDef(String p_sysName, String p_TableName) { //有时读取的参数是表类型,无法使用函数DDIF_FIELDINFO_GET直接读取到表的定义。 //首先到表DD40L里查出表类型对应的结构类型。 var criteria = String.Format("TYPENAME = '{0}'", p_TableName); var readTableFunction = ConfigFileTool.SAPGlobalSettings.GetReadTableFunction(); var dd40l = new SAPINT.Utils.ReadTable(p_sysName); dd40l.TableName = "DD40L"; dd40l.RowCount = 1; dd40l.SetCustomFunctionName(readTableFunction); dd40l.AddCriteria(criteria); dd40l.Run(); var dd40lt = dd40l.Result; var structureName = string.Empty; if (dd40lt.Rows.Count == 1) { structureName = dd40lt.Rows[0]["ROWTYPE"].ToString(); } if (!string.IsNullOrEmpty(structureName)) { p_TableName = structureName; } try { RfcDestination destination = SAPDestination.GetDesByName(p_sysName); IRfcFunction RFC_FUNCTION_SEARCH = destination.Repository.CreateFunction("DDIF_FIELDINFO_GET"); RFC_FUNCTION_SEARCH.SetValue("TABNAME", p_TableName); RFC_FUNCTION_SEARCH.Invoke(destination); IRfcTable DFIES_TAB = RFC_FUNCTION_SEARCH.GetTable("DFIES_TAB"); DataTable dt = _Convert_rfctable_to_dt(DFIES_TAB); return(dt); } catch (RfcAbapException abapException) { throw new SAPException(p_TableName + abapException.Key + abapException.Message); } catch (RfcAbapBaseException abapbaseException) { throw new SAPException(abapbaseException.PlainText + abapbaseException.Message); } catch (Exception ex) { throw new SAPException(ex.Message); } }
internal void FillMessageText(string sysName) { ReadTable table = new ReadTable(sysName); RfcDestination des = SAPDestination.GetDesByName(sysName); table.AddField("TEXT"); table.AddCriteria("SPRSL = '" + Converts.languageIsotoSap(des.Language) + "' "); table.AddCriteria("AND ARBGB = '" + this.MessageID + "' "); table.AddCriteria("AND MSGNR = '" + this.MessageNumber + "' "); table.TableName = "T100"; table.RowCount = 10; table.Run(); DataTable result = table.Result; if (result.Rows.Count == 0) { //this.Message = "Message could not be found";// Messages.Messagecouldnotbefound; this.Message = Messages.Messagecouldnotbefound; } else { this.Message = result.Rows[0]["TEXT"].ToString().Trim(); int length = 0; length = this.Message.IndexOf("&"); if (length >= 0) { this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable1 + " " + this.Message.Substring(length + 1).Trim(); } length = this.Message.IndexOf("&"); if (length >= 0) { this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable2 + " " + this.Message.Substring(length + 1).Trim(); } length = this.Message.IndexOf("&"); if (length >= 0) { this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable3 + " " + this.Message.Substring(length + 1).Trim(); } length = this.Message.IndexOf("&"); if (length >= 0) { this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable4 + " " + this.Message.Substring(length + 1).Trim(); } this.Message = this.Message.Trim(); } }
/// <summary> /// 返回表或结构的定义细节。 /// </summary> /// <param name="p_sysName">SAP系统</param> /// <param name="p_TableName">表或结构</param> /// <returns>结构定义</returns> private static DataTable _GetSAPTableDef(String p_sysName, String p_TableName) { //有时读取的参数是表类型,无法使用函数DDIF_FIELDINFO_GET直接读取到表的定义。 //首先到表DD40L里查出表类型对应的结构类型。 var criteria = String.Format("TYPENAME = '{0}'", p_TableName); var readTableFunction = ConfigFileTool.SAPGlobalSettings.GetReadTableFunction(); var dd40l = new SAPINT.Utils.ReadTable(p_sysName); dd40l.TableName = "DD40L"; dd40l.RowCount = 1; dd40l.SetCustomFunctionName(readTableFunction); dd40l.AddCriteria(criteria); dd40l.Run(); var dd40lt = dd40l.Result; var structureName = string.Empty; if (dd40lt.Rows.Count == 1) { structureName = dd40lt.Rows[0]["ROWTYPE"].ToString(); } if (!string.IsNullOrEmpty(structureName)) { p_TableName = structureName; } try { RfcDestination destination = SAPDestination.GetDesByName(p_sysName); IRfcFunction RFC_FUNCTION_SEARCH = destination.Repository.CreateFunction("DDIF_FIELDINFO_GET"); RFC_FUNCTION_SEARCH.SetValue("TABNAME", p_TableName); RFC_FUNCTION_SEARCH.Invoke(destination); IRfcTable DFIES_TAB = RFC_FUNCTION_SEARCH.GetTable("DFIES_TAB"); DataTable dt = _Convert_rfctable_to_dt(DFIES_TAB); return dt; } catch (RfcAbapException abapException) { throw new SAPException(p_TableName + abapException.Key + abapException.Message); } catch (RfcAbapBaseException abapbaseException) { throw new SAPException(abapbaseException.PlainText + abapbaseException.Message); } catch (Exception ex) { throw new SAPException(ex.Message); } }
//加载表数据 void loadTableData() { try { dt = new ReadTable(_systemName.ToUpper().Trim()); dt.SetCustomFunctionName("ZVI_RFC_READ_TABLE"); dt.TableName = _tableName; // dt.Fields.Clear(); // dt.Options.Clear(); //从界面上加载条件与字段列表 for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells["FieldName"].Value != null) { if (dataGridView1.Rows[i].Cells["Select"] != null & (bool)dataGridView1.Rows[i].Cells["Select"].Value == true) { string s = dataGridView1.Rows[i].Cells["FieldName"].Value.ToString(); if (!string.IsNullOrEmpty(s)) { dt.AddField(s); } } } } for (int i = 0; i < dataGridView2.Rows.Count; i++) { if (dataGridView2[0, i].Value != null) { string s = dataGridView2[0, i].Value.ToString(); if (!string.IsNullOrEmpty(s)) { dt.AddCriteria(s); } } } dt.RowCount = Convert.ToInt32(rowNum.Text); dt.Run(); } catch (Exception ee) { MessageBox.Show(ee.Message); } }
internal void FillMessageText(string sysName) { ReadTable table = new ReadTable(sysName); RfcDestination des = SAPDestination.GetDesByName(sysName); table.AddField("TEXT"); table.AddCriteria("SPRSL = '" + Converts.languageIsotoSap(des.Language)+ "' "); table.AddCriteria("AND ARBGB = '" + this.MessageID + "' "); table.AddCriteria("AND MSGNR = '" + this.MessageNumber + "' "); table.TableName = "T100"; table.RowCount = 10; table.Run(); DataTable result = table.Result; if (result.Rows.Count == 0) { //this.Message = "Message could not be found";// Messages.Messagecouldnotbefound; this.Message = Messages.Messagecouldnotbefound; } else { this.Message = result.Rows[0]["TEXT"].ToString().Trim(); int length = 0; length = this.Message.IndexOf("&"); if (length >= 0) { this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable1 + " " + this.Message.Substring(length + 1).Trim(); } length = this.Message.IndexOf("&"); if (length >= 0) { this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable2 + " " + this.Message.Substring(length + 1).Trim(); } length = this.Message.IndexOf("&"); if (length >= 0) { this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable3 + " " + this.Message.Substring(length + 1).Trim(); } length = this.Message.IndexOf("&"); if (length >= 0) { this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable4 + " " + this.Message.Substring(length + 1).Trim(); } this.Message = this.Message.Trim(); } }