Markdown table via ABAP CDS and ABAP SQL
Dear SAP Community, since I really appreciate Markdown and you can easily design tables with it, I was wondering whether you could have the database generate a Markdown table directly using ABAP CDS (so to say some kind of "Code Pushdown").
This task is easily possible purely via ABAP, but via ABAP CDS? The answer is: it works. At least in my solution ABAP CDS does most of the work. The ABAP SQL SELECT statement has to do the rest.
Before you continue reading, please note that this is a fun blog without a serious business use case. At least none that comes to mind right away. So just for your infotainment 😁
Design
The goal is to output entries from database table /DMO/AIRPORT as Markdown table. To fulfill this requirement, I created 4 different ABAP CDS:
As UNION has no special sort order and I didn't find a good solution to bring the whole thing into right order, I solved that problem via ABAP SQL statement "SELECT" with addition "ORDER BY".
METHOD if_oo_adt_classrun~main.
SELECT * FROM zc_md_table
ORDER BY AirportID
INTO TABLE @DATA(markdown_table).
out->write( markdown_table ).
ENDMETHOD.
Recommended by LinkedIn
Example
I couldn't show the raw and formatted output on LinkedIn for technical reason. Please check my GitHub repository to see an example.
Have fun, thanks for reading and stay healthy
Michael
P.S.: I'm always happy to make new contacts. Everyone learns more through exchange of information. So feel free to connect on LinkedIn or GitHub.
Solution Architect | Director at SAP Architecture & Platform Advisory 🇯🇵 🇩🇪
10moLLMs handle markdown very well, therefore your approach removes the conversion step. It's certainly useful (e.g. from an ABAP GenAI SDK perspective 😉)! Thanks for sharing!
SAP BTP Solution Architect at Nestlé
10moThanks for sharing