2012 Apr 18 2:29 PM
Hello all,
I've created a BAPI in ecc6 which basically looks up a customer name for a given Vbeln no.
I have successfully exposed this BAPI externally and I can see it via my .net application and parts of the structure while debugging.
The problem I'm having is that my program is failing when I try to get the table results back out when stepping through.
or maybe I've not successfully passed in the input?
Using the VB example here http://scn.sap.com/thread/1876430 by Case Ahr, and tweaking it, I have concocted the following sub routine..
Private Sub CheckExists()
Dim StrNo As String = "87233483"
While Not String.IsNullOrEmpty(StrNo.Trim)
' create a function object
Dim myAPI As IRfcFunction = _ecc.Repository.CreateFunction("Z_BAPI_OCR_SCAN")
' prepare input parameters ( ZOcrSearch is the import structure - single value )
Dim impStruct As IRfcStructure = myAPI.GetStructure("ZOCRSEARCH")
impStruct.SetValue("DELNO", StrNo)
' fill the table parameter ( ZItemData is the export table, holding my results. )
Dim rfcTable As IRfcTable = myAPI.GetTable("ZITEMDATA")
Dim i As Integer = 0
Do While (i < 1)
Dim row As IRfcTable = CType(rfcTable.Clone, IRfcTable)
impStruct.SetValue("DELNO", StrNo)
' THIS IS THE BIT WHERE ITS ALL GETS A BIT HAZY FOR ME.
' rfcTable.Append(row)
i = i + 1
Loop
myAPI.Invoke(_ecc)
' this line fails also.
Form1.TxtSAPoutput.Text += myAPI.GetTable("ZITEMDATA").GetString("Zvbeln").ToString
' clear the value to stop the loop.
StrNo = Nothing
End While
End Sub
I've been trying for about 8 hours to get this working and its driving me crazy.
Can anyone shed any light on how to get the data back out of the BAPI
Many thanks in advance.
Dave
2012 Apr 23 11:46 AM
Hello all,
I've managed to get a little closer now with this sub routine,
I can query the BAPI and return a list of field names from the output table.
But I can't get the data out..
Any ideas?
Private Sub GetCompanyName()
Dim StrNo As String = "87233483"
While Not String.IsNullOrEmpty(StrNo.Trim)
' create a function object
Dim myAPI As IRfcFunction = _ecc.Repository.CreateFunction("Z_BAPI_OCR_SCAN")
' prepare input parameters
Dim bintable As IRfcTable = myAPI.GetTable("ZITEMDATA")
Dim impStruct As IRfcStructure = myAPI.GetStructure("ZOCRSEARCH")
impStruct.SetValue("DELNO", StrNo)
Dim am As RfcStructureMetadata = _ecc.Repository.GetStructureMetadata("ZITEMDATA")
Dim row As IRfcStructure = am.CreateStructure()
myAPI.Invoke(_ecc)
Form1.TxtSAPoutput.Text += row.Item(0).ToString & vbCrLf
Form1.TxtSAPoutput.Text += row.Item(1).ToString & vbCrLf
Form1.TxtSAPoutput.Text += row.Item(2).ToString & vbCrLf
Form1.TxtSAPoutput.Text += row.Item(3).ToString & vbCrLf
Form1.TxtSAPoutput.Text += row.Item(4).ToString & vbCrLf
Form1.TxtSAPoutput.Text += row.Item(5).ToString & vbCrLf
' clear the value to stop the loop.
StrNo = ""
Nothing
End While
End Sub
many thanks
Dave
2012 Apr 23 11:46 AM
Hello all,
I've managed to get a little closer now with this sub routine,
I can query the BAPI and return a list of field names from the output table.
But I can't get the data out..
Any ideas?
Private Sub GetCompanyName()
Dim StrNo As String = "87233483"
While Not String.IsNullOrEmpty(StrNo.Trim)
' create a function object
Dim myAPI As IRfcFunction = _ecc.Repository.CreateFunction("Z_BAPI_OCR_SCAN")
' prepare input parameters
Dim bintable As IRfcTable = myAPI.GetTable("ZITEMDATA")
Dim impStruct As IRfcStructure = myAPI.GetStructure("ZOCRSEARCH")
impStruct.SetValue("DELNO", StrNo)
Dim am As RfcStructureMetadata = _ecc.Repository.GetStructureMetadata("ZITEMDATA")
Dim row As IRfcStructure = am.CreateStructure()
myAPI.Invoke(_ecc)
Form1.TxtSAPoutput.Text += row.Item(0).ToString & vbCrLf
Form1.TxtSAPoutput.Text += row.Item(1).ToString & vbCrLf
Form1.TxtSAPoutput.Text += row.Item(2).ToString & vbCrLf
Form1.TxtSAPoutput.Text += row.Item(3).ToString & vbCrLf
Form1.TxtSAPoutput.Text += row.Item(4).ToString & vbCrLf
Form1.TxtSAPoutput.Text += row.Item(5).ToString & vbCrLf
' clear the value to stop the loop.
StrNo = ""
Nothing
End While
End Sub
many thanks
Dave
2012 May 21 10:28 AM
2012 May 25 4:06 PM
After a lot of digging, I have managed to find a work around using the RFC_READ_TABLE method.
its a shame that the .net connector 3 doesn't work / or that there isn't enough exposure to it on the web..