Skip to Content
Author's profile photo Former Member

Update HANA table and column descriptions from ABAP Dictionary.

If you are modelling HANA views based on a Suite (like ERP, CRM, SRM) on HANA system, you would probably like to have the table and table field descriptions from the ABAP Dictionary available to you in the HANA Studio Modeler/Editor. Once this ABAP report has been ran the table and column description are shown in the HANA Studio editor and automatically copied to the semantic layer:


Run the following ABAP report in the background to update the descriptions in the HANA database based on the ABAP Dictionary. Only works on NW 7.4 (ERP Ehp7 or BW 7.4 or CRM 7 Ehp 3) system:

REPORT z_hana_set_table_comments.
DATA: lt_tables       TYPE TABLE OF dd02t,
      lv_table        TYPE dd02t,
      lt_dfies        TYPE TABLE OF dfies,
      lv_dfies        TYPE dfies,
      lv_fieldcomment TYPE string.
SELECT t~tabname t~ddtext into corresponding fields of table lt_tables FROM dd02t AS t
  INNER JOIN dd02l AS l ON l~tabname = t~tabname WHERE t~as4local = 'A' AND t~ddlanguage = sy-langu AND l~tabclass = 'TRANSP'.
LOOP AT lt_tables INTO lv_table.
      NEW cl_sql_statement( )->execute_ddl(
           ` COMMENT ON TABLE "` && lv_table-tabname && `" is '` && lv_table-ddtext && `' ` ).
          tabname        = lv_table-tabname
          langu          = sy-langu
          dfies_tab      = lt_dfies
          not_found      = 1
          internal_error = 2
          OTHERS         = 3.
      IF sy-subrc = 0.
        LOOP AT lt_dfies INTO lv_dfies.
              lv_fieldcomment = cl_abap_dyn_prg=>escape_quotes( CONV string( lv_dfies-fieldtext ) ).
              NEW cl_sql_statement( )->execute_ddl(
                         ` COMMENT ON COLUMN "` && lv_table-tabname && `"."` && lv_dfies-fieldname && `" IS '` && lv_fieldcomment && `' ` ).
            CATCH cx_sql_exception INTO DATA(oreffield).
              WRITE: / 'Error: ', oreffield->get_text( ).
               COMMIT WORK.
    CATCH cx_sql_exception INTO DATA(oref).
WRITE: / 'Table and field comments updated.'.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      That was a saviour, thank you Onno Bagijn  it saved lot of our efforts 🙂


      Sindhoora Leburi

      Author's profile photo Benedict Venmani Felix
      Benedict Venmani Felix

      This is nice. In my previous project, we used a BW on HANA system and i used to do this 'comment on column' update running manual sql statement for every field in a table. And, finally when we import the developed view into QA everything would be gone 😥

      If only I had seen this then 🙂


      Author's profile photo Former Member
      Former Member

      Very helpful.
      Thanks for this

      Author's profile photo Former Member
      Former Member

      Thank you for this info Former Member. I have asked my basis consultant to run this report but he refused as this is not an sap standard z report. is this report mentioned in oss note?  Is this report standard 'Z' report with different report name?

      any information regarding above would be appreciated..

      Thanks in advance.

      Author's profile photo Paolo Croene
      Paolo Croene

      Hello Onno,

      thank you for sharing this.
      Just a quick question: our system (S/4HANA 1709FPS01) is based on NW7.52; would this code work, or is it meant only for NW7.40?


      Thanks and regards