cancel
Showing results for 
Search instead for 
Did you mean: 

Problem Ver 1.x to 2.0 Nco

Former Member
0 Kudos

I have a web application that uses RFC_READ_TABLE..in Nco 1.x, I had a single proxy with multiple instances of the three tables, TAB512Table, RFC_DB_FLDTable, RFC_DB_OPTTable..like TAB512Table1, TAB512Table2, etc..When I installed the 2.0 Nco, it compiled and ran with no code changes, now when I attempt to run (several days later), it gives me an error complaining about object not set to instance.

Question is, how do I instantiate multiple tables? Global to the page?

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Fixed it!! needed the designpatch...seems to be working now just the way it did before....thanks for your effort.

Former Member
0 Kudos

The Table Wizard does exist...however when I drag-and-drop from the toolbox to the main webform (not the SAP one) I get a message box stating that the cast is not valid....I've tried double-clicking also, nothing happens. When I said global, I meant global to the page, not the application.

Former Member
0 Kudos

That's correct...I used the SAPTable Wizard in ver 1.x, when upgrade to 2.0 the tables were removed from the aspx page and I don't see a way to get them back (no table wizard)...I understand that they need to be init...the question is how do I do that globaly? I REALLY don't want to create/dispose everywhere in the app.

reiner_hille-doering
Active Contributor
0 Kudos

The Table Wizard still exists. If the icons are not there, just double-click a .sapwsdl file once (opening the designer will re-create the toolbox as side-effect). So you can re-add the table to get the InitializeComponent-code back (or you add the initializing of the table manually).

The question about having object (e.g. tables) globally is related to stateless ASP.NET programming modell. You can store them in Session state. There is currently another thread ongoing on this theme.

reiner_hille-doering
Active Contributor
0 Kudos

I don't see an initialization of "rfC_DB_OPTTable1", e.g. something like

rfC_DB_OPTTable1 = new rfC_DB_OPTTable1();

If it's null, it stays null, even of passed as "ref" to RFCs.

Perhpaps you used WebForms designer that created the initialization for you in the InitializeComponent method and this code is somehow lost?

Former Member
0 Kudos

=========start of source:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.IO;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Diagnostics;

namespace UserRoles

