Ask the Expert

Problem sending unique keys with Material number


    Requires Free Membership to View

still new to BAPI. I started my project with simple programming to retrieve Material General Data from SAP, with Material(material number) to be given by a user using an interface in Visual Studio. Thank God my connection from VB to SAP successfully connected. But I have a problem sending unique keys. Below is my code:

boMaterial = oBAPICtrl.GetSAPObject("BUS1001", "Material")
oMaterialDesc = boMaterial.GetDetail(return:=oReturn, MaterialGeneralData:=oMaterialDesc)

TextBox2.Text = oMaterialDesc

But it keeps showing this error: "The runtime object of type Material with the persistent key Material could not be created in the Business Object Repository."

I tried it with the code:

boMaterial = oBAPICtrl.GetSAPObject("BUS1001")

oMaterialDesc = boMaterial.GetDetail(return:=oReturn, _ MaterialGeneralData:=oMaterialDesc)
TextBox2.Text = oMaterialDesc

and the error is: "The persistent key for a Business Object instance of type Material has not been set. Cannot invoke method GETDETAIL"

Could you please show me how to fix this problem? I really need help. And do you have a Web site or anything that can help me finish my little project? Thank you very much for your help. I really appreciate it.
In this source code statement:
- boMaterial = oBAPICtrl.GetSAPObject("BUS1001", "Material")
change "Material" to the actual material number (e.g., "TGS100") you are interested in, so that your statement looks like this:
- boMaterial = oBAPICtrl.GetSAPObject("BUS1001", "TGS100")
or this:
- boMaterial = oBAPICtrl.GetSAPObject("BUS1001", variableContainingMaterialNumber)
And you can replace "BUS1001" by "Material". They both refer to the same business object:
- boMaterial = oBAPICtrl.GetSAPObject("Material", "TGS100")

This was first published in July 2004

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: