Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
wolfgang_woehrle
Product and Topic Expert
Product and Topic Expert
You might know the formatter (a.k.a. pretty printer) in the core development scenario. It aligns the source code in accordance to predefined rules. Consequently, it adds/removes, for example, tab stops, line breaks, spaces and improves readability.

As of SAP NetWeaver AS for ABAP 7.51 innovation package SP00, you can also use the formatter for CDS entities. Open your CDS entity and choose Source Code > Format from the context menu.



Formatting is then performed directly in the editor.

Predefined Profiles


SAP provides you a predefined default configuration. But, you can also define your own formatting behavior for specific use cases. You can even share this profile with your team by exporting or importing it from them. Not bad!

You configure the DDL Formatter using a profile for each ABAP project in the Preferences. Open the ABAP Development > Editors > DDL Formatter Preferences page.



Here you find SAP’s standard profile. To create your own choose New or Edit to adapt the default profile.

The Profile dialog is then opened. From here you can open several tabs to define specific formatting behavior.



An integrated preview helps you to check the outcome of your configuration when typing.

For more information, look here Formatting DDL
9 Comments
Joseph_BERTHE
Active Contributor
0 Kudos
Hello,

Very good blog 🙂

I try to do what you explained but I have an error :

DDL formatter is not available in project 'blablabla'



What do you think ?

Regards

 

 
wolfgang_woehrle
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Joseph,

I am sorry for my late response.

On which SAP NetWeaver release is your S01 system based?

Formatting is supported as of SAP NetWeaver AS for ABAP 7.51 innovation package SP00

Kind regards,

Wolfgang
sundeepc
Explorer
0 Kudos
Hello Wolfgang,

DDL Formatting is a great feature for CDS Views. Thanks for this blog.

We are on the NetWeaver ABAP release 7.50 SP07 (SAPK-75007INSAPABA) and it says DDL formatter is not supported. Do we require BW 7.51 for the formatting to work or is there an equivalent 7.50 Patch or note that we can apply to get this working? Any help is greatly appreciated.

Thanks,

Sundeep

 
wolfgang_woehrle
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Sundeep,

thank you for your kind feedback.

Formatting is supported as of SAP NetWeaver AS for ABAP 7.51 innovation package SP00

So, NW7.50 SP07 does not yet support CDS formatting. I think the issue does not relate with BW 7.51.

Kind regards,

Wolfgang
Joseph_BERTHE
Active Contributor
0 Kudos

Thanks for your response... and sorry for the delay. At least with my S/4Hana system I have retreive the file that anyone can import into eclipse :

<?xml version="1.0" encoding="UTF-8"?>
<java class="java.beans.XMLDecoder">
<object class="com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration">
<void property="associationBlockAligment">
<object class="java.lang.Enum" id="DdlPrettyPrintConfiguration$BlockAlignmentEnum0" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$BlockAlignmentEnum</class>
<string>BlockAlignmentEnabled</string>
</object>
</void>
<void property="associationOnConditionAlignment">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$AssociationOnConditionAlignmentEnum</class>
<string>InSameLine</string>
</object>
</void>
<void property="booleanExpressionAlignment">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$BooleanExpressionAlignmentEnum</class>
<string>BreakBeforeANDKeyword</string>
</object>
</void>
<void property="configurationName">
<string>SAP_CDS_DDLS_STANDARD</string>
</void>
<void property="dataSourceAlignment">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$DataSourceAlignmentEnum</class>
<string>DataSourceInSameLine</string>
</object>
</void>
<void property="dataSourceIndent">
<object class="java.lang.Enum" id="DdlPrettyPrintConfiguration$IndentEnum0" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$IndentEnum</class>
<string>NoIndent</string>
</object>
</void>
<void property="default">
<boolean>true</boolean>
</void>
<void property="elementListEntryBlockAlignment">
<object idref="DdlPrettyPrintConfiguration$BlockAlignmentEnum0"/>
</void>
<void property="elementListEntryCommaLocation">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$SelectListCommaLocation</class>
<string>COMMA_AT_END</string>
</object>
</void>
<void property="elementListEntryIndention">
<object class="java.lang.Enum" id="DdlPrettyPrintConfiguration$IndentEnum1" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$IndentEnum</class>
<string>Indent</string>
</object>
</void>
<void property="entityNameAlignment">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$EntityNameAlignmentEnum</class>
<string>EntityNameInSameLine</string>
</object>
</void>
<void property="entityNameIndent">
<object idref="DdlPrettyPrintConfiguration$IndentEnum0"/>
</void>
<void property="indentationSize">
<int>2</int>
</void>
<void property="joinAlignment">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$JoinAlignmentEnum</class>
<string>LeftAndRightDataSourceInSeparateLine</string>
</object>
</void>
<void property="joinIndent">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$JoinIndentEnum</class>
<string>Indent</string>
</object>
</void>
<void property="joinOnConditionAlignment">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$JoinOnConditionAlignmentEnum</class>
<string>OnConditionInSameLine</string>
</object>
</void>
<void property="joinOnConditionBlockAlignment">
<object idref="DdlPrettyPrintConfiguration$BlockAlignmentEnum0"/>
</void>
<void property="joinOnConditionIndentation">
<object idref="DdlPrettyPrintConfiguration$IndentEnum1"/>
</void>
<void property="keepEmptyLines">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$KeepEmptyLinesEnum</class>
<string>KeepEmptyLines</string>
</object>
</void>
<void property="selectClauseAlignment">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$SelectListAlignmentEnum</class>
<string>SelectListInSeparateLine</string>
</object>
</void>
<void property="selectListIndent">
<object idref="DdlPrettyPrintConfiguration$IndentEnum0"/>
</void>
<void property="versionNumber">
<int>1</int>
</void>
<void property="whereClauseAlignment">
<object class="java.lang.Enum" method="valueOf">
<class>com.sap.adt.cds.ddl.ddlsources.prettyprint.DdlPrettyPrintConfiguration$WhereClauseAlignment</class>
<string>BreakAfterWhere</string>
</object>
</void>
<void property="whereClauseBlockAlignment">
<object idref="DdlPrettyPrintConfiguration$BlockAlignmentEnum0"/>
</void>
</object>
</java>

Copy it into a file without specific extension and then import the file in eclipse.

Regards,

Joseph

0 Kudos
Hey guys, I work with Eclipse and an S/4 system. The DDL Formatter is not available for me. Is it available for S/4 systems or only for NetWeaver 7.51?

Thanks!
wolfgang_woehrle
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Rene,

The ABAP CDS DDL Formatter is supported as of SAP NetWeaver AS for ABAP 7.51 innovation package SP00 and higher. This means, your S/4 system (in the context of on-premise) should support this formatter.

Please provide me more information what do you mean with "not available". Please also see here my latest ADT documentation.

Kind regards,

Wolfgang

 

Balu483
Participant
0 Kudos

hi wolfgang.woehrle,

i didn't find option to convert names to lower case and keywords to upper case when format is applied on CDS DDL source code.

can you help me how to convert keywords to upper case and non keyword to lower case (Like ABAP Pretty printer)

regards,

Balu.

wolfgang_woehrle
Product and Topic Expert
Product and Topic Expert

Hi Balu,

I am sorry, there is no DDL formatter to convert element names or keyword in upper or lower case.

It was decided to keep the keywords in ABAP CDS source code in lower case. Identifiers are converted to original case (=> as it is written in the definition of the data source/element).

Kind regards,

Wolfgang