{

/// <summary>

/// Summary description for SAPUser.

/// </summary>

public class UserTcodes : System.Web.UI.Page

{

#region local_vars

protected System.Web.UI.WebControls.TextBox TextBox1;

protected System.Web.UI.WebControls.Panel Panel1;

protected System.Web.UI.WebControls.Label Label1;

private System.ComponentModel.IContainer components;

protected SAP.Connector.Destination destination1;

protected System.Data.DataSet dataSet1;

protected System.Data.DataTable userDT;

protected System.Data.DataColumn RoleName;

protected System.Data.DataTable unameDT;

protected System.Data.DataColumn Name_Text;

protected System.Web.UI.WebControls.Button Button3;

protected System.Web.UI.WebControls.Button Button;

protected System.Data.DataColumn Tcode_Start;

protected System.Data.DataColumn Tcode_End;

protected System.Web.UI.WebControls.Label Label2;

protected System.Data.DataTable zsegDT;

protected System.Data.DataColumn tcode;

protected System.Data.DataColumn sod_tcode;

protected System.Web.UI.WebControls.DataGrid Datagrid2;

protected System.Data.DataColumn Auth;

protected System.Data.DataColumn Role1;

protected System.Data.DataColumn tcode1;

protected System.Data.DataTable Conflicts;

protected System.Data.DataColumn Role1_tcode;

protected System.Data.DataColumn Role2_tcode;

protected System.Web.UI.WebControls.Panel Panel3;

protected UserRoles.ConfirmWaitButton SODbutton;

protected System.Web.UI.WebControls.TextBox AddRoleTBox;

protected System.Web.UI.WebControls.Panel Panel4;

protected System.Web.UI.WebControls.Button UserButton;

protected System.Web.UI.WebControls.Panel Panel5;

protected System.Web.UI.WebControls.Button NoUserButton;

protected System.Web.UI.WebControls.DataGrid Datagrid1;

protected System.Data.DataColumn dataColumn2;

protected System.Data.DataColumn dataColumn3;

protected System.Web.UI.WebControls.DataGrid Datagrid4;

protected System.Web.UI.WebControls.DataGrid Datagrid5;

protected System.Data.DataView ConflictsDV;

protected System.Data.DataSet dataSet2;

protected System.Data.DataTable AuthDT;

protected System.Data.DataTable AuthDT2;

protected System.Data.DataColumn AO_RoleName;

protected System.Data.DataColumn AO_Tcode;

protected System.Data.DataColumn AO_Object;

protected System.Data.DataColumn AO_Field;

protected System.Data.DataColumn AO_Low;

protected System.Data.DataColumn AO_High;

protected System.Data.DataColumn AO_RoleName2;

protected System.Data.DataColumn AO_Tcode2;

protected System.Data.DataColumn AO_Object2;

protected System.Data.DataColumn AO_Field2;

protected System.Data.DataColumn AO_Low2;

protected System.Data.DataColumn AO_High2;

protected System.Web.UI.WebControls.Label Auth1Label;

protected System.Web.UI.WebControls.Label Auth2Label;

protected System.Web.UI.WebControls.Panel Panel6;

protected System.Web.UI.WebControls.Panel Panel7;

protected System.Web.UI.WebControls.Label SODNotFoundLabel;

protected UserRoles.ConfirmWaitButton SubmitButton;

protected UserRoles.ConfirmWaitButton AddRoleButton;

protected System.Web.UI.WebControls.Panel Panel2;

protected System.Data.DataTable RolesDT;

protected System.Data.DataColumn Role;

protected System.Data.DataColumn Text;

protected System.Web.UI.WebControls.Label Label3;

protected UserRoles.RFC_DB_FLDTable rfC_DB_FLDTable1;

protected UserRoles.RFC_DB_OPTTable rfC_DB_OPTTable1;

protected UserRoles.TAB512Table taB512Table1;

protected UserRoles.RFC_DB_FLDTable rfC_DB_FLDTable2;

protected UserRoles.RFC_DB_OPTTable rfC_DB_OPTTable2;

protected UserRoles.TAB512Table taB512Table2;

protected UserRoles.RFC_DB_FLDTable rfC_DB_FLDTable3;

protected UserRoles.RFC_DB_OPTTable rfC_DB_OPTTable3;

protected UserRoles.TAB512Table taB512Table3;

protected UserRoles.RFC_DB_FLDTable rfC_DB_FLDTable4;

protected UserRoles.RFC_DB_OPTTable rfC_DB_OPTTable4;

protected UserRoles.TAB512Table taB512Table4;

protected StrengthControls.Scrolling.SmartScroller SmartScroller1;

protected bool r;

#endregion

private void SetFocus(Control ctrl)

{

// Define the JavaScript function for the specified control.

string focusScript = "<script language='javascript'>" +

"document.getElementById('" + ctrl.ClientID +

"').focus();</script>";

// Add the JavaScript code to the page.

Page.RegisterStartupScript("FocusScript", focusScript);

}

private void Page_Load(object sender, System.EventArgs e)

{

if (!IsPostBack)

{

DataTable RolesDT = new DataTable("RolesDT");

RolesDT.Columns.Add("Role");

RolesDT.Columns.Add("Text");

int i=destination1.AppServerHost.IndexOf(".");

this.Label2.Text="UserID in "+destination1.AppServerHost.Substring(i-3,3).ToUpper();

// Put user code to initialize the page here

AddRoleTBox.Attributes.Add("onfocus", "this.style.background='#FFFF80';");

AddRoleTBox.Attributes.Add("onblur", "this.style.background='white';");

TextBox1.Attributes.Add("onfocus", "this.style.background='#FFFF80';");

TextBox1.Attributes.Add("onblur", "this.style.background='white';");

}

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();

this.destination1 = new SAP.Connector.Destination(this.components);

this.dataSet1 = new System.Data.DataSet();

this.userDT = new System.Data.DataTable();

this.RoleName = new System.Data.DataColumn();

this.Tcode_Start = new System.Data.DataColumn();

this.Tcode_End = new System.Data.DataColumn();

this.Auth = new System.Data.DataColumn();

this.unameDT = new System.Data.DataTable();

this.Name_Text = new System.Data.DataColumn();

this.zsegDT = new System.Data.DataTable();

this.tcode = new System.Data.DataColumn();

this.sod_tcode = new System.Data.DataColumn();

this.Conflicts = new System.Data.DataTable();

this.Role1_tcode = new System.Data.DataColumn();

this.Role2_tcode = new System.Data.DataColumn();

this.dataColumn2 = new System.Data.DataColumn();

this.dataColumn3 = new System.Data.DataColumn();

this.RolesDT = new System.Data.DataTable();

this.Role = new System.Data.DataColumn();

this.Text = new System.Data.DataColumn();

this.tcode1 = new System.Data.DataColumn();

this.ConflictsDV = new System.Data.DataView();

this.dataSet2 = new System.Data.DataSet();

this.AuthDT = new System.Data.DataTable();

this.AO_RoleName = new System.Data.DataColumn();

this.AO_Tcode = new System.Data.DataColumn();

this.AO_Object = new System.Data.DataColumn();

this.AO_Field = new System.Data.DataColumn();

this.AO_Low = new System.Data.DataColumn();

this.AO_High = new System.Data.DataColumn();

this.AuthDT2 = new System.Data.DataTable();

this.AO_RoleName2 = new System.Data.DataColumn();

this.AO_Tcode2 = new System.Data.DataColumn();

this.AO_Object2 = new System.Data.DataColumn();

this.AO_Field2 = new System.Data.DataColumn();

this.AO_Low2 = new System.Data.DataColumn();

this.AO_High2 = new System.Data.DataColumn();

((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.userDT)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.unameDT)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.zsegDT)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.Conflicts)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.RolesDT)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.ConflictsDV)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.dataSet2)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.AuthDT)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.AuthDT2)).BeginInit();

this.UserButton.Click += new System.EventHandler(this.UserButton_Click);

this.NoUserButton.Click += new System.EventHandler(this.NoUserButton_Click);

this.SubmitButton.Click += new System.EventHandler(this.SubmitButton_Click);

this.Datagrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.Datagrid1_DeleteCommand);

this.Datagrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.Datagrid1_ItemDataBound);

this.SODbutton.Click += new System.EventHandler(this.SODbutton_Click);

this.AddRoleButton.Click += new System.EventHandler(this.AddRoleButton_Click);

this.Datagrid2.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.Datagrid2_ItemCommand);

this.Datagrid2.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.Datagrid1_ItemDataBound);

this.Datagrid4.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.Datagrid1_ItemDataBound);

this.Datagrid5.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.Datagrid1_ItemDataBound);

//

// destination1

//

this.destination1.AppServerHost = ((string)(configurationAppSettings.GetValue("destination1.AppServerHost", typeof(string))));

this.destination1.Client = ((short)(configurationAppSettings.GetValue("destination1.Client", typeof(short))));

this.destination1.Language = ((string)(configurationAppSettings.GetValue("destination1.Language", typeof(string))));

this.destination1.Password = ((string)(configurationAppSettings.GetValue("destination1.Password", typeof(string))));

this.destination1.SystemNumber = ((short)(configurationAppSettings.GetValue("destination1.SystemNumber", typeof(short))));

this.destination1.Username = ((string)(configurationAppSettings.GetValue("destination1.Username", typeof(string))));

//

// dataSet1

//

this.dataSet1.DataSetName = "NewDataSet";

this.dataSet1.Locale = new System.Globalization.CultureInfo("en-US");

this.dataSet1.Tables.AddRange(new System.Data.DataTable[] {

this.userDT,

this.unameDT,

this.zsegDT,

this.Conflicts,

this.RolesDT});

//

// userDT

//

this.userDT.Columns.AddRange(new System.Data.DataColumn[] {

this.RoleName,

this.Tcode_Start,

this.Tcode_End,

this.Auth});

this.userDT.TableName = "userDT";

//

// RoleName

//

this.RoleName.ColumnName = "RoleName";

//

// Tcode_Start

//

this.Tcode_Start.Caption = "Tcode Start";

this.Tcode_Start.ColumnName = "Tcode Start";

//

// Tcode_End

//

this.Tcode_End.Caption = "Tcode End";

this.Tcode_End.ColumnName = "Tcode End";

//

// Auth

//

this.Auth.ColumnName = "Auth";

//

// unameDT

//

this.unameDT.Columns.AddRange(new System.Data.DataColumn[] {

this.Name_Text});

this.unameDT.TableName = "unameDT";

//

// Name_Text

//

this.Name_Text.ColumnName = "Name_Text";

//

// zsegDT

//

this.zsegDT.Columns.AddRange(new System.Data.DataColumn[] {

this.tcode,

this.sod_tcode});

this.zsegDT.TableName = "zsegDT";

//

// tcode

//

this.tcode.ColumnName = "tcode";

//

// sod_tcode

//

this.sod_tcode.ColumnName = "sod_tcode";

//

// Conflicts

//

this.Conflicts.Columns.AddRange(new System.Data.DataColumn[] {

this.Role1_tcode,

this.Role2_tcode,

this.dataColumn2,

this.dataColumn3});

this.Conflicts.TableName = "Conflicts";

//

// Role1_tcode

//

this.Role1_tcode.ColumnName = "Role1";

//

// Role2_tcode

//

this.Role2_tcode.ColumnName = "Role2";

//

// dataColumn2

//

this.dataColumn2.ColumnName = "Role1_tcode";

//

// dataColumn3

//

this.dataColumn3.ColumnName = "Role2_tcode";

//

// RolesDT

//

this.RolesDT.Columns.AddRange(new System.Data.DataColumn[] {

this.Role,

this.Text});

this.RolesDT.Constraints.AddRange(new System.Data.Constraint[] {

new System.Data.UniqueConstraint("Constraint1", new string[] {

"Role"}, true)});

