IDOC to XML conversion and to post it

Hi all,

I am new to SAP Integration. I am in need of your help in converting the IDOC into XML and then to send it to the customer.

I know how to get the IDOC from SAP using SAP Adapter. Once it reaches IS. I am converting the IDOC to boundnode using

pub.sap.idoc.transformFlatToHierarchy. which converts the IDOC to boundnode and I am mapping this bound node to the IDOC document structure which i have created using the DTD of the IDOC.

Now, my question is …will this structure itself is a XML? or Do I need anything to add more to convert it into an XML and then to post it.

Please suggest me how to convert it to XML and send that XML file to the partner. Please help me in solving this.

THanks,
David.

You can convert the IDOC doc structure to a valid xml format, using the built-in xml services, documentToXMLString.

Once u have the xml string, u can either send it to the target system or perform any mapping/transformations as required(to the expected output xml format). You may also need to validate the structure/values with the client.

S

Hi Smathangi,

Thanks for your reply. I got your point. So, After mapping it to a document structure i need to convert that document to XML String.

Coming to Validation. How can I validate the structure? Do I need to create a Schema? Please assist.

Thanks,
David.

First of all are you mapping the incoming idoc to any other IS document?
If YES, then you can validate that document after mapping. You can use pub.schema:validate service.

Cheers
Guna

Hi Guna,

Thanks for your reply. Actually, I am mapping the IDOC bound node to the IS DOC which i created using the IDOC DTD. And that Document has to be converted to XML.

I’m little confused.Will I need to take a DTD or XML from the customer to create a IS Doc and map the above IS DOC(which i created from IDOC DTD) to the newly created IDOC.?

And after that as suggested I use DocumenttoXMLString which converts the IS Doc to Xml string. Now where should I validate the structure.
Can you please give me a step by step procedure. I know I’m asking taking you to basic levell…but i’m little confused.

Thanks,
david.

David,

Yes, u should create a doc type using the reference(Schema/XML) from ur client, and then map the IDOC values to the xml.

S

No. You need not create the idoc once again from XSD. If you have a process like this: SAP → IDOC to IS → IDOC to custom XML mapping → Custom XML to Customer, then you need to validate the custom XML document. If all you need to do is transfer the idoc to your customer without any custom XML format then no need of validation.

Cheers
Guna

Guna and S,

Yeah, I just need to send the IDOC to the customer in XML format. And I have got it. I am using SMTP to send it to the customer. If I need any assistance. I will trouble you guys again!!

Cheers and thanks,
David.