Q

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 first published in July 2004

Dig deeper on SAP MM

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

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.

0 comments

Oldest 

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:

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close