this.RolesDT.PrimaryKey = new System.Data.DataColumn[] {

this.Role};

this.RolesDT.TableName = "RolesDT";

//

// Role

//

this.Role.AllowDBNull = false;

this.Role.ColumnName = "Role";

//

// Text

//

this.Text.ColumnName = "Text";

//

// ConflictsDV

//

this.ConflictsDV.ApplyDefaultSort = true;

this.ConflictsDV.Sort = "Role1";

this.ConflictsDV.Table = this.Conflicts;

//

// dataSet2

//

this.dataSet2.DataSetName = "NewDataSet";

this.dataSet2.Locale = new System.Globalization.CultureInfo("en-US");

this.dataSet2.Tables.AddRange(new System.Data.DataTable[] {

this.AuthDT,

this.AuthDT2});

//

// AuthDT

//

this.AuthDT.Columns.AddRange(new System.Data.DataColumn[] {

this.AO_RoleName,

this.AO_Tcode,

this.AO_Object,

this.AO_Field,

this.AO_Low,

this.AO_High});

this.AuthDT.Constraints.AddRange(new System.Data.Constraint[] {

new System.Data.UniqueConstraint("Constraint1", new string[] {

"AO_RoleName",

"AO_Tcode"}, true)});

this.AuthDT.PrimaryKey = new System.Data.DataColumn[] {

this.AO_RoleName,

this.AO_Tcode};

this.AuthDT.TableName = "AuthDT";

//

// AO_RoleName

//

this.AO_RoleName.AllowDBNull = false;

this.AO_RoleName.ColumnName = "AO_RoleName";

//

// AO_Tcode

//

this.AO_Tcode.AllowDBNull = false;

this.AO_Tcode.ColumnName = "AO_Tcode";

//

// AO_Object

//

this.AO_Object.ColumnName = "AO_Object";

//

// AO_Field

//

this.AO_Field.ColumnName = "AO_Field";

//

// AO_Low

//

this.AO_Low.ColumnName = "AO_Low";

//

// AO_High

//

this.AO_High.ColumnName = "AO_High";

//

// AuthDT2

//

this.AuthDT2.Columns.AddRange(new System.Data.DataColumn[] {

this.AO_RoleName2,

this.AO_Tcode2,

this.AO_Object2,

this.AO_Field2,

this.AO_Low2,

this.AO_High2});

this.AuthDT2.Constraints.AddRange(new System.Data.Constraint[] {

new System.Data.UniqueConstraint("Constraint1", new string[] {

"AO_RoleName2",

"AO_Tcode2"}, true)});

this.AuthDT2.PrimaryKey = new System.Data.DataColumn[] {

this.AO_RoleName2,

this.AO_Tcode2};

this.AuthDT2.TableName = "AuthDT2";

//

// AO_RoleName2

//

this.AO_RoleName2.AllowDBNull = false;

this.AO_RoleName2.ColumnName = "AO_RoleName2";

//

// AO_Tcode2

//

this.AO_Tcode2.AllowDBNull = false;

this.AO_Tcode2.ColumnName = "AO_Tcode2";

//

// AO_Object2

//

this.AO_Object2.ColumnName = "AO_Object2";

//

// AO_Field2

//

this.AO_Field2.ColumnName = "AO_Field2";

//

// AO_Low2

//

this.AO_Low2.ColumnName = "AO_Low2";

//

// AO_High2

//

this.AO_High2.ColumnName = "AO_High2";

this.Load += new System.EventHandler(this.Page_Load);

((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.userDT)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.unameDT)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.zsegDT)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.Conflicts)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.RolesDT)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.ConflictsDV)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.dataSet2)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.AuthDT)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.AuthDT2)).EndInit();

}

#endregion

private void AddRole()

{

string tstring=AddRoleTBox.Text.ToUpper().Trim();

if (tstring.Length>0)

{

string[] addedRoles=null;

addedRoles=tstring.Split('\n');

for (int lines=0;lines<addedRoles.Length;lines++)

{

string RoleAdded=addedRoles[lines].Trim();

DataRow RolesDR=RolesDT.NewRow();

RolesDR["Role"]=RoleAdded;

try

{RolesDT.Rows.Add(RolesDR);}

catch

{continue;}

RolesDT.AcceptChanges();

}

AddRoleTBox.Text=null;

this.Cache.Remove("RolesDT");

this.Cache.Insert("RolesDT",RolesDT,null);

}

}

private void ParseDG1()

