cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a Messages object via GetBusinessObjectFromXML

Former Member
0 Kudos

Has anyone got a working example of this? I always get an "Invalid XML File" error.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

It means that the xml you passed in is not correct from the prespective of the BO.

The typical way to do this is:

- Get a BO object by key

- Call ToXMLString() method and check the structure of the xml content

- Program your code to prepare the xml with the same structure.

Regards,

Tedy

Former Member
0 Kudos

Hello

Could u explain bit more

i mean when ur getting error..?

Firos

Former Member
0 Kudos

Here are some more details. Also there is no GetByKey() or ToXMLString() function on the SAPbobsCOM.Messages object.


        Dim oMSG As SAPbobsCOM.Messages = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oMessages)
        oMSG = oCompany.GetBusinessObjectFromXML("C:\iBOLT2.5\projects\Alert\test.xml", 0) '<-error happens here

Contents of test.xml file


<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
<BOM>
<BO>
<Messages>
<row>
<Priority>pr_High</Priority>
<Subject>subject</Subject>
<MessageText>body</MessageText>
</row>
</Messages>
<Recipients>
<row>
<UserType>rt_InternalUser</UserType>
<UserCode>manager</UserCode>
<SendInternal>tYES</SendInternal>
</row>
</Recipients>
</BO>
</BOM>

Former Member
0 Kudos

Yes you are right that specifically Message object has no GetByKey method.

I suppose to provide a general method to know how the acceptable xml per each BO would be like.

In addition to my original method, for all BO w/o GetByKey, usually there is a corresponsent service object to get a BO. For example, for Messge object, call MessagesService.GetMessage(header) to get a Message object.

Cheers,

Tedy

Former Member
0 Kudos

Still no luck. I tried generating the XML schema with GetBusinessObjectXmlSchema(SAPbobsCOM.BoObjectTypes.oMessages) which changed my XML file slightly, but I'm still getting the same error. I'll have to open a support ticket. Thanks for the help.


<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
<BOM>
<BO>
<OALR>
<row>
<Priority>pr_High</Priority>
<Subject>test subject</Subject>
<UserText>test body</UserText>
</row>
</OALR>
<AOB1>
<row>
<ObjType>rt_InternalUser</ObjType>
<ObjCode>manager</ObjCode>
<SendIntrnl>tYES</SendIntrnl>
</row>
</AOB1>
</BO>
</BOM>

Former Member
0 Kudos

Hi Mark,

I also met the error you mentioned when I gave it a little try. I verify that your xml attached is valid against the schema from calling GetBusinessObjectXmlSchema method. It should be a bug.

From the DI help, you may try the MessagesService Object and GetDataInterfaceFromXMLFile method. Caution that the xml payload would be different.

Good luck.

Tedy