cancel
Showing results for 
Search instead for 
Did you mean: 

Call Bapi_Material_Availability Error : Index was outside the bounds ...

Former Member
0 Kudos

I am coding .net 2003 (VB) and .NET connector 2.0 Call Bapi_Material_Availability . It Error Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

This my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim Batch As String

Dim Check_Rule As String

Dim Customer As String

Dim Dec_For_Rounding As Short

Dim Dec_For_Rounding_X As String

Dim Doc_Number As String

Dim Itm_Number As String

Dim Material As String

Dim Material_Evg As Test6.BAPIMGVMATNR

Dim Plant As String

Dim Read_Atp_Lock As String

Dim Read_Atp_Lock_X As String

Dim Stge_Loc As String

Dim Stock_Ind As String

Dim Unit As String

Dim Wbs_Elem As String

Dim Av_Qty_Plt As Decimal

Dim Dialogflag As String

Dim Endleadtme As String

Dim Return0 As Test6.BAPIRETURN

Dim Wmdvex As Test6.BAPIWMDVETable

Dim Wmdvsx As Test6.BAPIWMDVSTable

Material = "100-400"

Plant = "1000"

Unit = "ST"

Try

SapProxy11.Bapi_Material_Availability(Batch, _

Check_Rule, _

Customer, _

Dec_For_Rounding, _

Dec_For_Rounding_X, _

Doc_Number, _

Itm_Number, _

Material, _

Material_Evg, _

Plant, _

Read_Atp_Lock, _

Read_Atp_Lock_X, _

Stge_Loc, _

Stock_Ind, _

Unit, _

Wbs_Elem, _

Av_Qty_Plt, _

Dialogflag, _

Endleadtme, _

Return0, _

Wmdvex, _

Wmdvsx)

Me.TextBox1.Text = Av_Qty_Plt.ToString()

Catch ex As SAP.Connector.RfcAbapException

MsgBox(ex.Message.ToString)

End Try

End Sub

========

<i>Source Error:

Line 157: ByRef Wmdvsx As BAPIWMDVSTable)

Line 158: Dim results As Object()

Line 159: results = SAPInvoke("Bapi_Material_Availability", new Object() { _

Line 160: Batch,Check_Rule,Customer,Dec_For_Rounding,Dec_For_Rounding_X,Doc_Number,Itm_Number,Material,Material_Evg,Plant,Read_Atp_Lock,Read_Atp_Lock_X,Stge_Loc,Stock_Ind,Unit,Wbs_Elem,Wmdvex,Wmdvsx })

Line 161: Av_Qty_Plt = CType(results(0), Decimal)

Source File: E:\SAP\BAPI\Test6\SAPProxy1.vb Line: 159

Stack Trace:

[IndexOutOfRangeException: Index was outside the bounds of the array.]

SAP.Connector.Rfc.RfcClient.RfcInvoke(SAPClient proxy, String method, Object[] methodParamsIn) +1229

SAP.Connector.SAPClient.SAPInvoke(String method, Object[] methodParamsIn) +70

Test6.SAPProxy1.Bapi_Material_Availability(String Batch, String Check_Rule, String Customer, Int16 Dec_For_Rounding, String Dec_For_Rounding_X, String Doc_Number, String Itm_Number, String Material, BAPIMGVMATNR Material_Evg, String Plant, String Read_Atp_Lock, String Read_Atp_Lock_X, String Stge_Loc, String Stock_Ind, String Unit, String Wbs_Elem, Decimal& Av_Qty_Plt, String& Dialogflag, String& Endleadtme, BAPIRETURN& Return0, BAPIWMDVETable& Wmdvex, BAPIWMDVSTable& Wmdvsx) in E:\SAP\BAPI\Test6\SAPProxy1.vb:159

Test6.WebForm1.Button1_Click(Object sender, EventArgs e) in E:\SAP\BAPI\Test6\Default.aspx.vb:64

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

</i>

Pls. help me.

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hey, It's work.

Thank you.

Former Member
0 Kudos

Kreang,

In this forum 'thank' needs rewarding points Please thank me giving rewarding points.

Best Regards,

Huseyin Akturk

SW Engineer & SAP ABAP Consultant

www.huseyinakturk.net

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Kreangsak,

It seems that you need to initialize you tables, parameters for rfc function

Dim Wmdvex As Test6.BAPIWMDVETable

Dim Wmdvsx As Test6.BAPIWMDVSTable

Wmdvex = new Test6.BAPIWMDVETable()

Wmdvsx = new Test6.BAPIWMDVSTable()

If there is other table, you need to initialize them with new operator. Null tables does not accepted.

If you problem goes set the call stack's "show non-user code" property and send the stack.

Best Regards,

Huseyin Akturk

SW Engineer & SAP ABAP Consultant

www.huseyinakturk.net