{

RolesDT.Clear();

if (taB512Table1.Count>0)

{

for (int i=0;i<taB512Table1.Count;i++)

{

string s = (string) taB512Table1<i>.Wa;

string [] rec = null;

rec = s.Split('|');

DataRow RolesDR=RolesDT.NewRow();

RolesDR["Role"]=rec[1].Trim();

try

{RolesDT.Rows.Add(RolesDR);}

catch

{continue;}

}

RolesDT.AcceptChanges();

}

// Debug.WriteLine("ParseDG1.RolesDT.count=>"+RolesDT.Rows.Count.ToString());

taB512Table1.Clear();

rfC_DB_FLDTable1.Clear();

rfC_DB_OPTTable1.Clear();

}

private void FillDG1(string DeleteRole)

{

Debug.WriteLine("FillDG1.RolesDT.count=>"+RolesDT.Rows.Count.ToString());

// make unique roles for display

SAPProxy1 proxy1 = new SAPProxy1(destination1.ConnectionString);

RFC_DB_OPT dbopt = new RFC_DB_OPT();

DataTable dt=new DataTable();

dt.Columns.Add("t");

DataRow optDR = dt.NewRow();

optDR["t"]="MANDT = '025' AND SPRAS = 'E' AND LINE < 1";

dt.Rows.Add(optDR);

optDR = dt.NewRow();

optDR["t"]=" AND AGR_NAME IN ";

dt.Rows.Add(optDR);

// Format the rest of the string

ArrayList qray = new ArrayList();

for(int h=0;h<RolesDT.Rows.Count;h++)

{

if(!RolesDT.Rows[h]["Role"].ToString().Trim().Equals(DeleteRole.Trim()))

{

qray.Add(RolesDT.Rows[h]["Role"].ToString());

}

}

//Debug.WriteLine("qray.count="+qray.Count.ToString());

string q="('"qray[0].ToString().Trim()"'";

optDR = dt.NewRow();

optDR["t"]=q;

dt.Rows.Add(optDR);

Debug.WriteLine("q="+q);

for(int j=1;j<qray.Count-1;j++)

{

q="";

q=",'"qray[j].ToString().Trim()+"'";

optDR = dt.NewRow();

optDR["t"]=q;

dt.Rows.Add(optDR);

Debug.WriteLine("q="+q);

}

q=",'"qray[qray.Count-1].ToString().Trim()"')";

optDR = dt.NewRow();

optDR["t"]=q;

dt.Rows.Add(optDR);

// Debug.WriteLine("q="+q);

rfC_DB_OPTTable2.FromADODataTable(dt);

dt.Dispose();

try

{

proxy1.Connection.Open();

proxy1.Rfc_Read_Table("|","","AGR_TEXTS",0,0,ref taB512Table2,ref rfC_DB_FLDTable2, ref rfC_DB_OPTTable2);

proxy1.Connection.Close();

}

catch(Exception ex)

{

Response.Write(ex.ToString());

}

RolesDT.Clear();

if (taB512Table2.Count>0)

{

for (int j=0;j<taB512Table2.Count;j++)

{

string ss = (string) taB512Table2[j].Wa;

string [] rec2 = null;

rec2 = ss.Split('|');

DataRow dr=RolesDT.NewRow();

dr["Role"]=rec2[1].Trim();

dr["Text"]=rec2[4].Trim();

try

{RolesDT.Rows.Add(dr);}

catch

{continue;}

}

}

this.Cache.Remove("RolesDT");

Datagrid1.DataSource = RolesDT;

Datagrid1.DataBind();

Datagrid1.Visible=true;

this.Cache.Insert("RolesDT",RolesDT,null);

taB512Table2.Clear();

rfC_DB_FLDTable2.Clear();

rfC_DB_OPTTable2.Clear();

Panel4.Visible=true;

AddRoleTBox.Visible=true;

TextBox1.Visible=true;

}

private void Parse_zsegtcode(ref DataTable dt)

