0% found this document useful (0 votes)
1K views3 pages

Connect and Query SAP Using BAPI

This document contains notes on testing integration between VB.NET and SAP's .NET Connector for calling a BAPI function. It describes creating a function module object in SAP, adding input parameters, executing the function, and retrieving output tables. The code sample calls the BAPI_MATERIAL_GETLIST function to search for materials matching a wildcard criteria and outputs the results.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views3 pages

Connect and Query SAP Using BAPI

This document contains notes on testing integration between VB.NET and SAP's .NET Connector for calling a BAPI function. It describes creating a function module object in SAP, adding input parameters, executing the function, and retrieving output tables. The code sample calls the BAPI_MATERIAL_GETLIST function to search for materials matching a wildcard criteria and outputs the results.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

'NOTES: DEVELOPED 5/19/2011, BY JSMITHHART, FOR TESTING OF VB.

NET INTEGRATION WI
TH SAP NCO, .NET CONNECTOR VERSION 3, 64 BIT
'EMAILS CAN BE SENT TO [Link], WITH THE NAME OF JS1000 (THOSE ARE ZEROS)
'THIS YAHOO ADDRESS IS USED FOR SPAM PURPOSES, SO IF I DON'T ANSWER QUICKLY, THE
RE'S A REASON FOR IT. SORRY.
'HAVE A GREAT, BLESSED DAY!
'METADATA: SAP NCO, SAP .NET CONNECTOR, BAPI, BAPI_MATERIAL_GETLIST, MATNRS
ELECTION, CreateFunction, GetTable, SE37, FUNCTION MODULE,
' MATNRLIST, GetStructure, TESTING, FUNCTION BUILDER, ECD,
TEXT/EXECUTE F8, CHANGE, DISPLAY, FUNCTION MODULE DOCUMENTATION
Private _ecc As RfcDestination
Private Sub btnBAPI_MATERIAL_GETLIST_Click(ByVal sender As [Link], By
Val e As [Link]) Handles btnBAPI_MATERIAL_GETLIST.Click
Try
Connect()
Catch ex As Exception
If Not [Link]([Link]) Then
If [Link] = "destination configuration already
initialized" Then Exit Try
End If
[Link](ex, [Link], [Link])
Exit Sub
End Try
Dim MaterialFunction As IRfcFunction = Nothing
Dim IRfcMATNRLIST As IRfcTable = Nothing
Dim IRfcMATNRSELECTION As IRfcTable = Nothing
Dim IRfcMATERIALSHORTDESCSEL As IRfcTable = Nothing
Dim IRfcRETURN As IRfcTable = Nothing
Try
'View transaction SE37 to see how this will work in the GUI.
'Create Function
MaterialFunction = _ecc.[Link]("BAPI_MATERIAL_GET
LIST")
'Add parameters to proper table, see GetTable
IRfcMATNRSELECTION = [Link]("MATNRSELECTION")
'You need to add a row, because you are setting values. For every ne
w series of values, append new row.
[Link](1) 'this snippet of information comes f
rom here: [Link]
'Assign values to the fields:
[Link]("SIGN", "I")
[Link]("OPTION", "CP")
[Link]("MATNR_LOW", "000000000002*") '18 digit
field, use * as wildcard.
[Link]("MATNR_HIGH", "")
'Executes the Function (BAPI in this case)
[Link](_ecc)
'Get the return values, from various tables
IRfcMATNRLIST = [Link]("MATNRLIST")
IRfcMATNRSELECTION = [Link]("MATNRSELECTION")
IRfcMATERIALSHORTDESCSEL = [Link]("MATERIALSHORTD
ESCSEL")
IRfcRETURN = [Link]("RETURN")
[Link]("************************* IRfcMATERIALSHORTDES
CSEL ******************************************")
For i As Int32 = 0 To [Link] - 1
[Link] = i
[Link]([Link]((i + 1).[Link](4, "0"c), "
:"), vbTab)
[Link]([Link]("SIGN:", [Link]
tString("SIGN"), vbTab))
[Link]([Link]("OPTION:", IRfcMATERIALSHORTDESCSEL.
GetString("OPTION"), vbTab))
[Link]([Link]("DESCR_LOW:", IRfcMATERIALSHORTDESCS
[Link]("DESCR_LOW"), vbTab))
[Link]([Link]("DESCR_HIGH:", IRfcMATERIALSHORTDESC
[Link]("DESCR_HIGH"), vbTab))
[Link]([Link])
Next

[Link]("************************* IRfcMATNRSELECTION
************************************************")
For i As Int32 = 0 To [Link] - 1
[Link] = i
[Link]([Link]((i + 1).[Link](4, "0"c), "
:"), vbTab)
[Link]([Link]("SIGN:", [Link]
g("SIGN"), vbTab))
[Link]([Link]("OPTION:", [Link]
ing("OPTION"), vbTab))
[Link]([Link]("MATNR_LOW:", [Link]
String("MATNR_LOW"), vbTab))
[Link]([Link]("MATNR_HIGH:", [Link]
tString("MATNR_HIGH"), vbTab))
[Link]([Link])
Next
[Link]("************************* IRfcMATNRLIST ****
***************************************************")
For i As Int32 = 0 To [Link] - 1
[Link] = i
[Link]([Link]((i + 1).[Link](4, "0"c), "
:"), vbTab)
[Link]([Link]("Material:", [Link]
("MATERIAL"), vbTab))
[Link]([Link]("MatDesc:", [Link](
"MATL_DESC").PadRight(70, " "c), vbTab))
[Link]([Link]("MatExternal:", [Link]
ing("MATERIAL_EXTERNAL"), vbTab))
[Link]([Link]("MatGuid:", [Link](
"MATERIAL_GUID"), vbTab))
[Link]([Link]("MatVersion:", [Link]
ng("MATERIAL_VERSION"), vbTab))
[Link]([Link])
Next
Catch ex As Exception
[Link](ex, [Link], [Link])
Exit Sub
End Try
End Sub

You might also like