Continued from my previous post "Prototyping an ABAP OData Entity Data Model Generator : Table Relationships" :
I’ll now write about the EDMX/CSDL preparation part and completed prototype program. Finally, we’ll do a few test runs to generate edmx/xml files and see how it looks when imported into Eclipse data-modelling plug-in.
Read more »
Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts
Sunday, January 19, 2014
Saturday, January 11, 2014
Prototyping an ABAP OData Entity Data Model Generator : Simple Transformation
As mentioned in my earlier post It's the best of times, I’ve been trying to auto-generate the entity service-data-model XML ( EDMX file ) from exiting SAP database tables and their relationships.
I'll try to summarize these two approaches and available options in Service Builder before moving further with the prototype.
Read more »
Background:
SAP NetWeaver Gateway Service Builder (transaction SEGW) is a design-time environment to support creation of OData Services. It provides several options to support both, Outside-in and inside-out service Development Approaches:I'll try to summarize these two approaches and available options in Service Builder before moving further with the prototype.
Read more »
Saturday, October 6, 2012
Power of the Core : Using XSD for XML Transformation in ABAP
I've already written a few posts on how to use the graphical editor to create Simple Transformations but I guess that's not good enough for lazy developers like me.
So now we are going to try a different approach assuming we already have the XSD file that describes the structure of the required XML.
Let's say you have an XSD file for which you want to generate/transform XML <-> ABAP. Of course you don't want to create the corresponding ABAP Structures or Simple Transformations manually neither you are interested in hearing about capability of another SAP Product in this field e.g. SAP PI/CE etc. That said ..
Labels:
ABAP,
SAP,
XML
16
comments
Saturday, May 26, 2012
Simple Transformation for XML in ABAP - Part III & some JSON on the side
This is just to explain a bit further on one of my comments from the earlier XML related post : Generate Simple Transformation for XML in ABAP - Part II.
There were a few questions regarding transforming ABAP ITABs with deep structures to XML and setting encoding ( other than default UTF-8 ) for the output XML etc.
Sunday, April 5, 2009
Generate Simple Transformation for XML in ABAP - Part II
Just wanted to quickly add some more information to my last post on the same topic "Discovering a Hidden Gem :Generate Simple Transformation for XML in ABAP"
In this example, I will show how to use "Edit Simple Transformation Graphically" feature of XSLT_TOOL to generate simple transformations for XML elements having attributes.
Let's say there is a requirement to generate XML document from the ABAP data/ internal tables. And the resultant XML document should have the following structure. Basically, POST_CODE should be an attribute of "Town" element.
In this example, I will show how to use "Edit Simple Transformation Graphically" feature of XSLT_TOOL to generate simple transformations for XML elements having attributes.
Let's say there is a requirement to generate XML document from the ABAP data/ internal tables. And the resultant XML document should have the following structure. Basically, POST_CODE should be an attribute of "Town" element.
<?xml version="1.0" encoding="utf-8" ?>Initial steps are similar to the example in my last post [ so I've just copied the screen shots from there ] Read more »
<NewDataset>
<Table>
<Town POST_CODE="B5">BIRMINGHAM</Town>
<County>WARWICK</County>
</Table>
<Table>
<Town POST_CODE="NP20">NEWPORT</Town>
<County>WALES</County>
</Table>
</NewDataset>
Labels:
ABAP,
SAP,
XML
29
comments
Tuesday, February 3, 2009
Discovering a Hidden Gem :Generate Simple Transformation for XML in ABAP
Even in its most nascent form, this less known wizard of simple transformation, could be really useful for ABAP developers. I think, ABAP developers would love to have a graphical utility to generate simple transformation/XSLT code.
Now the result variable lv_output will be having the data in the form of an XML string as below.
Tip: You can use a function module SCOL_TRACE_SHOW_XML to show the XML data on screen.
By the way, I checked this on SAP ECC6.0. I will try to explore further for complex XML e.g. elements having attributes.
Please do add your inputs, if you managed to check this out or have done this before.
Updated:
SAP Help document for ST is at http://help.sap.com/abapdocu/en/ABENABAP_XML.htm
Almost a year back, I was writing some happy-code to consume an external web service from ABAP. As the web service was returning the result data in the form of an XML string, I ended up writing a Simple Transformation to get the values in ABAP internal table.
Consuming webservice from ABAP is not the topic of this post but if you need help on this then please check the blogs on SDN. However, If you need to post an answer on a twitter-interview ( similar to a telephonic interview but held on twitter ) then there you go :Xn SE80->Repository Browser->Enterprise Services->[ right click to bring the context menu ] -->Create Proxy [ use WSDL URL e.g. http://www.webservicex.net/uklocation.asmx?WSDL to generate proxy through wizard ]. Xn LPCONFIG to configure the logical port.
Back to the topic, I spotted this magic-stick in Simple Transformation editor [ Transaction XSLT_TOOL ] and tried to make it work. But could not decipher and wrote the ST manually, instead. Interestingly, I could not find any information about this so called "Edit Simple Transformation Graphically" feature. In my defence, I searched on SAP OSS, SAP Help & SDN. There you go ...Well search feature on SAP Sites.. is great anyway ;)
A year later, I just happened to be adoring ( developers do this often ) my old code and it reminded me of this utility. I tried figuring out once again and managed to discover something worth sharing.
Service proxy call provides data in the form of XML result. Code for proxy call is as below:
CREATE OBJECT LO_UK_LOCATION. TRY. lv_input-POST_CODE = p_post. CALL METHOD LO_UK_LOCATION->GET_UKLOCATION_BY_POST_CODE EXPORTING INPUT = lv_input IMPORTING OUTPUT = lv_output. CATCH CX_AI_SYSTEM_FAULT . WRITE : 'CX_AI_SYSTEM_FAULT'. CATCH CX_AI_APPLICATION_FAULT . WRITE : 'CX_AI_APPLICATION_FAULT'. ENDTRY.
Now the result variable lv_output will be having the data in the form of an XML string as below.
Tip: You can use a function module SCOL_TRACE_SHOW_XML to show the XML data on screen.
<NewDataSet>In order to transform the XML to ABAP internal table, I decided to use Simple Transformation. Now I will generate the simple transformation as below:
<Table>
<Town>Balthangie</Town>
<County>Aberdeenshire</County>
<PostCode>AB53</PostCode>
</Table>
<Table>
<Town>Bankhead</Town>
<County>Aberdeenshire</County>
<PostCode>AB51</PostCode>
</Table>
</NewDataSet>
- Create Table Type ZNEWDATASET in transaction SE11. The hierarchy structure should be compatible with the XML hierarchy.
- Now create the ST program in transaction XSLT_TOOL. Spot the magic stick in the editor menu.
- Click on 'Edit Simple Transformation Graphically' button (magic stick) and you will get the editor as below. Create a new root (right click - context menu ) in "Data Roots" section. I've named it NEWDATASET but the important thing is to enter the correct type, created earlier.
- Now you can see the data root hierarchy as below. Drag and Drop the NEWDATASET root on right panel ( Simple Transfromation ). It automaically generates the ST nodes corresponding to the ABAP structure. However, you need to adjust the names as per the XML element names.
- Now adjust the names in ST panel as per actual XML element names.
- Save and Activate. The ST program (Z_TEST), generated by the utility, is as below:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary" xmlns:def="http://www.sap.com/abapxml/types/defined">
<tt:root name="NEWDATASET" type="ddic:ZNEWDATASET"/>
<tt:template>
<NewDataSet>
<tt:loop ref=".NEWDATASET">
<Table>
<Town tt:value-ref="TOWN"/>
<County tt:value-ref="COUNTY"/>
<PostCode tt:value-ref="POST_CODE"/>
</Table>
</tt:loop>
</NewDataSet>
</tt:template>
</tt:transform> - Now use the code below to get data into ABAP internal table.
data : result type ZNEWDATASET, "itab of table type ZNEWDATASET wa_result like line of result. call transformation Z_TEST source xml lv_output-GET_UKLOCATION_BY_POST_CODE_R result newdataset = result[]. LOOP AT result into wa_result. WRITE :/ wa_result-TOWN, wa_result-COUNTY, wa_result-POST_CODE. ENDLOOP.
By the way, I checked this on SAP ECC6.0. I will try to explore further for complex XML e.g. elements having attributes.
Please do add your inputs, if you managed to check this out or have done this before.
Updated:
SAP Help document for ST is at http://help.sap.com/abapdocu/en/ABENABAP_XML.htm
* It's better to Display XML from ABAP as below :
cl_abap_browser=>show_xml( EXPORTING xml_string = xml_string ).
Labels:
ABAP,
SAP,
Webservice,
XML,
XSLT_TOOL
13
comments
Subscribe to:
Posts (Atom)
Copyright
This site uses cookies just to track visits to this website.

This work is licensed under a Creative Commons Attribution 3.0 Unported License.