{

int i, j;

string match1a,match2a;

DataTable pass1DT = new DataTable("pass1DT");

pass1DT.Columns.Add("pass1Role");

pass1DT.Columns.Add("tcode1");

UniqueConstraint UC = new UniqueConstraint(new DataColumn[]

{pass1DT.Columns["pass1Role"],

pass1DT.Columns["tcode1"]});

pass1DT.Constraints.Add(UC);

DataRow[] foundPass1Rows;

for (i=0;i<dt.Rows.Count;i++)

{

match1a=dt.Rows<i>["tcode"].ToString().Trim();

match2a=dt.Rows<i>["sod_tcode"].ToString().Trim();

foundPass1Rows=userDT.Select("[Tcode Start]='"match1a"' OR [Tcode Start]='"match2a"'");

for(j=0;j<foundPass1Rows.Length;j++)

{

DataRow dr = pass1DT.NewRow();

dr["pass1Role"]=foundPass1Rows[j]["RoleName"].ToString();

dr["tcode1"]=foundPass1Rows[j]["Tcode Start"].ToString();

try

{

pass1DT.Rows.Add(dr);

}

catch

{

continue;

}

}

}

// have tocdes .. now pair them up

DataTable Conflicts = new DataTable("Conflicts");

Conflicts.Columns.Add("Role1");

Conflicts.Columns.Add("Role1_tcode");

Conflicts.Columns.Add("Role2");

Conflicts.Columns.Add("Role2_tcode");

int k;

string match1,match2;

DataRow[] foundRows1,foundRows2;

for (i=0;i<pass1DT.Rows.Count;i++)

{

match1=pass1DT.Rows<i>["tcode1"].ToString().Trim();

foundRows1=dt.Select("tcode='"match1"'");

for(j=0;j<foundRows1.Length;j++)

{

match2=foundRows1[j]["sod_tcode"].ToString().Trim();

foundRows2=pass1DT.Select("tcode1='"match2"'");

for(k=0;k<foundRows2.Length;k++)

{

DataRow d=Conflicts.NewRow();

d["Role1"]=pass1DT.Rows<i>["pass1Role"].ToString().Trim();

d["Role1_tcode"]=match1;

d["Role2"]=foundRows2[k]["pass1Role"].ToString().Trim();

d["Role2_tcode"]=match2;

Conflicts.Rows.Add(d);

}

}

}

DataView ConflictsDV = new DataView(Conflicts);

ConflictsDV.Sort="Role1";

if (ConflictsDV.Count>0)

{

Datagrid2.DataSource = ConflictsDV;

Datagrid2.DataBind();

Datagrid2.Visible=true;

SODNotFoundLabel.Visible=false;

}

else

SODNotFoundLabel.Visible=true;

}

private void Parse_V_USERNAME()

{

// Only 1 row returned

DataRow dr = unameDT.NewRow();

string s = taB512Table1[0].Wa.Trim();

string [] rec = null;

rec = s.Split('|');

dr["Name_Text"]=rec[4].Trim(); // Name_text

unameDT.Rows.Add(dr);

Label1.Text=unameDT.Rows[0]["Name_Text"].ToString()+" - Existing Roles";

Label1.Visible=true;

unameDT.Dispose();

}

private void GetUserName()

{

SAPProxy1 proxy1 = new SAPProxy1(destination1.ConnectionString);

RFC_DB_OPT dbopt = new RFC_DB_OPT();

string s=TextBox1.Text.ToUpper();

dbopt.Text = "MANDT = '025' AND BNAME = '"+ s.Trim() + "'";

rfC_DB_OPTTable1.Insert(0,dbopt);

try

{

proxy1.Connection.Open();

// read V_USERNAME in PN1

proxy1.Rfc_Read_Table("|","","V_USERNAME",0,0,ref taB512Table1,ref rfC_DB_FLDTable1, ref rfC_DB_OPTTable1);

proxy1.Connection.Close();

}

catch(Exception ex)

{

Response.Write(ex.ToString());

}

Parse_V_USERNAME();

// cleanup

taB512Table1.Clear();

rfC_DB_FLDTable1.Clear();

rfC_DB_OPTTable1.Clear();

}

private void CreateDG()

{

if (TextBox1.Text.Trim()!="")

{

SAPProxy1 proxy1 = new SAPProxy1(destination1.ConnectionString);

RFC_DB_OPT dbopt = new RFC_DB_OPT();

string s=TextBox1.Text.ToUpper();

dbopt.Text = "UNAME = '"+ s.Trim() +"' AND TO_DAT = '99991231'";

rfC_DB_OPTTable1.Insert(0,dbopt);

try

{

proxy1.Connection.Open();

proxy1.Rfc_Read_Table("|","","AGR_USERS",0,0,ref taB512Table1,ref rfC_DB_FLDTable1, ref rfC_DB_OPTTable1);

proxy1.Connection.Close();

}

catch(Exception ex)

{

Response.Write(ex.ToString());

}

}

}

private void Parse_AGR_USERS_common(ref DataTable CommonDT)

{

string tcode1, tcode2;

if (Datagrid1.Items.Count>0)

{

//Debug.WriteLine("Parse_AGR_USERS()BEGIN==> "+DateTime.Now.ToLongTimeString());

for (int i=0;i<Datagrid1.Items.Count;i++)

{

SAPProxy1 proxy1 = new SAPProxy1(destination1.ConnectionString);

RFC_DB_OPT dbopt = new RFC_DB_OPT();

DataTable dt=new DataTable();

dt.Columns.Add("t");

DataRow optDR = dt.NewRow();

optDR["t"]="MANDT ='025' AND OBJECT ='S_TCODE' ";

dt.Rows.Add(optDR);

optDR = dt.NewRow();

optDR["t"]="AND AGR_NAME ='"+ Datagrid1.Items<i>.Cells[1].Text.Trim() + "'";

dt.Rows.Add(optDR);

optDR = dt.NewRow();

optDR["t"]="AND FIELD ='TCD'";

dt.Rows.Add(optDR);

rfC_DB_OPTTable2.FromADODataTable(dt);

dt.Dispose();

try

{

proxy1.Connection.Open();

proxy1.Rfc_Read_Table("|","","AGR_1251",0,0,ref taB512Table2,ref rfC_DB_FLDTable2, ref rfC_DB_OPTTable2);

proxy1.Connection.Close();

}

catch(Exception ex)

{

Response.Write(ex.ToString());

}

//Debug.WriteLine("Parse_AGR_USERS()LOOP Start==> "+DateTime.Now.ToLongTimeString());

if (taB512Table2.Count>0)

{

for (int j=0;j<taB512Table2.Count;j++)

{

string ss = (string) taB512Table2[j].Wa;

string [] rec2 = null;

rec2 = ss.Split('|');

// have the rolename

string Rname=rec2[1].Trim();

// build filter string

// replace wildcard with sql correct one

tcode1=rec2[7].Trim().Replace("*","%");

DataRow[] foundRows;

string qs;

if(rec2[8].Trim().Equals(""))

{

qs="common_tcode LIKE '"tcode1"'";

}

else

{

tcode2=rec2[8].Trim().Replace("*","%");

qs="common_tcode >= '"tcode1"' AND common_tcode <= '"tcode2"' OR common_tcode LIKE '"tcode2"'";

}

foundRows=CommonDT.Select(qs);

for(int k=0;k<foundRows.Length;k++)

{

DataRow dr = userDT.NewRow();

dr["RoleName"]=Rname;

dr["Tcode Start"]=foundRows[k]["common_tcode"].ToString().Trim();

try

{

userDT.Rows.Add(dr);

}

catch

{continue;}

}

}

}

//Debug.WriteLine("Parse_AGR_USERS()LOOP End==> "+DateTime.Now.ToLongTimeString());

// cleanup

taB512Table2.Clear();

rfC_DB_FLDTable2.Clear();

rfC_DB_OPTTable2.Clear();

}

}

//Debug.WriteLine("Parse_AGR_USERS()END==> "+DateTime.Now.ToLongTimeString());

}

private DataTable GetCommonTcodes(ref DataTable dt)

{

DataTable CommonTcodes = new DataTable("CommonTcodes");

CommonTcodes.Columns.Add("common_tcode");

CommonTcodes.Columns["common_tcode"].Unique=true;

for(int i=0;i<dt.Rows.Count;i++)

{

string s=dt.Rows<i>["tcode"].ToString().Trim();

DataRow dr=CommonTcodes.NewRow();

try

{

dr["common_tcode"]=s;

CommonTcodes.Rows.Add(dr);

}

catch

{continue;}

}

for(int i=0;i<dt.Rows.Count;i++)

{

string s=dt.Rows<i>["sod_tcode"].ToString().Trim();

DataRow dr=CommonTcodes.NewRow();

try

{

dr["common_tcode"]=s;

CommonTcodes.Rows.Add(dr);

}

catch

{continue;}

}

return(CommonTcodes);

}

private void SODbutton_Click(object sender, System.EventArgs e)

{

RolesDT=Cache.Get("RolesDT") as DataTable;

Panel2.Visible=false;

Panel4.Visible=false;

Panel3.Visible=true;

SAPProxy1 proxy1 = new SAPProxy1(destination1.ConnectionString);

try

{

proxy1.Connection.Open();

proxy1.Rfc_Read_Table("|","","ZSEGTCODE",0,0,ref taB512Table1,ref rfC_DB_FLDTable1, ref rfC_DB_OPTTable1);

proxy1.Connection.Close();

}

catch(Exception ex)

{

Response.Write(ex.ToString());

}

if (taB512Table1.Count>0)

{

for (int j=0;j<taB512Table1.Count;j++)

{

string s = (string) taB512Table1[j].Wa;

string [] rec = null;

rec = s.Split('|');

DataRow dr=zsegDT.NewRow();

dr["tcode"]=rec[0].Trim();

dr["sod_tcode"]=rec[1].Trim();

try

{zsegDT.Rows.Add(dr);}

catch

{continue;}

}

DataTable CommonTcodes=GetCommonTcodes(ref zsegDT);

Parse_AGR_USERS_common(ref CommonTcodes);

Parse_zsegtcode(ref zsegDT);

}

}

private void AddRoleButton_Click(object sender, System.EventArgs e)

{

if(Datagrid1.Items.Count>0)

{

RolesDT=Cache.Get("RolesDT") as DataTable;

}

Panel3.Visible=false;

// Debug.WriteLine("AddRoleButton_Click.RolesDT.count=>"+RolesDT.Rows.Count.ToString());

AddRole();

FillDG1("");

}

