Skip to Content
0
Former Member
Nov 30, 2004 at 05:23 AM

'System.IndexOutOfRangeException' Error in VB

167 Views

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