Problem solve Get help with specific problems with your technologies, process and projects.

Problem sending unique keys with Material number

Hi, I'm 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 last published in July 2004

Dig Deeper on SAP MM



Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.