private void UserButton_Click(object sender, System.EventArgs e)

{

Panel1.Visible=true;

SubmitButton.Visible=true;

Panel5.Visible=false;

SetFocus(TextBox1);

}

private void NoUserButton_Click(object sender, System.EventArgs e)

{

Panel5.Visible=false;

Panel4.Visible=true;

}

private void Datagrid2_ItemCommand(object sender,

System.Web.UI.WebControls.DataGridCommandEventArgs e)

{

if(e.CommandName == "Select")

{

for(int i=0;i<2;i++)

{

DataTable AuthDT = new DataTable("AuthDT");

AuthDT.Columns.Add("AO_RoleName");

AuthDT.Columns.Add("AO_Tcode");

AuthDT.Columns.Add("AO_Object");

AuthDT.Columns.Add("AO_Field");

AuthDT.Columns.Add("AO_Low");

AuthDT.Columns.Add("AO_High");

UniqueConstraint AuthUC = new UniqueConstraint(new DataColumn[]

{

AuthDT.Columns["AO_RoleName"],

AuthDT.Columns["AO_Tcode"],

AuthDT.Columns["AO_Object"],

AuthDT.Columns["AO_Field"],

AuthDT.Columns["AO_Low"],

AuthDT.Columns["AO_High"]});

AuthDT.Constraints.Add(AuthUC);

string Role1String, Role1_TcodeString;

if(i==0)

{

Role1String=e.Item.Cells[1].Text;

Role1_TcodeString=e.Item.Cells[2].Text;

Auth1Label.Text=Role1String"/"Role1_TcodeString;

}

else

{

Role1String=e.Item.Cells[3].Text;

Role1_TcodeString=e.Item.Cells[4].Text;

Auth2Label.Text=Role1String"/"Role1_TcodeString;

}

AuthObjects.GetAuthValues(this.Page,

Role1String,

Role1_TcodeString,

ref AuthDT,

destination1,

rfC_DB_FLDTable1,

rfC_DB_OPTTable1,

taB512Table1,

rfC_DB_FLDTable2,

rfC_DB_OPTTable2,

taB512Table2,

rfC_DB_FLDTable3,

rfC_DB_OPTTable3,

taB512Table3,

rfC_DB_FLDTable4,

rfC_DB_OPTTable4,

taB512Table4);

if (i==0)

{

Panel6.Visible=true;

Auth1Label.Visible=true;

Datagrid4.DataSource=AuthDT;

Datagrid4.DataBind();

Datagrid4.Visible=true;

AuthDT.Dispose();

}

else

{

Auth2Label.Visible=true;

Datagrid5.DataSource=AuthDT;

Datagrid5.DataBind();

Datagrid5.Visible=true;

AuthDT.Dispose();

}

}

}

}

private void SubmitButton_Click(object sender, System.EventArgs e)

{

GetUserName();

CreateDG();

ParseDG1();

FillDG1("");

SetFocus(AddRoleTBox);

}

private void Datagrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)

{

string s=Datagrid1.Items[e.Item.ItemIndex].Cells[1].Text;

RolesDT=Cache.Get("RolesDT") as DataTable;

// Debug.WriteLine("Datagrid1_DeleteCommand.RolesDT.count=>"+RolesDT.Rows.Count.ToString());

FillDG1(s);

}

private void Datagrid1_ItemDataBound(object source, System.Web.UI.WebControls.DataGridItemEventArgs e)

{

if (e.Item.ItemType.Equals(ListItemType.Item))

{

//Add the OnMouseOver and OnMouseOut method to the Row of DataGrid

e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#FFFF80'");

e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");

}

if(e.Item.ItemType.Equals(ListItemType.AlternatingItem))

{

//Add the OnMouseOver and OnMouseOut method to the Row of DataGrid

e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#FFFF80'");

e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='silver'");

}

}

}

}

===========end of source

============start of stack

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 678: string s=TextBox1.Text.ToUpper();

Line 679: dbopt.Text = "MANDT = '025' AND BNAME = '"+ s.Trim() + "'";

Line 680: rfC_DB_OPTTable1.Insert(0,dbopt);

Line 681: try

Line 682: {

Source File: c:\inetpub\wwwroot\userroles\usertcodes.aspx.cs Line: 680

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]

UserRoles.UserTcodes.GetUserName() in c:\inetpub\wwwroot\userroles\usertcodes.aspx.cs:680

UserRoles.UserTcodes.SubmitButton_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\userroles\usertcodes.aspx.cs:983

System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33

System.Web.UI.Page.ProcessRequestMain() +1292

-


Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

=========end of stack

reiner_hille-doering
Active Contributor
0 Kudos

Can you post some sourcecode and call stack (best with "Show non-user code" option turned on)?