Quantcast
Channel: SCN : All Content - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6745

Update HANA table and column descriptions from ABAP Dictionary.

$
0
0

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_query(           ` 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_query(                         ` 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.'.

Viewing all articles
Browse latest Browse all 6745

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>