public void KomisyonBedeliniGetir(string musteriNumarasi, DateTime? baslangicTarihi, DateTime? bitisTarihi , out DataTable dtITAB, out DataTable dtZRETURN) { SAPDestinationConfiguration sapDestinationConfiguration = new SAPDestinationConfiguration(); IRfcFunction rfcFunction = null; try { // ishak.kulekci 24.06.2013 // Destination configuration already initialized hatasını engelleme, bunun için önce TryGetDestination kullanılır RfcDestination rfcDestination = RfcDestinationManager.TryGetDestination("SAPSYSTEM"); if (rfcDestination == null) { try { RfcDestinationManager.RegisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } rfcDestination = RfcDestinationManager.GetDestination("SAPSYSTEM"); } //RfcDestination rfcDestination = RfcDestinationManager.GetDestination("SAPSYSTEM"); rfcFunction = rfcDestination.Repository.CreateFunction("Z_RFC_YK_BEKPRIM_TO_INTERNET"); //rfcFunction.SetValue("KUNNR", "100092"); // aygaz rfcFunction.SetValue("KUNNR", musteriNumarasi); //rfcFunction.SetValue("DATAB", "20130601"); rfcFunction.SetValue("DATAB", baslangicTarihi.Value.ToString("yyyyMMdd", CultureInfo.GetCultureInfo("tr-tr"))); //rfcFunction.SetValue("DATBI", "20130605"); rfcFunction.SetValue("DATBI", bitisTarihi.Value.ToString("yyyyMMdd", CultureInfo.GetCultureInfo("tr-tr"))); rfcFunction.Invoke(rfcDestination); } catch (Exception exception) { throw exception; } finally { try { RfcDestinationManager.UnregisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } } dtITAB = RFCHelper.RfcTableToDataTable(rfcFunction.GetTable("ITAB"), "ITAB"); dtZRETURN = RFCHelper.RfcTableToDataTable(rfcFunction.GetTable("ZRETURN"), "ZRETURN"); }
public void KomisyonBedeliniGetir(string musteriNumarasi, DateTime?baslangicTarihi, DateTime?bitisTarihi , out DataTable dtITAB, out DataTable dtZRETURN) { SAPDestinationConfiguration sapDestinationConfiguration = new SAPDestinationConfiguration(); IRfcFunction rfcFunction = null; try { // ishak.kulekci 24.06.2013 // Destination configuration already initialized hatasını engelleme, bunun için önce TryGetDestination kullanılır RfcDestination rfcDestination = RfcDestinationManager.TryGetDestination("SAPSYSTEM"); if (rfcDestination == null) { try { RfcDestinationManager.RegisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } rfcDestination = RfcDestinationManager.GetDestination("SAPSYSTEM"); } //RfcDestination rfcDestination = RfcDestinationManager.GetDestination("SAPSYSTEM"); rfcFunction = rfcDestination.Repository.CreateFunction("Z_RFC_YK_BEKPRIM_TO_INTERNET"); //rfcFunction.SetValue("KUNNR", "100092"); // aygaz rfcFunction.SetValue("KUNNR", musteriNumarasi); //rfcFunction.SetValue("DATAB", "20130601"); rfcFunction.SetValue("DATAB", baslangicTarihi.Value.ToString("yyyyMMdd", CultureInfo.GetCultureInfo("tr-tr"))); //rfcFunction.SetValue("DATBI", "20130605"); rfcFunction.SetValue("DATBI", bitisTarihi.Value.ToString("yyyyMMdd", CultureInfo.GetCultureInfo("tr-tr"))); rfcFunction.Invoke(rfcDestination); } catch (Exception exception) { throw exception; } finally { try { RfcDestinationManager.UnregisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } } dtITAB = RFCHelper.RfcTableToDataTable(rfcFunction.GetTable("ITAB"), "ITAB"); dtZRETURN = RFCHelper.RfcTableToDataTable(rfcFunction.GetTable("ZRETURN"), "ZRETURN"); }
public bool TestConnection() { bool result = false; SAPDestinationConfiguration sapDestinationConfiguration = new SAPDestinationConfiguration(); try { // ishak.kulekci 24.06.2013 // Destination configuration already initialized hatasını engelleme, bunun için önce TryGetDestination kullanılır RfcDestination rfcDestination = RfcDestinationManager.TryGetDestination("SAPSYSTEM"); if (rfcDestination == null) { try { RfcDestinationManager.RegisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } rfcDestination = RfcDestinationManager.GetDestination("SAPSYSTEM"); } if (rfcDestination != null) { rfcDestination.Ping(); result = true; } } catch (Exception exception) { //throw exception; result = false; //throw new Exception("Connection failure error. Message:"+exception.Message); } finally { try { RfcDestinationManager.UnregisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } } return(result); }
public bool TestConnection() { bool result = false; SAPDestinationConfiguration sapDestinationConfiguration = new SAPDestinationConfiguration(); try { // ishak.kulekci 24.06.2013 // Destination configuration already initialized hatasını engelleme, bunun için önce TryGetDestination kullanılır RfcDestination rfcDestination = RfcDestinationManager.TryGetDestination("SAPSYSTEM"); if (rfcDestination == null) { try { RfcDestinationManager.RegisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } rfcDestination = RfcDestinationManager.GetDestination("SAPSYSTEM"); } if (rfcDestination != null) { rfcDestination.Ping(); result = true; } } catch (Exception exception) { //throw exception; result = false; //throw new Exception("Connection failure error. Message:"+exception.Message); } finally { try { RfcDestinationManager.UnregisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } } return result; }
private void btnRFCExecute_Click(object sender, EventArgs e) { try { string rfcName = txtRFCName.Text; SAPDestinationConfiguration sapDestinationConfiguration = new SAPDestinationConfiguration(); IRfcFunction rfcFunction = null; try { // ishak.kulekci 24.06.2013 // Destination configuration already initialized hatasını engelleme, bunun için önce TryGetDestination kullanılır RfcDestination rfcDestination = RfcDestinationManager.TryGetDestination("SAPSYSTEM"); if (rfcDestination == null) { try { RfcDestinationManager.RegisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } rfcDestination = RfcDestinationManager.GetDestination("SAPSYSTEM"); } //RfcDestination rfcDestination = RfcDestinationManager.GetDestination("SAPSYSTEM"); //rfcFunction = rfcDestination.Repository.CreateFunction("Z_RFC_YK_BEKPRIM_TO_INTERNET"); ////rfcFunction.SetValue("KUNNR", "100092"); // aygaz //rfcFunction.SetValue("KUNNR", musteriNumarasi); ////rfcFunction.SetValue("DATAB", "20130601"); //rfcFunction.SetValue("DATAB", baslangicTarihi.Value.ToString("yyyyMMdd", CultureInfo.GetCultureInfo("tr-tr"))); ////rfcFunction.SetValue("DATBI", "20130605"); //rfcFunction.SetValue("DATBI", bitisTarihi.Value.ToString("yyyyMMdd", CultureInfo.GetCultureInfo("tr-tr"))); //rfcFunction.Invoke(rfcDestination); rfcFunction = rfcDestination.Repository.CreateFunction(rfcName); //rfcFunction.Metadata // ishak.kulekci 26.11.2015 09.00 import parametreleri set edilir, rfc invoke edilir // rfc sonucunda gelen export ve table parametreleri elde edilir ve gösterilir foreach (DataGridViewRow row in gvImportParams.Rows) { string prmName = row.Cells["cName"].Value == null ? "" : row.Cells["cName"].Value.ToString(); // cName -> Name verisi string prmNewValue = row.Cells["cNewValue"].Value == null ? "" : row.Cells["cNewValue"].Value.ToString(); // cNewValue -> NewValue verisi rfcFunction.SetValue(prmName, prmNewValue); } // rfc invoke edilir rfcFunction.Invoke(rfcDestination); //RfcParameterMetadata describing an importing/exporting/tables parameter of a function module List<RfcParameterMetadata_ForUI> listRfcParameterMetadataWhichDirectionExport = new List<RfcParameterMetadata_ForUI>(); List<RFCTableWhichHasDataTableAndFieldInfo> listRFCTable = new List<RFCTableWhichHasDataTableAndFieldInfo>(); int parameterCount = rfcFunction.Metadata.ParameterCount; for (int i = 0; i < parameterCount; i++) { RfcParameterMetadata rfcParameterMetadata = rfcFunction.Metadata[i]; //rfcParameterMetadata.DefaultValue //rfcParameterMetadata.Direction //RfcDirection.CHANGING //RfcDirection.EXPORT //RfcDirection.IMPORT //RfcDirection.TABLES //rfcParameterMetadata.Optional //rfcParameterMetadata.Name if (rfcParameterMetadata.Direction == RfcDirection.EXPORT) { listRfcParameterMetadataWhichDirectionExport.Add(Convert_To_RfcParameterMetadata_ForUI(rfcParameterMetadata)); } else if (rfcParameterMetadata.Direction == RfcDirection.TABLES) { RfcTableMetadata rfcTableMetadata = rfcParameterMetadata.ValueMetadataAsTableMetadata; int fieldCount = rfcTableMetadata.LineType.FieldCount; // field adeti kadar Datatable nesnesi oluşturup kolon eklemesi yapılacak DataTable dt = new DataTable(rfcTableMetadata.Name); List<RfcFieldMetadata_ForUI> listRfcFieldMetadata = new List<RfcFieldMetadata_ForUI>(); for (int j = 0; j < fieldCount; j++) { RfcFieldMetadata rfcFieldMetadata = rfcTableMetadata[j]; DataColumn dc = new DataColumn(rfcFieldMetadata.Name); dt.Columns.Add(dc); listRfcFieldMetadata.Add(Convert_To_RfcFieldMetadata_ForUI(rfcFieldMetadata)); } RFCTableWhichHasDataTableAndFieldInfo rfcTable = new RFCTableWhichHasDataTableAndFieldInfo(); rfcTable.TableParameterMetadata = Convert_To_RfcParameterMetadata_ForUI(rfcParameterMetadata); rfcTable.DataTableForItems = RFCHelper.RfcTableToDataTable(rfcFunction.GetTable(rfcParameterMetadata.Name), rfcParameterMetadata.Name); //dt; rfcTable.ListForFieldMetadata = listRfcFieldMetadata; listRFCTable.Add(rfcTable); } } gvExportParams.AutoGenerateColumns = false; gvExportParams.DataSource = listRfcParameterMetadataWhichDirectionExport; // tablolar elde edilip, tabcontrol içine tabpage olarak eklenir // her tabpage içinde datagridview eklenir, kolon değerlerini alma sağlanır foreach (RFCTableWhichHasDataTableAndFieldInfo itemTable in listRFCTable) { TabPage page = new TabPage(); page.Text = itemTable.TableParameterMetadata.Name; page.Name = "tp" + itemTable.TableParameterMetadata.Name; page.Width = 550; page.Height = 300; DataGridView gv = new DataGridView(); gv.Name = "gv" + itemTable.TableParameterMetadata.Name; // grid kaynağı bağlanmalı gv.DataSource = itemTable.DataTableForItems; gv.Anchor = AnchorStyles.Left | AnchorStyles.Right; gv.Location = new Point(5, 35); gv.Margin = new Padding(3); gv.Width = 540; gv.Height = 200; gv.AllowUserToAddRows = false; gv.AllowUserToDeleteRows = false; gv.ReadOnly = true; //gv.Visible = false; Label lblRowCount = new Label(); lblRowCount.Name = "lblRowCount" + itemTable.TableParameterMetadata.Name; lblRowCount.Text = "Veri Adeti: " + itemTable.DataTableForItems.Rows.Count.ToString(); lblRowCount.Location = new Point(gv.Location.X, gv.Location.Y + gv.Height - 20); page.Controls.Add(gv); page.Controls.Add(lblRowCount); tcTablesToExport.TabPages.Add(page); } } catch (Exception exception) { throw exception; } finally { try { RfcDestinationManager.UnregisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnRFCTest_Click(object sender, EventArgs e) { try { FileHelper.SaveRFCName(txtRFCName.Text); string rfcName = txtRFCName.Text; SAPDestinationConfiguration sapDestinationConfiguration = new SAPDestinationConfiguration(); IRfcFunction rfcFunction = null; try { // ishak.kulekci 24.06.2013 // Destination configuration already initialized hatasını engelleme, bunun için önce TryGetDestination kullanılır RfcDestination rfcDestination = RfcDestinationManager.TryGetDestination("SAPSYSTEM"); if (rfcDestination == null) { try { RfcDestinationManager.RegisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } rfcDestination = RfcDestinationManager.GetDestination("SAPSYSTEM"); } //RfcDestination rfcDestination = RfcDestinationManager.GetDestination("SAPSYSTEM"); //rfcFunction = rfcDestination.Repository.CreateFunction("Z_RFC_YK_BEKPRIM_TO_INTERNET"); ////rfcFunction.SetValue("KUNNR", "100092"); // aygaz //rfcFunction.SetValue("KUNNR", musteriNumarasi); ////rfcFunction.SetValue("DATAB", "20130601"); //rfcFunction.SetValue("DATAB", baslangicTarihi.Value.ToString("yyyyMMdd", CultureInfo.GetCultureInfo("tr-tr"))); ////rfcFunction.SetValue("DATBI", "20130605"); //rfcFunction.SetValue("DATBI", bitisTarihi.Value.ToString("yyyyMMdd", CultureInfo.GetCultureInfo("tr-tr"))); //rfcFunction.Invoke(rfcDestination); rfcFunction = rfcDestination.Repository.CreateFunction(rfcName); //rfcFunction.Metadata //RfcParameterMetadata describing an importing/exporting/tables parameter of a function module List <RfcParameterMetadata_ForUI> listRfcParameterMetadataWhichDirectionImport = new List <RfcParameterMetadata_ForUI>(); //List<RfcParameterMetadata_ForUI> listRfcParameterMetadataWhichDirectionTables = new List<RfcParameterMetadata_ForUI>(); //List<DataTable> listDataTableToImport = new List<DataTable>(); List <RFCTableWhichHasDataTableAndFieldInfo> listRFCTable = new List <RFCTableWhichHasDataTableAndFieldInfo>(); int parameterCount = rfcFunction.Metadata.ParameterCount; for (int i = 0; i < parameterCount; i++) { RfcParameterMetadata rfcParameterMetadata = rfcFunction.Metadata[i]; //rfcParameterMetadata.DefaultValue //rfcParameterMetadata.Direction //RfcDirection.CHANGING //RfcDirection.EXPORT //RfcDirection.IMPORT //RfcDirection.TABLES //rfcParameterMetadata.Optional //rfcParameterMetadata.Name if (rfcParameterMetadata.Direction == RfcDirection.IMPORT) { listRfcParameterMetadataWhichDirectionImport.Add(Convert_To_RfcParameterMetadata_ForUI(rfcParameterMetadata)); } else if (rfcParameterMetadata.Direction == RfcDirection.TABLES) { RfcTableMetadata rfcTableMetadata = rfcParameterMetadata.ValueMetadataAsTableMetadata; int fieldCount = rfcTableMetadata.LineType.FieldCount; // field adeti kadar Datatable nesnesi oluşturup kolon eklemesi yapılacak DataTable dt = new DataTable(rfcTableMetadata.Name); List <RfcFieldMetadata_ForUI> listRfcFieldMetadata = new List <RfcFieldMetadata_ForUI>(); for (int j = 0; j < fieldCount; j++) { RfcFieldMetadata rfcFieldMetadata = rfcTableMetadata[j]; DataColumn dc = new DataColumn(rfcFieldMetadata.Name); dt.Columns.Add(dc); listRfcFieldMetadata.Add(Convert_To_RfcFieldMetadata_ForUI(rfcFieldMetadata)); } //listDataTableToImport.Add(dt); //listRfcParameterMetadataWhichDirectionTables.Add(Convert_To_RfcParameterMetadata_ForUI(rfcParameterMetadata)); RFCTableWhichHasDataTableAndFieldInfo rfcTable = new RFCTableWhichHasDataTableAndFieldInfo(); rfcTable.TableParameterMetadata = Convert_To_RfcParameterMetadata_ForUI(rfcParameterMetadata); rfcTable.DataTableForItems = dt; rfcTable.ListForFieldMetadata = listRfcFieldMetadata; listRFCTable.Add(rfcTable); } } gvImportParams.AutoGenerateColumns = false; gvImportParams.DataSource = listRfcParameterMetadataWhichDirectionImport; // tablolar elde edilip, tabcontrol içine tabpage olarak eklenir // her tabpage içinde datagridview eklenir, kolon değerlerini alma sağlanır foreach (RFCTableWhichHasDataTableAndFieldInfo itemTable in listRFCTable) { TabPage page = new TabPage(); page.Text = itemTable.TableParameterMetadata.Name; page.Name = "tp" + itemTable.TableParameterMetadata.Name; page.Width = 550; page.Height = 300; DataGridView gv = new DataGridView(); gv.Name = "gv" + itemTable.TableParameterMetadata.Name; // grid kaynağı bağlanmalı gv.DataSource = itemTable.DataTableForItems; gv.Anchor = AnchorStyles.Left | AnchorStyles.Right; gv.Location = new Point(5, 35); gv.Margin = new Padding(3); gv.Width = 540; gv.Height = 200; page.Controls.Add(gv); tcTablesToImport.TabPages.Add(page); } } catch (Exception exception) { throw exception; } finally { try { RfcDestinationManager.UnregisterDestinationConfiguration(sapDestinationConfiguration); } catch (Exception ex) { } } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } }