cancel
Showing results for 
Search instead for 
Did you mean: 

'System.IndexOutOfRangeException' Error in VB

Former Member
0 Kudos

Hello everyone,

I'm trying to call a BAPI from VB. This BAPI is actually just a wrapper of the standard function module 'BP_JOB_READ'.

Unfortunately, when I try to call this BAPI, I get this error message:

=====================

An unhandled exception of type 'System.IndexOutOfRangeException' occurred in sap.connector.rfc.dll

Additional information: Index was outside the bounds of the array.

=====================

And breaks at the part of the code with >>>>>:

=====================

ByRef Job_Read_Steplist As TBTCSTEPTable)

Dim results As Object()

>>>>> results = SAPInvoke("Z_Monitor_Bp_Job_Read", new Object() { _

Job_Read_Jobcount,Job_Read_Jobname,Job_Read_Opcode,Job_Read_Steplist })

Job_Read_Jobhead = CType(results(0), TBTCJOB)

Job_Read_Steplist = CType(results(1), TBTCSTEPTable)

End Sub

=====================

Here is the code of the function module:

=====================

function z_monitor_bp_job_read.

*"----


""Local interface:

*" IMPORTING

*" VALUE(JOB_READ_JOBCOUNT) LIKE TBTCJOB-JOBCOUNT

*" VALUE(JOB_READ_JOBNAME) LIKE TBTCJOB-JOBNAME

*" VALUE(JOB_READ_OPCODE) LIKE BTCH0000-INT4

*" EXPORTING

*" VALUE(JOB_READ_JOBHEAD) LIKE TBTCJOB

*" STRUCTURE TBTCJOB

*" TABLES

*" JOB_READ_STEPLIST STRUCTURE TBTCSTEP OPTIONAL

*" EXCEPTIONS

*" INVALID_OPCODE

*" JOB_DOESNT_EXIST

*" JOB_DOESNT_HAVE_STEPS

*"----


call function 'BP_JOB_READ'

exporting

job_read_jobcount = job_read_jobcount

job_read_jobname = job_read_jobname

job_read_opcode = job_read_opcode

importing

job_read_jobhead = job_read_jobhead

tables

job_read_steplist = job_read_steplist

exceptions

invalid_opcode = 1

job_doesnt_exist = 2

job_doesnt_have_steps = 3

others = 99.

case sy-subrc.

when 1.

raise invalid_opcode.

when 2.

raise job_doesnt_exist.

when 3.

raise job_doesnt_have_steps.

endcase.

endfunction.

=====================

Here is the VB.net code:

=====================

Dim cs As String = "SYSTEM ASHOST=XXX.xx.xx.com R3NAME=XXX GROUP=XXXGROUPA SYSNR=00 CLIENT=888 USER=xxxxx PASSWD=xxxxx"

Dim proxy As New SAPProxy1(cs)

Dim JobList As TBTCJOB

Dim StepList As TBTCSTEPTable

proxy.Z_Monitor_Bp_Job_Read("06480001", "ZABAP", 20, JobList, StepList)

=====================

Is this is bug in the SAP.NET Connector? or is there a problem in my code?

I'm using MS Visual Studio Architect Edition 2003 and SAP .NET Connector version 2.0.

Hope someone can help me. thanks!

Regards,

Jay

Message was edited by: Jayson Brigado

Accepted Solutions (0)

Answers (1)

Answers (1)

reiner_hille-doering
Active Contributor
0 Kudos

It seems that one or more of the parameters you pass in are uninitialized (Nothing).

This is the case for TBTCJOB and TBTCSTEPTable. If they are not out-only, you should change to

Dim JobList As New TBTCJOB

Dim StepList As New TBTCSTEPTable

It's also likely the case for any proxy fields you use (I don't know if you have proxy fields). You can define default values for them in .sapwsdl designer. Or you can assign values to them before call.

If this doesn't help, please turn on the "Show Non-user Code" option in Call Stack window and post the full stack.