Copyright 2023 - BV TallVision IT

There is quite some functionality available on XML processing, especially in the form of the TRANSFORMATION. If you are not familiar with transformations, this is a must-see when handling XML files. The missing link with the transformation is interpreting the XML data. For this too, a lot of functionality is available, which takes a lot of effort to implement. Too much effort, to my opinion, so I developed a wrapper class lcl_Easy_ALV, with a set of examples for you to use.

LCL_EASY_XML wrapper class

A local class (hence lcl_ which can be made available by a simple upload into an include. From the include the class can be used directly. Wrapper classes tend to add their functionality to an already existing setup, which is (in this case) SAP's all standard CL_ class.

I've used the XML wrapper class to store a data model with information into an XML structure. This is a very powerful concept, because where the data model has (key)values in al it's tables, values will only need to be specified once in a properly formed XML. Hence a download to XML, rename of this main key field followed by an upload would effectively copy the whole data model.

The wrapper class is aimed at the upload part of this setup. For the download part (creating an XML file), the all standard SAP TRANSFORMATION is definitely the way to go.

To download the INCLUDE that holds the LCL_EASY_XML class, simply click on the download button and create an include with it's content. Alternatively, you could copy the downloaded content into your source code and try it out from there.


An example XML file (with a bit of bite)

We'll use a sample XML file to demonstrate how the LCL_EASY_XML class can be made to use:

<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu name="Giggles menu" id="MENU923">
  <food id="FOOD412">
    <name>Belgian Waffles</name>
    <description language="EN">Two of our famous Belgian Waffles with plenty of real maple syrup</description>
  <food id="FOOD022">
    <name>Strawberry Belgian Waffles</name>
    <description language="EN">Light Belgian waffles covered with strawberries and whipped cream</description>

A few things on the XML presented here: the nodes have content, in the form of nodes or an actual value. Nodes can also have attributes, which are (in this example) used to hold unique ID values (key values) from the table they originated from.