Skip to content

⚗️ create a Markdown table via ABAP CDS and ABAP SQL statement SELECT

License

Notifications You must be signed in to change notification settings

Keller-Michael/Markdown_table_via_ABAP_CDS_and_ABAP_SQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

⚗️ Markdown table via ABAP CDS and ABAP SQL

Just a small, non-serious free time SAP BTP project along the lines of: “Is that actually possible?” The answer is: "Yes it is!". You can use ABAP CDS and ABAP SQL statement SELECT to get data from the database directly as a Markdown table. I can't think of a business case for this scenario, but it's nice that it's possible 😂

Design

There are 4 different ABAP CDS to create a Markdown table output for entries in database table /DMO/AIRPORT:

  1. ZI_MD_HEADER: Headline with needed columns
  2. ZI_MD_ALIGNMENT: Alignment of columns
  3. ZI_MD_LINES: Lines from database table /DMO/AIRPORT
  4. ZC_MD_TABLE: Combines the other 3 ABAP CDS from 1) to 3) by UNION

As UNION has no given sort order I solved this problem via ABAP SQL SELECT ... 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.

Output example

Raw Markdown table

|         **Airport ID**    |         Name                                     |         City                                 |         Country    |     
|         :---              |         :---                                     |         :---                                 |         :---       |     
|         ACA               |         General Juan N. Álvarez Int. Airport     |         Acapulco, Guerrero                   |         MX         |     
|         ACE               |         Lanzarote Airport                        |         Lanzarote, Canary Islands            |         ES         |     
|         BKK               |         Suvarnabhumi Airport                     |         Bangkok                              |         TH         |     
|         BOS               |         Logan International Airport              |         Boston, Massachusetts                |         US         |     
|         CDG               |         Charles de Gaulle Airport                |         Paris                                |         FR         | 

GitHub interpreted Markdown table

Airport ID Name City Country
ACA General Juan N. Álvarez Int. Airport Acapulco, Guerrero MX
ACE Lanzarote Airport Lanzarote, Canary Islands ES
BKK Suvarnabhumi Airport Bangkok TH
BOS Logan International Airport Boston, Massachusetts US
CDG Charles de Gaulle Airport Paris FR

Releases

No releases published

Packages

No packages published