SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Display DDL Source Codes in SAP GUI using ABAP Program


To display DDL source codes of SAP CDS objects like CDS Views in SAP GUI ABAP developer can run DEMO_SHOW_DDL_SOURCE program.
CDS objects like CDS views or CDS table functions are created and maintained in ADT Tools like SAP HANA Studio with SQL Console.
When you are in SAP GUI and want to see source codes of a CDS view, you can use ABAP program DEMO_SHOW_DDL_SOURCE .


CDS View created using SQL DDL Document

Here is BSIS CDS View in SAP HANA system which I use SE11 transaction to display DDL SQL View.

display CDS view in SAP GUI SE11 transaction

Note that there is DDL Source section which has the value "BSIS_DDL". When I double click it, I get only a small part of the SQL DDL source codes of the CDS view.

show SQL DDL source codes of CDS view in SAP GUI

ABAP programmers should realize the warning:
Data Definitions can only be edited using ADT in Eclipse
Message no. DDIC_ADT_DDLS005

So if you have SAP HANA Studio ADT Tool installed, using the Eclipse IDE it is possible to display the SQL data definition language source codes of the CDS view.

Fortunately, there is an ABAP report to display source codes of SQL DDL views.


DEMO_SHOW_DDL_SOURCE to Show DDL Source Codes of CDS Views

SAP provided ABAP program DEMO_SHOW_DDL_SOURCE to display DDL source codes of CDS views or other CDS objects easily in SAP GUI environment without using SAP HANA Studio.

Launch SE38 ABAP transaction to execute DEMO_SHOW_DDL_SOURCE report

SAP ABAP program DEMO_SHOW_DDL_SOURCE to show SQL codes of CDS documents

Run the program with F8

Enter the DDL source name (name of the SQL DDL document) and press Enter button. Please check on SE11 for DDL Source attribute. Do not use the DDL SQL View name instead of DDL Source name.

SQL DDL document source codes with ABAP program

Although the format of the SQL codes is confusing the developers, all of the SQL DDL codes of a CDS view can be displayed with DEMO_SHOW_DDL_SOURCE ABAP program without the requirement of an installed SAP HANA Studio.

SQL codes of SAP HANA CDS View BSIS


Create DEMO_SHOW_DDL_SOURCE ABAP Program

If DEMO_SHOW_DDL_SOURCE ABAP report does not exist on your SAP system, you can try to create it by using following ABAP codes.

REPORT Z_KODYAZ_DDLSOURCE.
" copy of DEMO_SHOW_DDL_SOURCE ABAP report

CLASS demo DEFINITION.
 PUBLIC SECTION.
  CLASS-METHODS main.
ENDCLASS.

CLASS demo IMPLEMENTATION.
 METHOD main.
  DATA name TYPE string.
  cl_demo_input=>request( EXPORTING text = 'DDL Source' CHANGING field = name ).
  TRY.
   cl_dd_ddl_handler_factory=>create( )->read(
    EXPORTING
     name = CONV ddlname( to_upper( name ) )
    IMPORTING
     ddddlsrcv_wa = DATA(ddlsrcv_wa) ).
  CATCH cx_dd_ddl_read INTO DATA(exc).
   cl_demo_output=>display( exc->get_text( ) ).
  ENDTRY.
  IF ddlsrcv_wa-source IS INITIAL.
   cl_demo_output=>display( |Nothing found| ).
   RETURN.
  ENDIF.

  cl_demo_output=>display( replace( val = ddlsrcv_wa-source sub = |\n| with = '' occ = 0 ) ).
 ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
 demo=>main( ).
Code

ABAP codes of DEMO_SHOW_DDL_SOURCE SAP program

I could get a better formatted SQL DDL source view of the CDS view I created at CDS View tutorial using "Z_Ddlsqlview" in the DDL Source input parameter as follows

SQL DDL source codes of SAP CDS view



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.