Problem sending unique keys with Material number

Problem sending unique keys with Material number

Hi,
I'm

    Requires Free Membership to View

    When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSAP.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSAP.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

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

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.