Wednesday 16 September 2015

Standing on the shoulders of giants.... [SAPLINK]

Okay, so halfway through looking for xlsx downloads, I came across the following : 

SAPLINK : A project / set of programs that allows users to upload+download vast swathes of code, dictionary objects etc outside of the traditional transport methodology:

http://wiki.scn.sap.com/wiki/display/ABAP/SAPlink+User+Documentation


Then once you've got SAPLINK working, you can load in the ZCL_EXCEL* classes, which will do all the Excel work for you...

https://github.com/ivanfemia/abap2xlsx/wiki/Installation-guide

Once again, I'm blown away by the generosity of the community in sharing their code, and generally making life better for their fellow developers! Good work all!



Monday 14 September 2015

XSLT Pointer

This is as much for my own future reference as for anyone else's help... but it's been a while since I'd done any XSLT. Since all the examples had the same incoming XML tags as the outgoing mapped structures, it was confusing as to what referred to incoming, and what referred to outgoing : 



The rule of thumb I'm following (pragmatic until the last!) is that if it's in quotes and has "ss:" in it, then that's from the source, and any "xml:element" content refers to the outgoing data.

Trying to access the "Attributes" in the source XML is simply a matter of using the "@" symbol.



So the above takes the following xml:

 <row r="2" x14ac:dyDescent="0.25" spans="1:5">
  <c r="A2" t="s"><v>5</v></c>
  <c r="B2" t="s"><v>6</v></c>
  <c r="C2" t="s"><v>7</v></c>
  <c r="D2" t="s"><v>8</v></c>
  <c r="E2" t="s"><v>9</v></c>
 </row>

and spits out xml tags without attributes... the "r" attributes have been chucked into "C1" tags:

<sheetData>
  <row>
    <c>
      <c1>A1</c1>
      <v>0</v>
    </c>
    <c>
      <c1>B1</c1>
      <v>1</v>
    </c>
    <c>




Thursday 10 September 2015

XLSX Upload using XSLT

Having been tasked with an upload of xlsx (as well as xls, but hey, there's a quarter-dozen ways of doing that and we all know what they are!) I came across this:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6026d7c0-c716-3010-c8be-ea771ff9d783?QuickLink=index&overridelayout=true&57720065492913

You need to use the XSLT to do the transformation. SAP could really do with writing this into a standardised method, but I daresay someone else might beat them to it!

Good work Manu!

For me, the really interesting thing about this is the way that the xlsx files are structured. I was astonished at the way the shared string file works, but the amount of disk space that gets saved off the back of that could be massive.

Another thing to mention is that the XSLT transformations ARE CASE SENSITVE.
I just spent a cuppla hours having transformations fail on me because I'd not translated to upper case. Eugh. What a day.