Skip to Content

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:

at_view.PNG

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
*&
*&---------------------------------------------------------------------*
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.
  TRY.
      NEW cl_sql_statement( )->execute_ddl(
           ` COMMENT ON TABLE "` && lv_table-tabname && `" is '` && lv_table-ddtext && `' ` ).
      CALL FUNCTION 'DDIF_FIELDINFO_GET'
        EXPORTING
          tabname        = lv_table-tabname
          langu          = sy-langu
        TABLES
          dfies_tab      = lt_dfies
        EXCEPTIONS
          not_found      = 1
          internal_error = 2
          OTHERS         = 3.
      IF sy-subrc = 0.
        LOOP AT lt_dfies INTO lv_dfies.
          TRY.
              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.
          ENDTRY.
        ENDLOOP.
      ENDIF.
    CATCH cx_sql_exception INTO DATA(oref).
  ENDTRY.
COMMIT WORK.
ENDLOOP.
WRITE: / 'Table and field comments updated.'.






To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member

    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 🙂

    Benedict

    (0) 
  2. 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.

    (0) 
  3. Former Member

    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
    Paolo

    (0) 

Leave a Reply