cancel
Showing results for 
Search instead for 
Did you mean: 

Call By Reference Problem in SAP .NET Connector 1.2.2

0 Kudos

Dear All,

I have got a function in SAP R/3 4.6, which has got one Table as parameter. I use the following code to call this function via .NET connector. everything goes fine except that the passing parameter is considered as call by value instead of reference.

private void InitializeComponent()

{

this.zemP_ADSTable1 = new SAPRFC.ZEMP_ADSTable();

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

this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);

this.Button1.Click += new System.EventHandler(this.Button1_Click);

//

// zemP_ADSTable1

//

this.zemP_ADSTable1.AllowEdit = true;

this.zemP_ADSTable1.AllowNew = true;

this.zemP_ADSTable1.AllowRemove = true;

this.zemP_ADSTable1.SupportsChangeNotification = true;

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

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

}

#endregion

// this method prepare the ADSTable based on ADS structure.

private void prepareADSTable()

{

zemP_ADSTable1 = new ZEMP_ADSTable ();

zemP_ADS = new ZEMP_ADS ();

zemP_ADS.Name="Amirali";

zemP_ADS.Lastname="pourteymour";

// employee.Email="amirali.pourteymour@cablesurf.de";

// employee.Tel="01636558732";

zemP_ADSTable1.

zemP_ADSTable1.Add (zemP_ADS);

//return employees;

}

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

{

SAPHR proxy = new SAPHR();

try

{

proxy.Connection = SAP.Connector.SAPLoginProvider.GetSAPConnection(this);

prepareADSTable();

proxy.Zemp_Ads_Update(ref zemP_ADSTable1);

// Call methods here

// Now update Data Bindings. On WinForms this will be automatic, on WebForms call the following line

this.DataBind();

}

catch(Exception ex)

{

TextBox1.Text = ex.ToString();

// If SAPLoginProvider.GetSAPConnection(this) cannot get a connection, we might get an error. // Normally this can be ignored as it will automatically will force a relogon.

}

}

but the table parameter is not considered as call by reference. am I doing something wrong.

Regards,

Amirali

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello

I want the runtime installation of .net connector ver 1.2.2 . Where will get the same? on service.sap.com/connector it is not shown.

Thanks

Sandeep

Former Member
0 Kudos

Hi,

Did you get any error at compilation time or at runtime? If yes, what is the original error message ?

By the way, I saw the following code:

private void prepareADSTable()

{

zemP_ADSTable1 = new ZEMP_ADSTable ();

. . .

}

Please reconsider this line. It is at least unnecessary if it is not harmful.

Regards,

Guangwei

0 Kudos

Hi,

First Thanx for your answer, I didn't get any error message or warning after compiling the code, but by commenting the line of code you mentioned I got null pointer exception.

Any idea,

Cheers,

Amirali

Former Member
0 Kudos

Hi,

Inside InitializeComponent, you already have

this.zemP_ADSTable1 = new SAPRFC.ZEMP_ADSTable();

Therefore, the line I mentioned in my last response is unnecessary. As for the null reference problem, you can sure resolve it with VS debugger.

I am more interested in the "Call By Reference" problem. Why did you believe that you have this problem?

Guangwei

0 Kudos

Hi,

Thanx for your answer. The reason is that the passing parameter will be changed inside the function module in SAP but we don't get the changes back. seems that the table parameter is behaved in call by value mode.

Regards,

Amirali